FFmpeg Cheat Sheet

A little FFmpeg 0.5 guide made by RodrigoPolo.com

IMPORTANT: This guide and commands are no longer mantained, some information about formats still relevant but encoding commands are not, please reffer to the official ffmpeg encoding guides, I have an unoficial cheat cheat about FFmpeg encoding here: https://github.com/rodrigopolo/cheatsheets/blob/master/ffmpeg.md.


This is a small personal cheat sheet for audio/video encoding where I put some of my most used stuff with FFmpeg 0.5 and other tools. I use H.264 and AAC on MP4, M4V or MKV container most of the time.

I also have a FFmpeg command generator tool here, If you have any question just contact me, if you want to help, give us a donation:

Content

Video Size and Aspect Ratios

iPhone 3 (480x320):
Name Size Aspect
Wide 16:9 480x270 16:9
Old TV 4:3 427x320 4:3
Wide 16:9 /16 480x272 16:9
Old TV 4:3 /16 432x320 4:3
iPhone 4 (960x640):
Name Size Aspect
Wide 16:9 960x540 16:9
Old TV 4:3 853x640 4:3
Wide 16:9 /16 960x544 16:9
Old TV 4:3 /16 848x640 4:3
iPhone 5 (1136x640):
Name Size Aspect
Wide 16:9 1136x639 16:9
Old TV 4:3 856x640 4:3
Wide 16:9 /16 1136x640 16:9
Old TV 4:3 /16 864x640 4:3
DV NTSC Video
Name Size Aspect
Wide 16:9 720x480 16:9
Old TV 4:3 720x480 4:3
Youtube and Vimeo Upload
Name Size Aspect
SD 4:3 640:480 4:3
HD 16:9 1280x720 16:9
Full HD 1920x1080 (1920x1072 base 16) 16:9
HD, Blu-Ray, AVCHD
Name Size Aspect
720p 1280x720 16:9
1080p/i Anamorphic 1440x1080 16:9
1080p/i 1920x1080 16:9

Frame Rates

Name Standard Fps FFmpeg
Movies NTSC 23.976 24000/1001
TV Video NTSC 29.97 30000/1001
Movies PAL 25 25
TV Video PAL 30 30

FFmpeg Encoding

X264Presets
default fastfirstpass lossless_ultrafast lossless_slower
baseline slowfirstpass lossless_fast lossless_max
normal hq lossless_medium ipod320
main max lossless_slow ipod640
High quality 2 Pass
ffmpeg -y -i INPUT -r 30000/1001 -b 2M -bt 4M -vcodec libx264 -pass 1 -vpre fastfirstpass -an output.mp4
ffmpeg -y -i INPUT -r 30000/1001 -b 2M -bt 4M -vcodec libx264 -pass 2 -vpre hq -acodec libfaac -ac 2 -ar 48000 -ab 192k output.mp4
iPod-iPhone 320 width
ffmpeg -i INPUT -s 320x240 -r 30000/1001 -b 200k -bt 240k -vcodec libx264 -vpre ipod320 -acodec libfaac -ac 2 -ar 48000 -ab 192k output.mp4
iPod-iPhone 640 width
ffmpeg -i INPUT -s 640x480 -r 30000/1001 -b 200k -bt 240k -vcodec libx264 -vpre ipod640 -acodec libfaac -ac 2 -ar 48000 -ab 192k output.mp4
Hight quality, 2 pass without presset
ffmpeg -y -i input -r 24000/1001 -b 6144k -bt 8192k -vcodec libx264 -pass 1 -flags +loop -me_method dia -g 250 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -bf 16 -b_strategy 1 -i_qfactor 0.71 -cmp +chroma -subq 1 -me_range 16 -coder 1 -sc_threshold 40 -flags2 -bpyramid-wpred-mixed_refs-dct8x8+fastpskip -keyint_min 25 -refs 1 -trellis 0 -directpred 1 -partitions -parti8x8-parti4x4-partp8x8-partp4x4-partb8x8-an output.mp4
ffmpeg -y -i input -r 24000/1001 -b 6144k -bt 8192k -vcodec libx264 -pass 2 -flags +loop -me_method umh -g 250 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -bf 16 -b_strategy 1 -i_qfactor 0.71 -cmp +chroma -subq 8 -me_range 16 -coder 1 -sc_threshold 40 -flags2 +bpyramid+wpred+mixed_refs+dct8x8+fastpskip -keyint_min 25 -refs 4 -trellis 1 -directpred 3 -partitions +parti8x8+parti4x4+partp8x8+partb8x8-acodec libfaac -ac 2 -ar 44100 -ab 128k output.mp4
iPod-iPhone 320 width, without presset
ffmpeg -i INPUT -s 320x240 -r 30000/1001 -b 200k -bt 240k -vcodec libx264 -coder 0 -bf 0 -flags2 -wpred-dct8x8 -level 13 -maxrate 768k -bufsize 3M-acodec libfaac -ac 2 -ar 48000 -ab 192k output.mp4
iPod-iPhone 640 width, without presset
ffmpeg -i INPUT -s 320x240 -r 30000/1001 -b 200k -bt 240k -vcodec libx264 coder 0 -bf 0 -refs 1 -flags2 -wpred-dct8x8 -level 30 -maxrate 10M -bufsize 10M-acodec libfaac -ac 2 -ar 48000 -ab 192k output.mp4
iPod-iPhone, 2 pass custom
ffmpeg -y -i input -r 30000/1001 -s 480x272 -aspect 480:272 -vcodec libx264 -b 512k -bt 1024k -maxrate 4M -flags +loop -cmp +chroma -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq "blurCplx^(1-qComp)" -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -coder 0 -refs 1 -bufsize 4M -level 21 -partitions parti4x4+partp8x8+partb8x8 -subq 5 -f mp4 -pass 1 -an -title "Title" output.mp4
ffmpeg -y -i input -r 30000/1001 -s 480x272 -aspect 480:272 -vcodec libx264 -b 512k -bt 1024k -maxrate 4M -flags +loop -cmp +chroma -me_range 16 -g 300 keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq "blurCplx^(1-qComp)" -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -coder 0 -refs 1 -bufsize 4M -level 21 -partitions parti4x4+partp8x8+partb8x8 -subq 5 -f mp4 -pass 2 -acodec libfaac -ac 2 -ar 44100 -ab 128k -title "Title" output.mp4 

DV Video

To DV
ffmpeg -i input -target ntsc-dv -aspect 4:3 -y output.dv
From DV To Microsoft AVI DV
ffmpeg -i input.dv -vcodec copy -vtag dvsd -acodec pcm_s16le -f avi -aspect 4:3 -y output.avi

Audio

AAC Stereo HQ
-acodec libfaac -ac 2 -ar 48000 -ab 192k
AAC Stereo SQ
-acodec libfaac -ac 2 -ar 44100 -ab 128k
AAC 5.1 HQ
-acodec libfaac -ac 6 -ar 48000 -ab 448k
AAC 5.1 LQ
-acodec libfaac -ac 6 -ar 44100 -ab 224k

Eac3To

AC3 5.1 Channel Mapping Fix
eac3to from_true_hd.ac3 fixed_mapping.ac3 -blu-ray -448
AAC to AC3
  1. From AAC to WAV with faad2:
    faad2 -o temp_audio.wav input.aac
  2. From WAV to AC3 with eac3to
    eac3to temp_audio.wav output.ac3 -448
AC3 to AAC
  1. From AC3 to a remapped AC3 with eac3to:
    eac3to input.ac3 temp_remaped.ac3 -448 -resampleTo48000 -2,1,0,3,4,5
  2. From remapped AC3 to AAC with FFmpeg
    ffmpeg -y -i temp_remaped.ac3 -vn -acodec libfaac -ac 6 -ar 48000 -ab 384k output.m4a

Other FFmpeg Options

-threads thread count, 0 means all threads available
-y overwrite output files
-ss time_off set the start time offset
-t duration record or transcode "duration" seconds of audio/video
-ildct Interlaced

FFmpeg Information Sources

IRC

Server: irc.freenode.net
Channel: #ffmpeg

Download

The bests binaries on the web, Easy installation without compiling, just runing an install file:
FFmpeg for Windows
FFmpeg for Macintosh OS X (Intel)
FFmpeg for Linux

You can also use this extremely easy guide to install FFmpeg on your Windows, GNU Linux or Macintosh machine:
http://rodrigopolo.com/about/wp-stream-video/ffmpeg-binary-installers-for-win-mac-and-linux

Win32 Binary Builds

http://ffmpeg.arrozcru.com/autobuilds
http://sourceforge.net/project/showfiles.php?group_id=205275&package_id=248632

FFmpeg x264 encoding guide by Robert Swain

http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide

H.264 Profiles and Levels
8x8dct high
cabac+bframes main
-level #

Special Thanks To:

 

Creative Commons License
FFmpeg Cheat Sheet by Rodrigo Polo is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.