Ripping
DVDs to Divx with mencoder (mplayer) under Linux
by paranouei
Spanish Version
News(20/01/2003): New forum available. You can ask there your questions
about this guide.
We can do it in two ways, direct ripping to the .avi or doing "three
pass encoding". The latter method is explained in
http://www.bunkus.org/dvdripping4linux/single/index.html#transcoding_mplayer
Direct Ripping
-
play the DVD, calculate how long it last (including credits) in seconds,
check if the volume is too low (because we can turn it up with software).
Also, if the image looks strechted, maybe mplayer doesn't realize it's
in 16:9 format, so we have to explicitly indicate it (with -aspect 16:9),
and the image will be all right (this happened to me with "Crouching
Tiger Hidden Dragon").
And don't forget to check in which "title id" does the movie start,
usually movies start in id 1, but sometimes there are trailers
and such so it starts in a different title id (i.e. Crouching
Tiger.. started in number 10) (mplayer -dvd 10).
-
calculate the rate to get the desired file size. Knowing how many seconds
it lasts,you can use my script dvd-ripping (it's at the end) to get the rate.
For example, if you want a file size below 700Mb, you have to calculate the
best rate you can use to get a file under that size."Rate" is the movie quality
in kbits/s.
-
if the movie has black borders you can take them off. First, calculate
the borders geometry whith option cropdetect:
mencoder -aspect 16:9 -dvd 10 -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=694
-vop cropdetect,scale -zoom -xy 640 -oac mp3lame -lameopts
abr:br=128:vol=9 -o tigreydragon.avi
let it run for a while to make sure is ripping the real movie (and
not just the credits) and you'll get the values you have to pass
to crop option to take the black borders off(i.e. in Crouching Tiger..
I get crop=640:272:0:44). Keep in mind these values are relative to
the output resolution.
-
run mencoder with your parameters. Here are some parameters I used:
- vol=9 in -lameopts (this is because the volume was too
low, so i gave it some gain. Valid values are between 1 and 10).
- -aspect 16:9 (this is because mplayer didn't realize
this was the original format so i was getting a stretched image).
- vbitrate=694 in -lavcopts (video rate i got with my
script dvd-ripping)
- -dvd 10 it's the title id where the movie starts (usually
is number 1)
- crop=640:272:0:44 in -vop (to take the black borders
off)
So the full command is
mencoder -aspect 16:9 -dvd 10 -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=694
-vop crop=640:272:0:44,scale -zoom -xy 640 -oac mp3lame
-lameopts abr:br=128:vol=9 -o tigreydragon.avi
This will rip the movie directly from the DVD to the Divx avi file
in only one pass. I recommend that at the same time you are ripping, play
with mplayer the .avi in a different terminal to check you are getting
the desired format (resolution, quality, volume...)
Three pass encoding
This method is explained in http://www.bunkus.org/dvdripping4linux/single/index.html.
Anyway his method uses the *.vob files in the hard drive, and you can
make it directly from the DVD with this method:
-
First the sound:
mencoder -dvd 1 -ovc frameno -o frameno.avi -oac mp3lame -lameopts
abr:br=128
-
First pass:
mencoder -dvd 1 -nosound -oac copy -o /dev/null -ovc lavc -lavcopts
vcodec=mpeg4:vbitrate=800:vhq:vpass=1:vqmin=1:vqmax=31 -vop scale -zoom
-xy 640 -npp lb
-
Second pass:
mencoder -dvd 1 -oac copy -o file.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=800:vhq:vpass=2:vqmin=1:vqmax=31
-vop scale -zoom -xy 640 -npp lb
Script dvd-ripping:
#!/bin/bash
if [ $# != 1 ] ; then echo "Use: dvd-ripping <movie size in seconds>" echo "" exit 1 fi
# Biggest file size is 700mb, which is 716800kbytes # but just in case we use a little smaller size MAXSIZE=700000
SEGUNDOS=$1 MINUTOS=$(($SEGUNDOS/60))
#Audio rate is 128bits/s which is 16kbytes/s AUDIOSIZE=$((16*$SEGUNDOS)) LIBRE=$(($MAXSIZE - $AUDIOSIZE)) RATE=$((($LIBRE*8) / $SEGUNDOS))
echo "Calculating rate for movie which lasts $MINUTOS minutes..."
echo "Estimated rate: $RATE"
FINALSIZE=$(( ($RATE * $SEGUNDOS)/8 + $AUDIOSIZE))
echo "Estimated size: $FINALSIZE"
echo "The command is:" echo "mencoder -dvd 1 -ovc lavc \ -lavcopts vcodec=mpeg4:vhq:vbitrate=$RATE \ -vop scale -zoom -xy 640 -oac mp3lame \ -lameopts abr:br=128 -o file.avi"
|
|
|