Rip dvd’s (iso’s) to high quality avi

I recently needed to rip some videos from dvd’s so I can have them on my computer in smaller files. I prefer the command line, so I use MEncoder that comes with mplayer. Supposedly AcidRip is a good interface that automates things for MEncoder. I wrote some scripts based on my research into how to do rip dvd’s from the command line. Note that I have -dvd-device /path/to/iso in all of the scripts since I’m doing videos from an iso file. If you are doing it from disc, remove this portion of the commands.

dvdiso2xvid.sh (one pass, based on xvid):

<pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>

## Usage: dvdiso2xvid.sh file.iso ## http://www.howforge.com/how-to-encode-dvd-to-avi-using-mencoder ## http://forum.videohelp.com/threads/288190-(SOLVED)-Need-mencoder-help-certain-files-have-no-audio for file in “$@” do bn=basename "$file" NameNoExt=${bn%.*} ## no extension mencoder dvd://1 -dvd-device “$bn” -oac mp3lame -lameopts mode=2:cbr:br=128:vol=0 -ovc xvid -xvidencopts bitrate=-1 -vf scale -zoom -xy 480 -o “$NameNoExt.avi” done

dvdiso2lavc.sh (one pass, based on libavcodec):

<pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>

## Usage: dvdiso2lavc.sh file.iso ## http://www.howforge.com/how-to-encode-dvd-to-avi-using-mencoder ## http://forum.videohelp.com/threads/288190-(SOLVED)-Need-mencoder-help-certain-files-have-no-audio for file in “$@” do bn=basename "$file" NameNoExt=${bn%.*} ## no extension mencoder dvd://1 -dvd-device “$bn” -oac mp3lame -lameopts mode=2:cbr:br=128:vol=0 -ovc lavc -lavcopts vcodec=mpeg4:vhq:v4mv:vqmin=2 -o “$NameNoExt.avi” done

dvdiso2xvid_2pass.sh (two passes (so better quality), crop images (for use with widescreen), based on xvid):

<pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>

## Usage: dvdiso2xvid_2pass.sh file.iso ## http://www.axllent.org/docs/video/mencoder_dvd_to_mpeg4 ## http://www.axllent.org/uploads/files/divxcalc.html ## http://quadpoint.org/projects/simplerip

VBR=1000 ## higher, better quality ABR=128 ## 96 recommended for file in “$@” do rm -f divx2pass.log bn=basename "$file" NameNoExt=${bn%.*} ## no extension # start a timer to kill mplayer (sleep 5 && killall mplayer)& # start the mplayer cropdetect on DVD’s chapter 4 mplayer dvd://1 -dvd-device “$bn” -chapter 3 -vf cropdetect &> mplayer.tmp # get last crop value from mplayer output and store in variable CROP_VALUES=$(awk -F‘crop=’ ‘/[CROP]/{f=$2} END{print f}’ ./mplayer.tmp |cut -d‘)’ -f1) # print detected crop values echo -e “nnDetected crop values = ${CROP_VALUES}nn” mencoder dvd://1 -dvd-device “$bn” -vf crop=${CROP_VALUES} -ovc xvid -xvidencopts bvhq=1:chroma_opt:quant_type=mpeg:bitrate=${VBR}:pass=1 -oac copy -o /dev/null mencoder dvd://1 -dvd-device “$bn” -vf crop=${CROP_VALUES} -ovc xvid -xvidencopts bvhq=1:chroma_opt:quant_type=mpeg:bitrate=${VBR}:pass=2 -alang en -oac mp3lame -lameopts br=${ABR}:cbr:vol=0 -o “${NameNoExt}.avi” done

Basically, if you want better quality, then increase the video bitrate. However, this means the final output file will be bigger. Double passing also makes better quality output because the second pass uses information from the first pass to increase the bitrate at the part of the video that is needed. Good references are here and here. For me, I think setting the video bitrate to 1000 produces a pretty good quality video for the size. If you have a constraint on the file size (such as 690mb to fit on a CD), you can find a calculator here and here. simplerip is pretty cool in that it will create all the commands you need after you input your requirements (such as crop, file size, scale, volume, etc). However, I think my dvdiso2xvid_2pass.sh is a pretty decent script that automates everything and gives good quality output.

About Vinh Nguyen

Statistician

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>