Convert Videos to iPod / iPad / iPhone with FFmpeg under Ubuntu or Mac OS X

We’ll pretend you have ffmpeg up and running, with the necessary build options – for more info on that, refer to the FFmpeg Compilation Guide.

To convert to an iPod nano with a max screen size of 320×180, issue the following, replacing INPUT.AVI and OUTPUT.MP4 to your desired filename (but be sure to keep the output extension as .mp4!):

 

ffmpeg -i "INPUT.AVI" -c:a aac -cutoff 15000 -ab 128k -ar 44100 -ac 1 -strict -2 -async 1 -c:v libx264 -b:v 1024k -maxrate 2048k -bufsize 2048k -r 23.81 -s 320x180 -aspect 16:9 -pix_fmt yuv420p -movflags faststart -profile:v baseline -level 13 -partitions partb8x8+partp4x4+partp8x8+parti8x8 -b-pyramid 1 -weightb 0 -8x8dct 0 -fast-pskip 1 -trellis 1 -me_method hex -flags +loop -sws_flags fast_bilinear -direct-pred 1 -sc_threshold 40 -qmin 3 -qmax 51 -threads 4 -sn -y "OUTPUT.mp4"

 

If you’d rather not touch the size of the video, then issue the following (ideal for playing back on an iPad):

 

ffmpeg -i "INPUT.AVI" -c:a aac -cutoff 15000 -ab 128k -ar 44100 -ac 1 -strict -2 -async 1 -c:v libx264 -b:v 1024k -maxrate 2048k -bufsize 2048k -r 23.81 -pix_fmt yuv420p -movflags faststart -profile:v baseline -level 13 -partitions partb8x8+partp4x4+partp8x8+parti8x8 -b-pyramid 1 -weightb 0 -8x8dct 0 -fast-pskip 1 -trellis 1 -me_method hex -flags +loop -sws_flags fast_bilinear -direct-pred 1 -sc_threshold 40 -qmin 3 -qmax 51 -threads 4 -sn -y "OUTPUT.mp4"