DVDripTools

Hi, this short tutorial aims to be a guide for those who would like to back up a DVD using Linux. If you like nice and clear GUIs I suggest you to use the excellent Handbrake, but if you are interested in understanding what really happens when ripping a DVD and have complete control over the operation you will find this guide quite useful.

At first I will start with a general overview to clarify the situation about DVDs, then I'll switch to a description of the script I made, along with its usage. Remember that this does not pretend to be an exhaustive study about DVD encoding, it is a simple introduction to this beautiful World, for further information I suggest you to follow these links:

DVD ripping and transcoding with Linux. This is a very specific tutorial about the DVD ripping and transcoding, using MPlayer and Transcode. It is well organized and it contains specific information about the codecs, the aspect ratio, the audio and other specifics. Recommended.

Mplayer HOWTO. The original MPlayer HOWTO. They are a huge and precious source of information of any kind about the video playing/encoding. Plus, the supported OS are Linux, Windows, Mac OS X, FreeBSD... you got it. A must for any serious user, everybody should take a careful look at it.

Some information about the codecs.

In this section I will explain the choice of the video codecs I used to make the script, and the reason upon which I made this decision.

Codecs and Containers

Video codec My choice is MPEG4, which in MPlayer is the ISO standard MPEG-4 (DivX 5, XVID compatible).You can also use x264 of ff264, open implementations of Apple's h264. Although I think the title explains itself, I will spend a few words about it. It is crucial to have an open standard, so that anybody, anywhere, will be able to play the video, no matter the OS used (*UNIX, Linux, Windows, Mac OS X) or the architecture upon which the OS is working (x86, SPARC, PPC, ALPHA), therefore we should use the so called "open standards".

Audio codec Vorbis, using the OGG container. Same reason as above, plus some extra special motivations. OGG Vorbis is a completely open, patent-free, professional audio encoding and streaming technology with all the benefits of Open Source. Listening tests [1] (http://www.rjamorim.com/test/) have attempted to find the best quality lossy audio codecs at certain bitrates. The tests show that: at 128 kbit/s, Ogg Vorbis and MPC performed marginally better than other codecs. Based on this, Vorbis can be considered a high quality codec. For most applications Vorbis is a good codec to use, but would only be considered superior to other modern codecs because it is patent free.

Container The Choice was between OGM (Ogg Media) and MKV (Matroska). Without any doubt, I would not have chosen avi, which is probably the worst container for audio and video that ever existed in this planet. I will quote the official matroska home page to make you understand what it is capable of:

Matroska aims to become THE standard of multimedia container formats. It was derived from a project called MCF, but differentiates from it significantly because it is based on EBML (Extensible Binary Meta Language), a binary derivative of XML. EBML enables the Matroska Development Team to gain significant advantages in terms of future format extensibility, without breaking file support in old parsers.

First, it is essential to clarify exactly "What an Audio/Video container is", in order to avoid any misunderstandings. Matroska:

It is NOT a video or audio compression format (video codec)

It is an envelope for which there can be many audio, video and subtitles streams, allowing the user to store a complete movie or CD in a single file.

Matroska is designed with the future in mind. It incorporates features you would expect from a modern container format, like:

Fast seeking in the file

High error recovery

Chapter entries

Selectable subtitle streams

Selectable audio streams

Modularly Extendable

Streamable over internet (HTTP and RTP audio & video streams)

Menus (like DVDs have)

Matroska is an open standards project. This means for personal use it is absolutely free to use and that the technical specifications describing the bitstream are open to everybody, even to companies that would like to support it in their products. The source code of the libraries developed by the Matroska Development Team is licensed under GNU L-GPL.

Let's get started: Encoding!

Now that we have a general overview of what is the difference between a video codec and a container, we are acknowledged about the codecs that we are going to use and the reason of this choice, we can start with the very essence of this tutorial, the encoding.

My decision to use the omnipotent MPlayer and MEncoder was very easy. At first, it is an open standard. Secondly, it works really fast, it has an enormous number of parameters for the playing/encoding of almost any media that exists; and thirdly it has a very big and open community willing to help those who are in need, plus the documentation is exahustive and clear. Some info about the Mplayer project can be found here:
:: Mplayer Home Page.

Let us now make the situation clear. We are about to do the following tasks in chronological order:

Ripping the audio

Ripping the video - First pass

Ripping the video - Second pass

Merge the audio and the video into a single MKV file

Audio encoding

It looks pretty simple, though. The first operation can be done in two different ways. The first one if to create a FIFOTEMP, this will make the whole process a bit longer, but you won't need to have +1GB space just for an audio that you would have to dump anyways. Furthermore, the audio encoding through a FIFOTEMP works pretty fast in my PowerBook G4 1.33GHz, so I think it won't be a problem for a modern computer (which is really required for good DVD ripping). The commands that you'll have to use are the following:

These commands will create a FIFOTEMP (First-In-First-Out Temporary), encode in vorbis the audio that mplayer will produce dumping the video; finally remove the FIFOTEMP when all it's done. The second way to achieve the same result will be this:

This will eventually takes even longer, since it has to encode all the audio before, and then run the oggenc. The single operation will be faster than the FIFOTEMP, also the computer will no be overloaded; but the overall result may not as good as you wanted to. In the script I put as default the FIFOTEMP, and I commented with # the other solution, just switch and uncomment if you wish to use the other one.

Video Encoding

At this point we should have an audio file called audio.ogg that contains all the DVD audio track in a 128kBit/sec vorbis. The encoding will be done using mencoder, but first we should specify the option we wish to use.