Hari's Corner
Humour, comics, tech, law, software, reviews, essays, articles and HOWTOs intermingled with random philosophy now and thenRound 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
- Versatile. You can easily combine multiple files, choose different input and output formats and the command line is easy to understand and clearly laid out.
- Ability to read from DVD titles and chapters directly. With FFmpeg, you can only use VOB files which may or may not align with titles/chapters.
- Large number of audio/video formats supported thanks to the LAVC codecs.
Disadvantages of MEncoder
- Broken muxing for containers other than AVI. Resultant file works only in MPlayer properly.
- Some audio codecs might be problematic with MEncoder. Resultant file could be a mute, video-only file.
Advantages of FFmpeg/avconv (libav tools)
- Good integration with MP4 container format and supported codecs.
- Has AAC audio support.
- Generates error-free MP4 video files playable on a variety of media.
Disadvantages of FFmpeg/avconv (libav tools)
- Lacks ability to read directly from DVD titles/chapters, which makes it harder to rip, since VOB files may not be aligned to titles/chapters.
- Not as versatile as MEncoder in terms of input options, multiple files combining etc.
- Command line can be confusing compared to MEncoder.
A simple way to rip DVDs to MP4
- 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).
- 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:
- Not encoding the audio track properly. This happens on a few DVDs, resulting in a mute video stream.
- Problems with A/V sync. This also happens on some DVDs when the audio starts at a latter stage in the video and has no relation to the actual scene. Halfway through the video, the audio track ends, leaving the video mute.
I also found that HandBrake has some issues reading chapters on some DVDs. This prevents you from ripping the DVD.
Comments closed
The blog owner has closed further commenting on this entry.
No comments yet
There are no comments for this article yet.