Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to convert a large number of video files in various formats into .mp4 files (container MPEG-4, codec H.264). I want to do this on an Ubuntu machine, using only command-line tools and I'm willing to install packages from main, restricted, universe and multiverse.

Ideally I'd like to be able to do ...

for VIDEO_FILE in *; do
  some_conversion_program $VIDEO_FILE $VIDEO_FILE.mp4
done

... and have all my video files in .mp4 format with container MPEG-4 and codec H.264.

How would you tackle this problem on an Ubuntu machine? What packages do I need to install?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

You will need to install these :

sudo apt-get install ffmpeg libavcodec-unstripped-52 libavdevice-unstripped-52 libavformat-unstripped-52 libavutil-unstripped-50 libpostproc-unstripped-51 libswsclale-unstripped-0 x264

In Karmic, Lucid and Maverick you should replace "unstripped" by "extra" but since there is transitional packages this work too.

And then you can use a script with :

for i in *.avi; do ffmpeg -i "$i" -f mp4 "`basename "$i" .avi`.mp4";done

And you can use options like these to set up resolution, video codec and audio codec and audio quality :

for i in *.avi; do ffmpeg -i "$i" -s 352x288 -vcodec libx264 -vpre default -acodec libmp3lame -ab 192k -ac 2 -ar 44100 -f mp4 "`basename "$i" .avi`.mp4";done
share|improve this answer

A long howto for Ubuntu 10.10 can be found here. But it looks a little bit complicated http://ubuntuforums.org/showthread.php?t=786095

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.