Convert video to iPod format

August 7, 2008 8:21 pm GMT-0700 | In Tech

Basic command:

ffmpeg -i input.avi -f mp4 -vcodec mpeg4 -b 1000kb \
-acodec aac -ab 192kb [-ac 2] output.mp4

-ac 2” may not work if the input file is in mkv format with 5.1 aac audio (if you don’t convert 5.1 to 2.0, playing the file crashes your iPod/iPhone). Here’s a possible way to convert:

  • Extract aac audio from the mkv file:
    ffmpeg -i input.mkv -vn -acodec copy audio.aac
  • Downmix 5.1 to 2.0:
    faad -d audio.aac -o audio-2ch.wav
  • Merge and convert to iPod format:
    ffmpeg -i input.mkv -i audio-2ch.wav -map 0.0:0 -map 1.0:1 -f mp4 \
    -vcodec mpeg4 -s 470x320 -b 1000kb -acodec aac -ab 192kb output.mp4
  • The output of the last command gives a little more info of what I am doing here:
    Input #0, matroska, from 'input.mkv':
    Duration: 01:24:42.5, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: h264, yuv420p, 704x480, 24.39 fps(r)
    Stream #0.1: Audio: aac, 48000 Hz, 5:1
    Input #1, wav, from 'audio-2ch.wav':
    Duration: 01:24:42.5, start: 0.000000, bitrate: 1536 kb/s
    Stream #1.0: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s
    Output #0, mp4, to 'output.mp4':
    Stream #0.0: Video: mpeg4, yuv420p, 470x320, q=2-31, 1000 kb/s, 24.39 fps(c)
    Stream #0.1: Audio: aac, 48000 Hz, stereo, 192 kb/s
    Stream mapping:
    Stream #0.0 -> #0.0
    Stream #1.0 -> #0.1

Video conversion can certainly be way fancier than what I am doing here, and faad is obviously not the best way to downmix audio from 5.1 to 2.0. You can also find quite a few iPod converters but personally I like command line. Anyway, happy converting! (ffmpeg ref)

[Also note that on MacOS, you may have to change “-acodec aac” to “-acodec libfaac“.]

Tags: , , , , , ,

1 Comment »

RSS feed for comments on this post.

  1. you may have interest on our video converting service:

    It’s in beta testing now, we have released api and ruby/rails libs. is build on this tech.

    Comment by Jan — September 8, 2008 2:51 am GMT-0700 #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This weblog is licensed under a Creative Commons License.
Powered by WordPress. Theme based on Pool by Borja Fernandez.