WARNING! This guide is not for the faint hearted. It involes a lot
of compiling code, installing software, doing things on the command line.
If you don't know how to do
configure; make; make install then
read some other docs and learn about it. If you don't want to then please
install Windows and use all those formidable DVD ripping utilities available
for it. I won't start a flame war about "Linux vs Windows". It's simply a
fact that the process is rather difficult under Linux.
You're still with me? Great! You're about to embark on a journey to a beautiful land...
Back to the table of contents
.IFOfiles. libdvdread is often used to parse these files and extract the informations that are needed.
Here's a list of supported video codecs:
divx.dlland some others) and requires avifile.
libdivxencore.so. This is closed source. For Windows there are different versions available and only the commercial version supports all encoding options like b-frames*, GMC* or quarter PEL*. The free version can still be used to view all files created with even the commercial version. Unfortunately there's only the free version for Linux which doesn't support all those nice options. DivXNetworks are thinking about providing a commercial solution for Linux aswell. But don't expect that codec to be available soon.
DivXread backwards) is an Open Source MPEG4 implementation that is really good considering compression and picture quality. Support for advanced MPEG4 features (b-frames*, GMC*) is being worked on or has already been implemented.
Again a list, this time for audio codecs:
Note: Before downloading software check if your distribution already contains that software. I use Debian Woody (testing) and have found that a lot of software is already available prepackaged.
libdvdcss-0.0.3.ogle3.tar.gz(note that version numbers may differ as software is always under development). Un-tar-gz it, compile it, and install it in
apt-get install libdvdread2 libdvdread2-devshould do the trick.
cvs -z3 -d:pserver:firstname.lastname@example.org:/xvid loginWhen asked for a password simply hit enter.
cvs -z3 -d:pserver:email@example.com:/xvid co xvidcore
make -f Makefile.linux
/usr/local/include/encore2.h. Be sure to make a backup of the files you will overwrite!
If you want to encode using MEncoder I suggest you also get a version of libavcode for encoding. You only need to download it if you are using a CVS version of MPlayer. Releases come pre-packaged with libavcodec. These instructions are taken from the MPlayer documentation:
cvs -d:pserver:firstname.lastname@example.org:/cvsroot/ffmpeg login. Just hit enter when you're prompted for a login or password.
cvs -d:pserver:email@example.com:/cvsroot/ffmpeg co ffmpeg
A note on compiling: Be sure not to include XviD support. Instead include support for libavcodec. Installation instructions are provided in the MPlayer docs. Yes, you've read correctly: compile transcode with XviD and MPlayer without XviD but with libavcodec. The reason is that MPlayer can't contain support for both codecs at the same time as both use variables that have the same name.
Additionally you really want to download dvd::rip, an excellent Gtk+ based frontend for transcode. Get it from here. Installation instructions are included.
Back to the table of contents
Before you do anything else think about the region code. All drives shipped today have RPC mode 2 protection - that means that you can only switch your region code five times before it is locked. You can get information about how to remove the region code from your drive over at Digital Digest. So why am I mentioning this? The ripping methods mentioned below rely on the drive to have the correct region code (read: the same as the DVD that's inserted) or no region code at all. All error messages are kind of cryptic and it's often not very clear that you have a region code related problem when ripping fails. So keep that in mind.
First test the DVD. Fire up MPlayer and watch the first title:
mplayer -dvd 1. Do you like it? Cool. Make sure you
remember whether the video is interlaced or not (see below). Close
Now that you have an idea what interlacing looks like you should be able to decide for yourself whether your DVD contains interlaced material or not.
For the rest of this guide I'm assuming the following:
/dvd. There is an entry in
There are a lot of ways to rip the VOBs. I'll present two: using a command line tool (vobcopy) and using the transcode GUI dvd::rip. You don't have to do both :-)
-o /space). They will be named after the DVD's title (e.g. I have
ALLY_MCBEAL_DISC21-2.vobetc.). It will take some time. Just be patient.
Note from the author (Robos): vobcopy has some problems following angles. You might get duplicate scenes with e.g. "The Matrix". I'm working on it.
dvdrip. You'll see the main window. Chose
Edit / Preferencesand dvd::rip will come up with the preferences dialog. Here you'll have to enter your paths. The first is the path to the DVD device and not the mount point. Often it is
/dev/dvdwhich is a symlink to the real device, e.g.
Close that dialog. Now start a new project (
File / New Project).
It will start with the storage tab. Again enter the correct paths. Note how the
other name fields change when you change the project title.
Change over to the Rip
Title tab and press the
Read DVD Table of Contents button.
After a second or two the list below will be populated with the titles that are
stored on the DVD. Just select the title you want to rip (you can select
multiple titles by holding
CTRL and clicking on them). Chose the
languange and the angle. Leave
Specify Chapter Mode on
No. Last step: press
Title(s)/Chapter(s). Again be patient. Drink some milk. Have a nice chat
with your girlfriend.
The rest of dvd::rip will be covered later in chapter 4.
Back to the table of contents
Here is a list of common scenarios:
After starting dvd::rip you rip the titles you wish to transcode to your hard disk. Refer to chapter 3 for a detailed description.
Grab Preview Frameinput line and press
Grab Frame from ripped VOB. After a few seconds the three views below show the frame you requested.
transcode uses three steps to bring the picture to its final size: first it clips the unscaled image, then it does resizing and last it clips again. Each of this steps can be left out by selecting 0 for clipping and the original width and height for resizing. Each window shows the result of those three steps. If you want to see how big the pictures really are then just click onto any of them and a pop-up window will be opened containing the result.
You may have noticed the drop-down listbox below the three preview windows.
dvd::rip offers a wide rage of presets for you to work with. Simply
select one of those gives you a place to start. You can still change the
values manually after selecting such a preset. All presets that are named
"autoadjust..." try to guess the correct clipping regions. After selecting
a preset hit the
Apply Preset Values button. Now adjust the
values you got until you're happy.
medium frame and
frame parts refer to the final image size that is to be achieved.
big keeps almost full DVD resolution,
somewhere between 500 to 600 for the width and
small is somewhere
Use fast resizinghas a big impact upon image processing but requires that the target width and height are dividable by 32. Don't worry, dvd::rip will tell you if you can't use fast resizing. Note also that while it is possible to actually enlarge the picture I strongly advise against it. There are several drawbacks: the encoder needs a lot more bits to achieve the same quality you'd get when encoding a smaller picture and then scaling it up while playing it back, and you might even get distorted pictures (Peter Schuller reported such a case to me). Always scale down.
xvidcvs(obviously). If transcode later aborts with some obscure error then you can try
Do you remember that I asked you to check if the video was interlaced? Now we
need it. If your video is not interlaced then simply leave
deinterlacing to and
antialias off. Otherwise
3 - Zoom To Full Frame. This is the slowest but best
looking deinterlacer. Again here's the interlaced sample from Ally McBeal. You can see
the result from
3 - Zoom To Full Frame in the
Another filter for deinterlacing is provided by an external plugin (don't
worry you've already installed it with transcode itself).
Have a look at the lower right. There's a input box labeled
transcode options. All options entered here are simply passed
along to transcode. We can use this for deinterlacing. Here's the same
picture as above
deinterlaced with other deinterlacer. This deinterlacer
is faster than the
3 - Zoom To Full Frame option. If you want
to use this deinterlacer then set
-J dilyuvmmx in the input line.
dvd::rip tries to autodetect your framerate. If it failed you can
correct it here.
Use YUV internal should always be
yes unless the output codec does not support YUV modes.
XviD does. Leaving it on gives a huge speed boost.
multipass should be
yes aswell unless you only want
to do a preview. For final results always chose two pass encoding. Although
this is labeled
DivX multipass it works nicely with XviD
The audio options should be self explanatory. You chose either to reencode
the audio to MP3 using the specified bitrate or to use the original AC3
sound without reencoding. AC3 audio provides surround sound and all those
advantages but is bigger than MP3 sound. It's really your choice. If you
use MP3 then make sure that the
MP3 Quality setting is at
2. According to lame's documentation (lame
is used for MP3 compression) higher quality settings like
0 - best but slower are at lot slower but do not produce
significantly higher quality. The
volume rescale allows
normalization the audio which does not require a separate (external) program.
In the upper right is the bitrate option. You can easily chose the rip size
by selecting the count and size of CDs you want to use. Manipulating
Target Size or the
Video Bitrate works aswell.
Frame Range. I usually take a 30 second sample which would be 750 frames at 25fps (<number of seconds> * <fps> = <number of frames to encode>) and start sometime into the movie (like 200, 300 frames). Good values might be
200 - 950. You should also give transcode a high nice level (which results in a low process priority) so it will only use spare time. If you really want your preview right here right now you can also temporarily disable
DivX Multipass. Just remember to turn it back on later!
When you're done click
Transcode. After a couple of minutes
at most your AVI/MPEG will be ready. Now have a look at it (like
mplayer my-new-file.avi). This is a good moment to see if
deinterlacing works as expected and to check if audio and video are in
synch. If they are, you're set. If they aren't, then read on:
-D nrin the
transcode optionsinput line on the
nris the number of frames the audio is delayed. This number can be negative. A frame is 40msecs long at 25fps. In general the frame length is (1000 / fps)msecs long. For my Ally McBeal DVD I need a correction of -2 which amounts to -80msecs:
-D -2. Now regenerate your preview video (the other parameters should still be the same) and check the audio again. If needed redo this step until you're satisfied.
DivX Multipassis turned on again if you disabled it for the preview. Either click on
Transcode + Splitif you want your files to be split automatically according to the settings under
Video Bitrate Calculation.
Now is really a fine time for some socialising :-)
In dvd::rip press
CTRL-t to see what the commands
dvd::rip executes look like. For now let's concentrate on the last
set of commands,
Transcode command. Here's an example for my
Star Trek: The Next Generation DVD without all those
transcode -i /space/tng-biggoodbye/vob/004 -w 4357,250,100 -a 1 -b 128,0,0 -s 3.311 -V -f 25 -B 12,10,8 -R 1 -x vob,null -o /dev/null -y xvidcvs,null
transcode -i /space/tng-biggoodbye/vob/004 -w 4357,250,100 -a 1 -b 128,0,0 -s 3.311 -V -f 25 -B 12,10,8 -R 2 -x vob -o /space/tng-biggoodbye/avi/004/tng-biggoodbye-004.avi -y xvidcvs
-i /space/tng-biggoodbye/vob/004obviously tells transcode where to find the files. It can be a file, a device or a directory containing the files.
-w 4357,250,100sets the video encoding parameters: bit rate, maximum key frame interval and crispness.
-a 1selects audio track number 1 (starting with 0).
-b 128,0,0sets the audio encoding parameters for lame: bit rate, vbr and quality. Have a look at lame's man page for an explanation of the parameters
-s 3.311causes lame to scale the audio and thus normalizing it on the fly.
-Vcauses transcode to do image processing in the YUV color space. Without
-Vimages would be converted to the RGB color space. Note that some external filters only work with either color space. YUV processing gives a huge speed boost.
-f 25sets the frame rate.
-B 12,10,8sets the fast scaling options: the picture will be scaled down to
height - 12 * 8rows and to
width - 10 * 8columns.
-R 1is the marker for the first (of two) encoding pass.
-x vob,null- the video input comes from VOB files and the audio input will be skipped (it isn't needed for the first pass anyway).
-o /dev/null- We don't need the video either, so just discard it.
-y xvidcvs,null- Output video using XviD and discard audio.
-y xvidcvs). For a more complete reference have a look at transcode's and lame's man pages.
As a last note you will find that transcode as of version
0.6.0pre6-20020529 contains support for libavcodec via a still
experimental export module writte by me. You can activate it by using
ffmpeg4 (remember: libavcodec is part of ffmpeg)
instead of your previous codec. dvd::rip does not support it at the
moment (read: it is not in the list of selectable codecs).
enfor Englisch or
defor German). You can find out about these codes by running MPlayer in verbose mode:
mplayer -dvd 1 -v. It should print a lot of lines. Search these for lines similar to:
[open] audio stream: 0 audio format: ac3 language: en aid: 128
[open] audio stream: 1 audio format: ac3 language: de aid: 129
[open] audio stream: 2 audio format: ac3 language: es aid: 130
Now call MEncoder to encode the audio for you:
nice -+19 cat /space/*vob | nice-+19 mencoder -ovc frameno
-o frameno.avi -oac mp3lame -lameopts abr:br=128 -alang de -
Here's an explanation for the command line arguments used:
nice -+19- Gives MEncoder the lowest process priority so it won't disrupt your normal work.
-ovc frameno- Output Video Codec is
framenowhich means that no video data is actually written or processed at all.
-o frameno.avi- Write the output to the file called
frameno.avi. The audio must be written to a file with that name as MEncoder wil read the audio from exactly this file with the exact name in the next step.
-oac mp3lame- Output Audio Codec is the lame encoder library.
-lameopts abr:br=128- options for
Recommended video bitrate for 650MB CD: 1845
Recommended video bitrate for 700MB CD: 1992
Recommended video bitrate for 800MB CD: 2287
Let's assemble the command line options one by one:
-nosound- We don't need sound in the first pass, so let's just disable it.
-o /dev/null- The output of the first pass isn't needed either, so just dump it.
-ovc lavc- chose lavc as the Output Video Codec.
-lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vqmin=1:vqmax=31:vpass=1- libavcodec actually supports a handful of different video codecs. With
vcodec=mpeg4we chose the MPEG4 compliant encoder.
vbitrate=1000is the desired bitrate.
vhq(very high quality) tells the encoder to spend a lot of time optimizing the results. It is worth it.
vpass=1finally tells the encoder that this is the first pass only. Using
vqmaxtells the codec how much it may compress the video at least and at most. Keeping these at their defaults (see
man mencoder) restricts the achievable output bitrate a lot so I advice chosing a broader range. Note that I'm no expert on quantizers. If I'm wrong here please
-vop scale=640:480- scale the picture down to 640 by 480 pixels. I've read on the mailing list that a new switch has been added that automatically calculates the height from the width or the other way round so that the aspect ratio will be kept. I haven't tried it myself but it should look like this:
-vop scale -xy 640. Note that while it is possible to actually enlarge the picture I strongly advise against it. There are several drawbacks: the encoder needs a lot more bits to achieve the same quality you'd get when encoding a smaller picture and then scaling it up while playing it back, and you might even get distorted pictures (Peter Schuller reported such a case to me). Always scale down.
-ss 0:20specifies 20seconds into the movie as our beginning, and
-endpos 0:30says that we want 30seconds to be processed. This parameter is named badly as it's not the end position but the duration that it specifies.
nice -+19 mencoder -nosound -o /dev/null -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=1 -vop scale=640:480 -npp lb -ss 0:20 -endpos 0:30 /space/first.vob
vpass=2to tell the encoder that it's the second pass this time. Additionally we leave out the
-nosoundand replace it with
-oac copywhich simply copies the audio from the
frameno.avifile we created in step one. Of course we should save the final output and replace
-o /dev/nullwith something usefule, e.g.
Here's the command line:
nice -+19 mencoder -oac copy -o ally-preview.avi -ovc lavc -lavcopts
vcodec=mpeg4:vbitrate=1000:vhq:vpass=2 -vop scale=640:480 -npp lb
-ss 0:20 -endpos 0:30 /space/first.vob
After MEncoder finishes take a look at your preview. Adjust parameters if needed. Redo the preview until you're happy with it.
-endpos. Unfortunately MEncoder can't handle multiple input files on the command line. That's what the
catis for. Just enter:
cat /space/*vob | nice -+19 mencoder -nosound -o /dev/null -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=1:vqmin=1:vqmax=31 -vop scale=640:480 -npp lb -
cat /space/*vob | nice -+19 mencoder -oac copy -o ally.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=2:vqmin=1:vqmax=31 -vop scale=640:480 -npp lb -
-ssdoes not seem to work with the
cat *vob | mencoder...variant. So for the preview just specify the first vob as the last argument on the command line (just look up).
Now go get a beer and a nice book.
Back to the table of contents
avisyncwhich is part of the transcode package.
avisync is easy to use: just provide an input file
-i name.avi), an output file (
and the synch offset in frames (
-n count). From
count>0: audio starts with frame 'count'.
count>0: prepend 'count' padding audio frames. An example:
avisync -i ally-not-synched.avi -o ally-synched.avi -n -2
avisplitwhich is part of the transcode package. Use it only with AVIs generated by transcode.
avisplit is easy to use: just provide an input file
-i name.avi) and when it should split. You can split after
a fixed size (
-s size_in_megs), after a number of frames
-f f1-f2) or after a number of seconds (
avisplit -i ally-big-file.avi -o ally -s 700
This will produce files named
ally-0000.avi, ally-0001.avi etc.
that are each 100megs big at most.
-vo nulloptions tells MPlayer not to show the video.
mplayer -vo null -nogui -alang de -dumpaudio -dumpfile lang-de.ac3 *vob
mplayer -vo null -nogui -aid 128 -ao pcm -aofile lang-de.wav *vob
mplayer -vo null -nogui -dumpaudio -dumpfile audio.mp2 myvideo.mpg
mplayer -vo null -nogui -ao pcm -aofile audio.wav myvideo.avi
-dumpaudio -dumpfile newaudio.extensionif you want to extract the audio without processing and
-ao pcm -aofile newaudio.wavif you want the WAV itself.
mplayer -audiofile anotherlang.mp3 myvideo.aviplays video from
myvideo.aviand audio from
anotherlang.mp3. A lot of Windows media players support external audio files, too. This way you can provide sevaral language versions as separate audio files. A combination often used is to have the AVI include the English audio track and to provide additional audio tracks in separate files.
Back to the table of contents
man transcodeshow these pages. Additionally providing
--helpas the only parameter to one of these programs will give you a listing of command line options (which might not be complete).
Back to the table of contents
With CBR the encoder spends the same amount of bits on each frame, regardless of how much it would really need. This has the disadvantage that for example complete black pictures or complete silence in an audio frame would waste a lot of bits while pictures or audio frames with a lot of elements would benefit from these bits.
VBR now takes as much bits as it needs. So black pictures get very few bits and complex pictures get as much as they need. While this provides the best quality the final size can't be predicted at all.
This is were ABR kicks in. You specify an average bit rate you want to achieve and the encoder distributes the bits it has available. Those bits it saves on black pictures it spends on complex pictures. It is a compromise between quality and size predictability.
This is a quick explaination of an MPEG "GOP", or, "Group Of Pictures".
The situation for B frames is like this: "I don't know that block" (INTRA mode), "I know that block from the preceding I or P frame (backward mode)", "this block looks like the block in the following frame (forward mode)" or "this block looks like a mixture of the blocks from the preceding and the following frames (bidirectional mode)".
MPEG1 GOPs are always "IBBPBBPBBPBB" (this is the order in which the frames are displayed, not necessarily the order in which they were encoded/saved). MPEG2 GOPs look like that aswell. They may aswell contain three B frames. The DivX5 MPEG4 codec only uses "IBPBPBPBPB" because it's easier to implement and because B frame support for MPEG4 codecs is rather new. You may expect to see more B frames in the future.
Back to the table of contents
mencoder ... /space/*vobto
cat /space/*vob | mencoder ... -for the audio processing (thanks to E. Kevin Hall).
vqmaxto the recommended options for libavcodec (thanks to Peter Schuller)
This is the first release of this guide. Please provide feedback - what did you like? What did you dislike? Where should I provide more information? Please also correct mistakes that I have made. And please tell me about programs / tools / scripts / documentation that I've missed. I can be reached via email: firstname.lastname@example.org
Back to the table of contents