How to rip DVDs with mencoder

MEncoder is a media editor, part of MPlayer. It is often used for compressing files and capturing video. This program is part of mplayer a media player. This program has been ported to almost every operating system including Microsoft Windows, Mac OSX, and all forms of Linux, BSD, and UNIX. Using mencoder to rip DVDs allows you to avoid dealing with VOB files, coping large video files, and many other troubles.

There are many different video and audio codecs combinations to compress files. Here are some common ones.

Xvid, 2 stage
Xvid video compression, and mp3lame audio compression


 * requires
 * Mencoder:
 * Home page: http://www.mplayerhq.hu/
 * Gentoo: emerge mplayer
 * Xvid
 * http://www.xvid.org/
 * Usually compiled internally with Mplayer
 * LAME mp3 encoder (mp3lame)
 * Homepage: http://lame.sourceforge.net/
 * Gentoo: emerge lame


 * DVD_TRACK is the DVD track number to rip
 * Example: 2
 * BIT_RATE: is the video bitrate
 * Example: 1000
 * VIDEO_FILE: is the video output file name
 * Example: movie.avi


 * Stage 1
 * mencoder DVD://DVD_TRACK -ovc xvid -xvidencopts pass=1 -alang en -oac copy -o /dev/null
 * Stage 2
 * (mencoder DVD://DVD_TRACK -ovc xvid -xvidencopts pass=2:bitrate=BIT_RATE -alang en -oac mp3lame -lameopts vbr=3 -o VIDEO_FILE

h264/x264
H264 compression with ACC audio compression

See: http://gentoo-wiki.com/HOWTO_Rip_DVD_mencoder#H264_.28MPEG4_Part_10.29

Divx (3 stage)
Using 3-stage Divx ripping


 * NB: This gives a rather average rip! No cropping


 * 1) !/bin/sh

VIDEO_WIDTH=640 DVD_DEVICE=/dev/dvd TWOPASSFILE=divx2pass.$$.`date +%Y%m%d%H%M%S`

script=`basename "$0"`

track="$1" brate="$2" name="$3"

if [ "$track" = "" ] || [ "$brate" = "" ] || [ "$name" = "" ]; then echo "$script: Rip a DVD track to DIVX" echo "$script: Arguments    [dvd-device (or rip directory)]" exit 1 fi

if [ -f "$name" ]; then echo "$script: [$name] exists, overwriting in 3 seconds ..." sleep 3 rm -f "$name" fi

if [ "$4" != "" ]; then DVD_DEVICE="$4" if [ ! -d "$DVD_DEVICE" ]; then echo "$script: Can't find DVD Device (directory) [$DVD_DEVICE]" exit 1 else echo "$script: Reading from 'DVD' [$DVD_DEVICE]" fi fi

mencoder dvd://$track -passlogfile $TWOPASSFILE -dvd-device "$DVD_DEVICE" -oac copy \ -o /dev/null -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=$brate:vhq:vpass=1:vqmin=1:vqmax=31 \ -vf scale -zoom -xy $VIDEO_WIDTH -vf pp -alang en mencoder dvd://$track -passlogfile $TWOPASSFILE -dvd-device "$DVD_DEVICE" -oac copy \ -o "$name" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=$brate:vhq:vpass=2:vqmin=1:vqmax=31 \ -vf scale -zoom -xy $VIDEO_WIDTH -vf pp -alang en
 * 1) echo "dvd://$track -passlogfile $TWOPASSFILE -dvd-device \"$DVD_DEVICE\" -oac copy \
 * 2)   -o \"$name\" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=$brate:vhq:vpass=2:vqmin=1:vqmax=31 \
 * 3)   -vf scale -zoom -xy $VIDEO_WIDTH -vf pp -alang en"

if [ -f "$TWOPASSFILE" ]; then rm $TWOPASSFILE fi echo "Ripped track [$track] to [$name]"