Pages

Tuesday, July 26, 2011

Encoding MP4 Files for iPod on Ubuntu 10.04

    I used mencoder utility to convert my video files. But it was compiled without libfaac. So if you specify AAC encoding, an error occurs. Details and solutions can be found here. I just added the Medibuntu repository as described:
# sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list
# sudo apt-get --quiet update
# sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring
# sudo apt-get --quiet update
    NOTE: ffmpeg utility in Lucid release does not support *.rm/*.rmvb yet.
    Then install mencoder and codecs:
# sudo apt-get install mencoder libavcodec-extra-52 libavformat-extra-52
    Now you can convert videos. Here's a sample to convert a *.rmvb(848x480) to a *.mp4(320x240):
# mencoder -oac lavc -ovc lavc -lavcopts acodec=libfaac:abitrate=96:aglobal=1:vcodec=mpeg4:vbitrate=500:vglobal=1 -vf scale=320:180,harddup -vf-add expand=:240 -ofps 24000/1001 -of lavf source.rmvb -o target.mp4
    Modify fps/codec/bitrate values as you wish. The aglobal & vglobal options seem to be essential for iPod.
    In order to keep video aspect after scaling, the output file should be 360x204. we use the -vf-add filter to add black band to the top and bottom of it. Other command line options, please refer to its manpage.
    Lastly, install gtkpod to import your *.mp4 files.

0 COMMENTS: