You're still with me? Great! You're about to embark on a journey to a beautiful land...
.IFO
files. libdvdread is often used to parse
these files and extract the informations that are needed.Here's a list of supported video codecs:
divx.dll
and some others) and
requires avifile.
libdivxdecore.so
and 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.DivX
read 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 /usr/local
apt-get install libdvdread2 libdvdread2-dev
should do the trick.
cvs -z3 -d:pserver:anonymous@cvs.xvid.org:/xvid login
When asked for a password simply hit enter.cvs -z3 -d:pserver:anonymous@cvs.xvid.org:/xvid co xvidcore
cd xvidcore/build/generic
make -f Makefile.linux
xvidcore/src/divx4.h
file to
/usr/local/include/decore.h
and to
/usr/local/include/encore2.h
. Be sure to make a backup
of the files you will overwrite!libxvidcore.so
and libcore.a
to
/usr/local/lib/
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:anonymous@cvs.ffmpeg.sourceforge.net:/cvsroot/ffmpeg
login
. Just hit enter when you're prompted for a login or
password.
cvs
-d:pserver:anonymous@cvs.ffmpeg.sourceforge.net:/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
MPlayer.
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 /etc/fstab
for /dvd
./space
.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 :-)
mount /dvd
vobcopy -i /dvd
-o /space
). They will be named after the
DVD's title (e.g. I have ALLY_MCBEAL_DISC21-1.vob
,
ALLY_MCBEAL_DISC21-2.vob
etc.). 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 / Preferences
and 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/dvd
which is a symlink to the real device, e.g.
/dev/hdc
.
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 Rip selected
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
avisync
utility.
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 Frame
input 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.
The big frame
, medium frame
and small
frame
parts refer to the final image size that is to be achieved.
big
keeps almost full DVD resolution, medium
is
somewhere between 500 to 600 for the width and small
is somewhere
around 350.
Use fast resizing
has 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 xvid
.
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
select 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
first deinterlaced
picture.
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 deinterlace
to off
and enter -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. DivX
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
aswell.
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 1
or
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
the 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 nr
in the transcode options
input line on the
Transcode
tab. The nr
is 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 Multipass
is turned on again if you disabled it for
the preview. Either click on Transcode
or on Transcode
+ Split
if 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 :-)
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/004
obviously tells
transcode where to find the files. It can be a file, a device
or a directory containing the files.-w 4357,250,100
sets the video encoding parameters: bit rate,
maximum key frame interval and crispness.-a 1
selects audio track number 1 (starting with 0).-b 128,0,0
sets 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 -V
and
-q.-s 3.311
causes lame to scale the audio
and thus normalizing it on the fly.-V
causes transcode to do image processing
in the YUV color space. Without -V
images 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 25
sets the frame rate.-B 12,10,8
sets the fast scaling options: the picture
will be scaled down to height - 12 * 8
rows and to
width - 10 * 8
columns.-R 1
is 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.-o real-file-name
and
-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 -y
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).
en
for Englisch or de
for 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
nice -+19
- Gives MEncoder the lowest process
priority so it won't disrupt your normal work.-ovc frameno
- Output Video Codec is frameno
which 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 -alang de
-aid 129
.
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=mpeg4
we chose the MPEG4 compliant encoder.
vbitrate=1000
is the desired bitrate. vhq
(very high quality) tells the encoder to spend a lot of time
optimizing the results. It is worth it. vpass=1
finally
tells the encoder that this is the first pass only. Using
vqmin
and vqmax
tells 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.-npp lb
.-ss 0:20
specifies 20seconds into the movie as our beginning,
and -endpos 0:30
says 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=1
to vpass=2
to tell the encoder
that it's the second pass this time. Additionally we leave out the
-nosound
and replace it with -oac copy
which simply
copies the audio from the frameno.avi
file we created in step
one. Of course we should save the final output and replace -o /dev/null
with something usefule, e.g. -o ally-preview.avi
.
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.
-ss
and
-endpos
. Unfortunately MEncoder can't handle multiple
input files on the command line. That's what the cat
is 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 -
-ss
does 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.
avisync
which is part of the transcode package.
avisync
is easy to use: just provide an input file
(-i name.avi
), an output file (-o newname.avi
)
and the synch offset in frames (-n count
). From
avisync
's help: 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
avisplit
which 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 (-t s1-s2
).
An example:
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 null
options tells MPlayer not to show the video.
mplayer -vo null -nogui -alang de -dumpaudio
-dumpfile lang-de.ac3 *vob
lang-de.ac3
.mplayer -vo null -nogui -aid 128 -ao pcm
-aofile lang-de.wav *vob
lang-de.wav
.mplayer -vo null -nogui -dumpaudio
-dumpfile audio.mp2 myvideo.mpg
audio.mp2
.mplayer -vo null -nogui -ao pcm -aofile audio.wav
myvideo.avi
audio.wav
.-dumpaudio -dumpfile
newaudio.extension
if you want to extract the audio without processing
and -ao pcm -aofile newaudio.wav
if you want the WAV itself.
mplayer -audiofile
anotherlang.mp3 myvideo.avi
plays video from myvideo.avi
and 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.
man mplayer
, man mencoder
and
man transcode
show these pages. Additionally providing
-h
or --help
as 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
This is a quick explaination of an MPEG "GOP", or, "Group Of Pictures".
GOP:
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.
mencoder ... /space/*vob
to cat /space/*vob |
mencoder ... -
for the audio processing (thanks to E. Kevin
Hall).export_ffmpeg4
.vpass=1
which should be vpass=2
in
several places (thanks to Markus Liebl)vqmin
and vqmax
to 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: moritz@bunkus.org
Back to the table of contents