Often you just want to rip the default title of a DVD without much clicky-clacky. Use this script:

Code: dvdmain2xvid.sh

#!/bin/bash

# filesize in MB
FILESIZE=630
# audio bitrate in kBit/s
ABR=128
# max video bitrate
MAXVBR=1000
# ripping device
DEVICE=/dev/dvd
# default language
ALANG="en"

###

TITLE=`lsdvd $DEVICE | grep 'Disc Title' | awk '{ print $3}'`
TRACK=`lsdvd $DEVICE | grep 'Longest track' | awk '{ print $3}'`
OUTPUTFILE=$TITLE-`date +%Y%m%d%H%M%S`.avi
LENGTH=`lsdvd | grep "Title: $TRACK" | awk '{print $4}'`
MINUTES=`echo "$LENGTH" | awk '{split($1, a, ":"); print a[1]*60+a[2]+1}'`
SECONDS=`echo $[60*$MINUTES]`

# Videobitrate in kBit/s
VBR=`echo $[($FILESIZE*8000-$ABR*$SECONDS)/$SECONDS]`
if [ $VBR -gt $MAXVBR ]
then
 VBR=$MAXVBR
fi

echo "ripping track $TRACK of DVD $TITLE, audio languge $ALANG, length $LENGTH ($MINUTES minutes), to $OUTPUTFILE,"
echo "chosing video bitrate $VBR kBit/s and audio bitrate $ABR kBit/s to reach max size of ${FILESIZE}MB."

echo "----------- pass1"
mencoder dvd://$TRACK -ovc xvid -xvidencopts pass=1 -alang en -oac copy -o /dev/null
echo "----------- pass2"
mencoder dvd://$TRACK -ovc xvid -xvidencopts pass=2:bitrate=$VBR -alang $ALANG -oac mp3lame -lameopts abr:br=$ABR -o $OUTPUTFILE