DVD Backups

Scouring the internet for making backup copies of DVDs in Linux results in a few GUIs with half-working features and ffmpeg command-line examples resulting in dismal quality.

The following script produces a high-quality two-pass MPEG4 copy entirely automatically using common Linux binaries: mplayer, mencoder, and lsdvd. Edit the MAXSIZE variable to set output size or replace 850 by $1 to allow setting output size at runtime. An audio rate of 192kbps is assumed.

[edit] source

#!/bin/bash
#
# other functions:
# * dump VOB
#   mplayer dvd://1 -v -dumpstream -dumpfile $MOVIE.vob
# * detect crop flag
#   mplayer dvd://1 -vf cropdetect

MAXSIZE=$((850*1000))
AUDIORATE=$((192/8))

MOVIE=`lsdvd -v | grep 'Disc Title:' | cut -d\: -f2`
LENGTH=`lsdvd -t 1 -v | grep 'Length:' | cut -d\  -f4`
LHOURS=`echo $LENGTH | cut -d: -f1`
LMINS=`echo $LENGTH | cut -d: -f2`
LSECS=`echo $LENGTH | cut -d: -f3 | cut -d. -f1`
SECS=$(($LHOURS*3600+$LMINS*60+$LSECS))

AUDIOSIZE=$(($AUDIORATE*$SECS))
VIDEOSIZE=$(($MAXSIZE-$AUDIOSIZE))
VBR=$((($VIDEOSIZE*8)/$SECS))

CROP=`mplayer -vf cropdetect dvd://1 -ss 01:01:01 -frames 30 | grep CROP | tail -n1 | cut -d= -f2 | cut -d\) -f1`

mencoder dvd://1 -oac copy -o /dev/null -vf crop=$CROP -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:cmp=3:subcmp=3:autoaspect:vbitrate=$VBR:vpass=1

mencoder dvd://1 -oac copy -o "$MOVIE.avi" -vf crop=$CROP -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:cmp=3:subcmp=3:autoaspect:vbitrate=$VBR:vpass=2

mencoder dvd://1 -nosound -ovc frameno -o /dev/null -slang en -vobsubout "$MOVIE"

Retrieved from "http://presbrey.mit.edu/DVD_Backups"

This page has been accessed 769 times. This page was last modified 17:27, 13 August 2007.