How to Encode Videos for iPhone or iPod on any Unix using ffmpeg

Imagine what? I’m a big fan of the iPhone/iPod touch for mobile entertainment and since I’m also a big fan of the commandline, I of course want to use ffmpeg for video conversion. But… I’ve been looking for a working ffmpeg config for serveral months now. There were issues with Medibuntu’s version of ffmpeg for Ubuntu Hardy (or at least I had a lot of issues), there were issues with iTunes' crazy restrictions, there are dozens of (non) working ffmpeg configs on the web… so I just want to share my config with you. It works at least with Ubuntu Intrepid’s and Debian Lenny’s versions of ffmpeg and should work with MacPort’s version too. I’m pretty sure the BSD’s also have a working one. You will also need x264libs and lame.

So, here comes my cmd:

$ ffmpeg -i infile.avi -f mp4 -title -vcodec libx264
-level 21 -s 480x270 -r 24000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k
-g 250 -coder 0 -threads auto -acodec libfaac -ac 2 -ab 128k outfile.mp4
This will cost you about 270MB of space for a 45min show.

Have fun watching movies on your iPhone/iPod Touch on your way to work or home or whereever.