Wednesday, October 03, 2007

Convert to iPod Nano video with ffmpeg

Just got my iPod Nano with video and the first thing I noticed was that it only supported one video format and that iTunes didnt even want to convert to this format for certain video files.

The next thing I noticed, when I finally managed to get iTunes 7.4.3 to accept a video (it refuses .avi files, accepts .mpg files), it converted a 22 minute MPEG-1 video in about 50 minutes time on my Core 2 Duo E6600). Even then, the resulting file lacked the audio track and was useless.

So after some poking, here's a pretty good ffmpeg syntax to produce nice iPod videos with acceptable sound, should work with all input types supported by your ffmpeg build:

ffmpeg -i infile.avi -f mp4 \
-acodec libfaac -ar 44100 -ab 128 \
-vcodec mpeg4 -maxrate 2000 -b 1500 \
-qmin 3 -qmax 5 -bufsize 4096 -g 300 \
-s 320x240 -r 30000/1001 outfile.mp4



It took 3 min 14 seconds for ffmpeg to encode the file I used.
From my sample input file of 22 minutes good quality video, the output file was 42 MB.
(Thats about 95 Simpsons episodes on a 4GB iPod Nano :-)

Note: Some versions of ffmpeg calls the audio codec "aac" instead of "libfaac".

For Windows, I used ffmpeg-r10461-gpl-static-win32.tar.bz2 from http://arrozcru.no-ip.org/ffmpeg_builds/

Oh, iTunes ALSO refuses to accept files named something.avi.m4v
You must remove the ".avi" part of the filename.