converting videos for iPod video using ffmpeg

This should work with all platforms where ffmpeg is available, including Linux, Windows, Mac OS X and several BSD flavors.

After experimenting a bit, I finally got the right command lines working for ffmpeg which convert every video (at least every video that ffmpeg supports as input) to iPod video friendly format. Everything seems to work, including forward/backward seeking.

First of all, you need to compile xvid and support into ffmpeg. The corresponding arguments to ffmpeg's configure script are --enable-xvid and --enable-faac. You may need to compile and install faac and xvid first. You also need to specify --enable-gpl, since ffmpeg's configure script won't accept those options otherwise.

If you like to be able to encode videos into h264 format instead of MPEG4/xvid, you might also install x264 libraries and specify --enable-x264 to ffmpeg's configure.

Now that you have everything up and running, you may try to convert a video. For a 4:3 video, use:

ffmpeg -i foo.avi -f mov -b 1800 -maxrate 2500 \
-vcodec xvid -qmin 3 -qmax 5 -s 320x240 \
-acodec aac -ab 128 \

For some reason, I can't get my iPod to honor the aspect ratio settings and to squish a 16:9 video into letterbox format (or zoom into fullscreen, for that matter), although iTunes and Quicktime seem to have no problem doing so. To work this around, just tell ffmpeg to add the black bars on top and bottom itself and substract the height of the black bars from the actual video size:

ffmpeg -i foo.avi -f mov -b 1800 -maxrate 2500 \
-vcodec xvid -qmin 3 -qmax 5 \
-s 320x180 -padtop 30 -padbottom 30 \
-acodec aac -ab 128 \

It may be worth playing with bitrate and quality settings or also trying to use 2-pass-encoding, remember however that at least according to Apple's specification, the iPod with video only supports up to 2500kbps for MPEG4 and up to 768kbps for h264. Another thing that you might want to play with, especially if you plan on outputting your videos on a TV screen (using the optional A/V cable) instead of just on the iPod are the size and padding options.

If you know of any means to make the encoding process faster or to induce better quality, please drop me a comment. And now, enjoy your movies and clips on the go!

Update: If forward/backward skipping doesn't work, update your version of gtkpod.

1 comment:

Eliza said...

Thanks for your post. I’ve been thinking about writing a very comparable post over the last couple of weeks, I’ll probably keep it short and sweet and link to this instead if thats cool. Thanks. rohrb√ľndelw√§rmetauscher