| table of contents --> next chapter <-- previous chapter | last modified on August 23, 2002 |
avisync utility.Here is a list of common scenarios:
If you want to understand what is really happening then you just have to
do some math. Let's assume that the DVD is encoded with 720x576 which is
5:4, and its flags indicate that it should be played back at 16:9. This means
that the player has to change the picture's aspect ratio from 5:4 to 16:9
by either scaling to 1024x576 or to 720x405. How to I calculate these values?
Well I simply multiply the width with (display AR / encoded AR) which is
(16:9 / 5:4) = 1.78 / 1.25 = 1.42. It's similar for the latter case. But this
includes the black bars that may be present! So if your DVD cover says that
the movie has an aspect ratio of 2.35 then you still see black bars on this
scaled picture.
After starting dvd::rip you rip the titles you wish to transcode
to your hard disk. Refer to chapter
3 for a detailed description.
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
The 4.2. Using dvd::rip
Using dvd::rip is by far the best and easiest method to get your
AVI. As stated earlier it relies heavily on transcode to do its job.4.2.1. Clipping and zooming
Now head over to the Clip & Zoom tab. Here's where you set all parameters
regarding picture size and cropping (called "clipping" here). First get
yourself a picture to work with: simply enter a frame number (like 200)
into the 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.Apply Preset Values button. Now adjust the
values you got until you're happy.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 divisible 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.
4.2.2. Choosing encoding parameters
We're done with this tab. Open the Transcode tab. First decide about the video codec you
want to use. If you've installed DivX5 for Linux then you can use
that, but I would recommend using XviD. If you've downloaded
XviD from CVS then the option to chose is 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 as well 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
as well.
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
When you're done click
Now is really a fine time for some socialising :-)
In dvd::rip press
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 written by me. You can activate it by using
Now call MEncoder to encode the audio for you:
Let's assemble the command line options one by one:
Here's the command line:
Now go get a beer and a nice book.
Target Size or the Video Bitrate works as well.
4.2.3. Generating a quick preview
Most of the times you should let dvd::rip generate a small preview.
You do that by providing a 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!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 perfectly
synchronized. If they are, you're set. If they aren't, then read on:
4.2.4. Preventing audio/video desynchronization
If your audio and video are not synchronized in the preview (or when you
play back the DVD itself) then you can give transcode a frame
offset for the a/v synchronization. You do that by providing the parameter -D nr
in the transcode options input line on the
Transcodetab. 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.
4.2.5. Doing the whole thing
When the preview is fine you can start your transcode. Make sure that
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.4.2.6. For advanced users: transcode command line arguments
This chapter explains the transcode command line options used by
dvd::rip. It is not crucial to the transcoding process so you may
as well skip it. I provide it for those who wish to have some deeper insight
into what dvd::rip and transcode do.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 mkdir
and cd commands:
Let's take a look at the first command and its parameters:
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,nulltranscode -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
The second command line is not that different. It just skips all options
that would discard output (like -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.-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).
4.3. Using MEncoder
As mentioned earlier there is no GUI for MEncoder at the moment.
Therefore I won't provide screenshots and you have to do everything by hand.
This is a process called "three pass encoding".
4.3.1. Encoding the audio
The first step is to encode only the audio. Make sure you know what audio
language you want to use - you need either the audio id (which is 128 for
the first stream, 129 for the second etc.) or the two-letter country code
(like en for English 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
Here I have three audio streams: English, German, Spanish and their IDs.
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:
Wait some time and you'll have your audio. MEncoder even prints
some suggestions for the video bitrate: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 will 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
As you can see these values are rather high - but that's because an Ally
McBeal episode is only 41minutes long. So I'd go for two episodes per
CD and give the video a bitrate of about 1000.
4.3.2. Generating a preview (first pass)
Now's the time to decide about the video codec you're going to use. I'm
assuming that AVI is the desired result with one of the different DivX
encoders. MEncoder has support for DivX 4 or
DivX 5 (same under Windows actually, you have either v4 or v5
running) as well as for XviD or lavc. Although most of you
won't have heard of libavcodec or the ffmpeg-project before
you should be advised that lavc is far superior to DivX 4 or 5
and at least as good as XviD. So I will only provide examples
for lavc as you don't even need special codecs for playback:
MPlayer plays them just fine (naturally), and for Windows you simply
need DivX 5 (free edition is absolutely sufficient). So here we go.
Put together the complete command line looks like this:-oac copy - MEncoder needs the audio information
from the first pass in order to keep audio/video synchronization.
You mustn't use -nosound, although I suggested it in earlier
versions of this guide. If you want the technical details then have a look
at the MPlayer mailing list.-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=2: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 choosing a broader range.
Note that I'm no expert on quantizers. If I'm wrong here please
drop me a line.-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 -oac copy -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
4.3.3. Generating a preview (second pass)
For this step we can keep most of our previous command line. Of course we
change the vpass=1 to vpass=2 to tell the encoder
that it's the second pass this time. Of course we should save the final output
and replace -o /dev/null with something useful, e.g. -o
ally-preview.avi.
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.
4.3.4. Generating the final AVI (both passes)
The calls for the final options simply leave out -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 -oac copy -o /dev/null -ovc lavc -lavcopts
vcodec=mpeg4:vbitrate=1000:vhq:vpass=1:vqmin=2: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=2:vqmax=31 -vop scale=640:480
-npp lb -
Note that -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).
| table of contents --> next chapter <-- previous chapter | this guide was written by Moritz Bunkus |