By: Federico Pistono
20 Feb 2007
svn co https://dvdriptools.svn.sourceforge.net/svnroot/dvdriptools dvdriptoolsHi, 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:
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.
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:
Matroska is designed with the future in mind. It incorporates features you would expect from a modern container format, like:
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.
In the end I just found Matroska more performing than OGM, which has similar functionalities. For further information about this topic, I redirect you to these links:
:: Official matroska Home Page
:: Wikipedia Definition
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:
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:
mknod fifotemp p& oggenc -Q -q 3 -o audio.ogg fifotemp mplayer -dvd-device $DEVICE dvd://$TITLE -aid 128 -vc dummy \ -vo null -hardframedrop -ao pcm:fast:file=fifotemp& rm fifotemp&
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:
mplayer -dvd-device $1 dvd://$2 -aid 128 -vc null -vo null\ -hardframedrop -ao pcm:file=audio.wav& oggenc -q 3 -o audio.ogg audio.wav&
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.
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.
NAME=Avalon BITRATE=1100 OPT=vcodec=mpeg4:psnr:mv0:cbp:trell=yes:mbd=2:keyint=125\ :naq:v4mv:vlelim=-4:vcelim=7:lumi_mask=0.05:dark_mask\ =0.01:tcplx_mask=0.01:scplx_mask=0.01:vratetol=32000:\ vbitrate=$BITRATE
This local variable OPT contains the options for the 2-pass encoding process. For specifics about all the options used about luminosity, FPS, scaling, etc... see the Mencoder manual.
it is now time to pass to the real encoding process, use the following commands:
mencoder -dvd-device $DEVICE dvd://$TITLE -aid 128 -vf \ crop=$CROP -ovc lavc -lavcopts $OPT:vpass=1:turbo \ -nosound -o /dev/null & mencoder -dvd-device $DEVICE dvd://$TITLE -aid 128 -vf \ crop=$CROP -ovc lavc -lavcopts $OPT:vpass=2 -nosound \ -o output.avi &
The result will be saved in a file named output.avi, containing the original AC3 audio, and the video, encoded with the bitrate previously specified.
A very simple command is needed:
mkvmerge --title $NAME -o $NAME.mkv -A output.avi \ --language 0:eng audio.ogg
The vorbis audio will be merged together with the video, the old AC3 will be replaced, and as a result we'll have the MKV desired.
I assembled all these command into a bash script that will do the job for you. The tar.bz2 contains three file:
It is quite simple, I will report the README file as it follows:
- dvd-device = your dvd-device. Either a on-the-fly copy (/dev/dvd) or a local directory, created before with vobcopy - dvd title = the title of the dvd using mencoder (e.g mencoder dvd://1, also multiple titles, like 2-6 = from 2 to 6) - bitrate = the bitrate to use for the ffmpeg compression (DivX, Xvid) (best > 900, 1100 is fair enough.) - crop = That if you wish to crop the black bars. - If no argument is provided the script will perform a standard rip in /dev/dvd at 1100Kb/sec, English language with output file named dvdout.mkv Common options: -h, --help - display this help text -dep - only install dependencies (requires sudo/root) -crop - crop detect -c - custom, start a step-by-step guided rip [EASIER] Examples: [bash]$: ripdvd [bash]$: ripdvd -c Output: -rw------- 1 phate phate 700M May 5 04:09 dvdout.mkv -rw------- 1 phate phate 700M May 5 06:12 Avalon.mkv
SourceForge :: Project Home page.
FreshMeat :: Project Home page.
In order to install the script see the README, or open a terminal and copy paste the following code, line by line:
unzip dvdriptools-0.6.1.zip cd dvdriptools && sudo ./installit
Enjoy the script.
For further information, suggestions, bug fix, send me an email.
3 Responses to DVD ripping with Linux/*BSD/OS X
biznes (not verified)
Thursday, March 5, 2009 - 15:44 reply quote
Thanks a lot for the script! :)
Federico Pistono
Saturday, March 7, 2009 - 17:29 reply quote
My pleasure. ^_^
boediger (not verified)
Saturday, April 18, 2009 - 12:16 reply quote
Thanks a lot for the script! :)
boediger
Post new comment