Hari's Corner

Humour, comics, tech, law, software, reviews, essays, articles and HOWTOs intermingled with random philosophy now and then

Round up of video encoding on Linux

Filed under: Tutorials and HOWTOs by Hari
Posted on Thu, Oct 25, 2012 at 14:57 IST (last updated: Sat, Oct 27, 2012 @ 09:39 IST)

Over the years, I've used several tools for audio and video encoding on Linux and I've found a few home-truths regarding the tools used. In this article, I will share some of my thoughts on video encoding on Linux, highlighting the suitable tools/encoders used in the process. This won't however, be a comprehensive guide to video or audio encoding on Linux, for which you are referred to the manual pages of the appropriate codecs and tools.

Most Portable Video File Format

Most popular container for portable devices presently appears to be MP4. The best video format seems to be h264 and the best audio format seems to be AAC.

Best Tool to Rip DVDs

MEncoder hands down because it can read titles and chapters from DVDs directly and it supports a huge variety of output formats. Unfortunately its MP4 muxing is broken and so you should choose the AVI container format rather than LAVF. Note: If you are not comfortable with the command line, you can use my MEncoder GUI, BiaMovE.

You can always remux the audio and video tracks in FFmpeg as MP4. Remuxing (without re-encoding video/audio) is as simple as:

ffmpeg -i inputfile.avi -vcodec copy -acodec copy -f mp4 outputfile.m4v

MEncoder's AAC audio encoding might also be broken, in which case I use the following to make sure that the audio stream is AAC:

ffmpeg -i inputfile.avi -vcodec copy -acodec libfaac -f mp4 outputfile.m4v

Advantages of MEncoder

Disadvantages of MEncoder

Advantages of FFmpeg/avconv (libav tools)

Disadvantages of FFmpeg/avconv (libav tools)

A simple way to rip DVDs to MP4

  1. First rip the titles/chapters using MEncoder in AVI container with h264 video and copy the audio stream without encoding (AAC might not work or be broken depending on your version of MEncoder).
  2. Remux to MP4 container using FFmpeg while converting audio to AAC at the same time.

Example: supposing you want to rip Title 1 (all chapters) from a DVD using MEncoder:

mencoder dvd://1 -of avi -oac copy -ovc x264 -x264encopts crf=22:subq=5:frameref=1 -o videofile.avi

Then you can re-mux while encoding the audio track in FFmpeg as follows

ffmpeg -i videofile.avi -f mp4 -ovc copy -oac libfaac videofile.mp4

This will result in an MP4 file with h264 video and AAC audio that is so popular among video playing devices.

Another option to rip DVDs

HandBrake is a cool GUI for video transcoding. It's crossplatform and free software too. With HandBrake you can directly rip DVDs to MP4 files without the above command line tools.

However, I found a few issues with some DVDs with HandBrake like:

I also found that HandBrake has some issues reading chapters on some DVDs. This prevents you from ripping the DVD.

No comments yet

There are no comments for this article yet.

Comments closed

The blog owner has closed further commenting on this entry.