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 "