ffmpeg cheatsheet

How to convert video files using the command line

Installation

apt-get install -y ffmpeg
apt-get install -y libavcodec-extra-53 libavdevice-extra-53 libavformat-extra-53 libavutil-extra-51 libpostproc-extra-52 libswscale-extra-2 

Examples

Convert video

ffmpeg -i [source-file] -strict experimental -f mp4 -c:v libx264 -crf 20 -maxrate 15000k -c:a aac -b:a 160k [target-file] /dev/null 2>[log-file] &

-i       = input file 
-f       = container
-an      = audio deaktivieren
-c:v     = video encoder ( libx264 = encoder für h.264)
-crf     = visuelle qualität (differenz zum originalbild --> niedrieger wert=besser)
-maxrate = maximale bitrate die benutzt wird um die qualität unter -crf zu erreichen
-c:a     = audio encoder (aac eingebauter ffmpeg aac encoder, hinweis: flag -sctrict experimental setzen)
-b:a     = audio bitrate (konstant)

Show video information

ffprobe -v quiet -print_format json -show_format -show_streams 

generate 5 preview images in 800x600px:

./bin/ffmpeg-2.5.4-64bit-static/ffmpeg -i ./testvideos/300.HD.DVDRe.720p.x264.DDPlus.Sample-Hi_SiLURe.mkv -vf "select=gt(scene\,0.5),scale=iw*min(800/iw\,450/ih):ih*min(800/iw\,450/ih),pad=800:450:(800-iw)/2:(450-ih)/2" -frames:v 5 -vsync vfr ./preview%03d.jpg