Here's what I currently use to backup dvd's that I've purchased.
### This page is not a runnable script anymore... it's a collection of scripts I use to backup my dvd collection.
### I used to think I could concoct the Ultimate Script that would allow me to pop in a dvd and make a copy with
### the touch of a button, but after doing a lot of research and gaining a lot of experience, I now realize that's
### impossible with ALL dvd's because not all dvd's are the same. No matter what, you have to collect information
### about the dvd by the output of "mplayer -v dvd://1".
### Also! I'm not a programmer at all, so if you make improvements please, please email them to me at
### "jeff (at) jeffscomputer.kicks-ass.net"
### Thanks!!!
### This first script makes an avi out of the big mpeg you'll get from a dvd with:
### "mplayer dvd://1 -dumpstream -dumpfile desired_moviename"
#!/bin/bash
if [ -z "$1" ]; then
echo -e "\nThis script is designed to be used in one of two ways:\n";
echo -e "1. The best way is to do:\n\n mplayer dvd://1 -dumpstream -dumpfile moviename\n\n\
and then point this script at moviename. Read the script for more details.\n"
end
#echo -e "2. If you're having trouble you can try this: 'mplayer -dumpstream file1.vob' for every vob you want to include in \n\
#your final movie. Then concatenate them all together like:\n\n 'cat file1.vob file2.vob ... > big_mpeg.mpg' \n\
#Then run this script, pointing it at the big mpeg. Assuming you had a full-length movie, \n\
#it will produce about a 1.1 GB avi. \n\n"
#echo "Enter the title of the big mpeg below. (probably moviename if you followed #1)";
#read big_mpeg;
# These are for interlaced videos.
# mencoder $big_mpeg -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=1:vqmin=2:vqmax=31 lavcdeint -o $big_mpeg.avi ;
# mencoder $big_mpeg -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=2:vqmin=2:vqmax=31 lavcdeint -o $big_mpeg.avi ;
# These are for non-interlaced videos.
#mencoder $big_mpeg -ffourcc xvid -ni -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=1:vqmin=2:vqmax=31 $big_mpeg.avi ;
#mencoder $big_mpeg -ffourcc xvid -ni -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=2:vqmin=2:vqmax=31 $big_mpeg.avi ;
#mv test.avi $big_mpeg.avi
#rm divx2pass.log ;
else
#mencoder $1 -ni -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=1:vqmin=2:vqmax=31 $1.avi ;
#mencoder $1 -ni -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=2:vqmin=2:vqmax=31 $1.avi ;
# If you're having trouble with the default language, (ie the rip ends up being in French)
# try running mplayer -v on the big mpeg, then look for the languages. 128 is usually english.
#mencoder $1 -aid 128 -ni -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=1:vqmin=2:vqmax=31 $1.avi ;
#mencoder $1 -aid 128 -ni -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=2:vqmin=2:vqmax=31 $1.avi ;
# This is for the new mencoder from mplayer-1.0_pre7. The "-ffourcc xvid" bit is new to this version of mplayer.
mencoder $1 -ffourcc xvid -aid 128 -ni -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=1:vqmin=2:vqmax=31 $1.avi ;
mencoder $1 -ffourcc xvid -aid 128 -ni -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=2:vqmin=2:vqmax=31 ;
mv test.avi $1.avi ;
rm divx2pass.log ;
fi
exit
# to concatenate avi's:
# cat file1.avi file2.avi > big.avi
# mencoder -ovc copy -oac copy -o out.avi -forceidx big.avi
########################################################################################################################
### This script will take a big mpeg you've collected with "mplayer dvd://1 -dumpstream -dumpfile desired_moviename"
### and cut it down to whatever size you want. I use 2100 MB and put 2 on each dvd. The quality is excellent.
### Unless you have a multiprocessor box, you'll want to remove ":threads=2" from -lavcopts below.
#!/bin/bash
echo -e "Enter name of mpeg file."
read FILENAME
echo -e "Enter length (in minutes) of movie."
read MINUTES
echo -e "Enter desired final size in MB."
read FINALSIZE
FINALKBSIZE=$(($FINALSIZE*1000))
SECONDS=$(($MINUTES*60))
AUDIOSIZE=$(($SECONDS*24))
DIFFERENCE=$(($FINALKBSIZE - $AUDIOSIZE))
RATE=$((($DIFFERENCE*8) / $SECONDS))
echo -e "Title: $FILENAME"
echo -e "Length: $MINUTES"
echo -e "Number of seconds: $SECONDS"
echo "Rate is $RATE"
echo -e "An mpeg of final size $FINALSIZE MB is going to be created in 10 sec.\n I hope you know what the fuck you're doing..."
sleep 10
mencoder $FILENAME -of mpeg -aid 128 -vf scale=720:480,harddup -oac lavc -ovc lavc -lavcopts \
acodec=ac3:abitrate=192:vcodec=mpeg2video:keyint=25:vbitrate=$RATE:aspect=16/9:threads=2 \
-mpegopts format=dvd -srate 48000 -ofps 30000/1001 -o $FILENAME.mpg
exit
###########################################################################################################################
# Here's another version I'm using...I launch it like:
# mymencodeadvd.sh moviename timeInMinutes desiredSizeInMB
#!/bin/bash
#echo -e "Enter name of mpeg file."
#read FILENAME
#echo -e "Enter length (in minutes) of movie."
#read MINUTES
#echo -e "Enter desired final size in MB."
#read FINALSIZE
FILENAME=$1
MINUTES=$2
FINALSIZE=$3
FINALKBSIZE=$(($FINALSIZE*1000))
SECONDS=$(($MINUTES*60))
AUDIOSIZE=$(($SECONDS*24))
DIFFERENCE=$(($FINALKBSIZE - $AUDIOSIZE))
RATE=$((($DIFFERENCE*8) / $SECONDS))
echo -e "Title: $FILENAME"
echo -e "Length: $MINUTES"
echo -e "Number of seconds: $SECONDS"
echo "Rate is $RATE"
echo -e "An mpeg of final size $FINALSIZE MB is going to be created in 10 sec.\n I hope you know what the fuck you're doing..."
sleep 10
mencoder $FILENAME -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -aid 128 -vf scale=720:480,harddup \
-srate 48000 -lavcopts acodec=ac3:abitrate=192:vcodec=mpeg2video:keyint=25:trell:mbd=2:\
vbitrate=$RATE:aspect=16/9:threads=2 -ofps 30000/1001 -o $FILENAME.mpg
exit
#################################################################################################
And now my favorite...
#################################################################################################
#!/bin/bash
# This script uses a framerate for telecined dvd's that are common in the US. The option is -ofps 24000/1001
# if you start seeing lots of frames dropped you might want to change it.
if [ -z "$1" ]; then
echo -e "Enter arguments as follows: MovieName Minutes FinalsizeMB Device\n";
else
FILENAME=$1 ;
MINUTES=$2 ;
FINALSIZE=$3 ;
DEVICE=$4 ;
# FRAMERATE=$5;
FINALKBSIZE=$(($FINALSIZE*1000)) ;
SECONDS=$(($MINUTES*60)) ;
AUDIOSIZE=$(($SECONDS*24)) ;
DIFFERENCE=$(($FINALKBSIZE - $AUDIOSIZE)) ;
RATE=$((($DIFFERENCE*8) / $SECONDS)) ;
echo -e "Title: $FILENAME" ;
echo -e "Length: $MINUTES" ;
echo -e "Number of seconds: $SECONDS" ;
echo "Rate is $RATE" ;
echo -e "An mpeg of final size $FINALSIZE MB is going to be created in 10 sec.\n I hope you know what the fuck you're doing..." ;
sleep 10 ;
mplayer dvd://`lsdvd -d /dev/$4 | grep Longest | cut -c 16-17` -dvd-device /dev/$4 -dumpstream -dumpfile $1 ;
mencoder $FILENAME -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:telecine -aid 128 -vf scale=720:480,harddup \
-srate 48000 -lavcopts acodec=ac3:abitrate=192:vcodec=mpeg2video:keyint=25:trell:mbd=2:dc=10:\
vbitrate=$RATE:aspect=16/9:threads=2 -ofps 24000/1001 -o $FILENAME.mpg ;
fi
exit
#################################################################################################
### Here's another script I've just started using after reading some more docs at
### The mencoder documentation page.
#################################################################################################
#!/bin/bash
# This script uses a framerate for telecined dvd's that are common in the US. The option
# "-ofps 30000/1001" is the default for mencoder, so if you start seeing lots of frames dropped
# you might want to change it to 24000/1001. (Nearly all dvd's here in the US use 24000/1001)
# What I usually do is issue the command "mymencodeadvd.sh Some.Movie 99 2100 dvd", with mymencodeadvd.sh
# being this script, 99 minutes being the length of the movie, 2.1 GB being the desired final mpg size,
# and dvd being the device the disc is in. (hdc or hdd will work also, whatever you've got)
# Then I use DVDStyler to create a dvd with a menu which points to two 2.1 GB movies I've saved.
if [ -z "$1" ]; then
echo -e "Enter arguments as follows: MovieName Minutes FinalsizeMB Device\n";
else
FILENAME=$1 ;
MINUTES=$2 ;
FINALSIZE=$3 ;
DEVICE=$4 ;
FRAMERATE="24000/1001";
FINALKBSIZE=$(($FINALSIZE*1000)) ;
SECONDS=$(($MINUTES*60)) ;
AUDIOSIZE=$(($SECONDS*24)) ;
DIFFERENCE=$(($FINALKBSIZE - $AUDIOSIZE)) ;
RATE=$((($DIFFERENCE*8) / $SECONDS)) ;
echo -e "Title: $FILENAME" ;
echo -e "Length: $MINUTES" ;
echo -e "Number of seconds: $SECONDS" ;
echo "Rate is $RATE" ;
echo -e "An mpeg of final size $FINALSIZE MB is going to be created in 10 sec.\n I hope you know what the fuck you're doing..." ;
sleep 10 ;
mplayer dvd://`lsdvd -d /dev/$4 | grep Longest | cut -c 16-17` -dvd-device /dev/$4 -dumpstream -dumpfile $1 ;
mencoder $FILENAME -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -aid 128 \
-vf scale=720:480,harddup -srate 48000 -lavcopts acodec=ac3:abitrate=192:\
vcodec=mpeg2video:keyint=15:trell:mbd=2:mbd=2:precmp=2:subcmp=2:cmp=2:\
dia=-10:predia=-10:cbp:mv0:vqmin=1:lmin=1:dc=10:vbitrate=$RATE:aspect=16/9:\
threads=2 -ofps $FRAMERATE -o $FILENAME.mpg ;
fi
exit
#########################################################################################################
There's been a breakthrough.....
I _really_ like this transcode script. What it does is:
1) Accepts 3 parameters, the desired movie title, the final_size (in MB) desired (I use 2100), and the device the dvd is in. (you can use hdc or whatever).
2) It uses mplayer to dump the biggest chapter on the drive (usually 1). I've found mplayer to be more reliable than tccat for this purpose.
3) Then it collects basic info using tccat and stores it in a file (tcprobe.tempinfo). I then get movie_length and language_track info from it. It reports (for debugging) the track numbers of the english and spanish tracks. I've only done a few dvd's with this script, so I'm SURE it will need further tweaking.
4) Once all the info is collected, it splits the movie into audio and video tracks, and then rejoins them to create a movie of the desired size.
#!/bin/bash
if [ -z "$1" ]; then
echo -e "Enter arguments as follows: MovieName FinalsizeMB Device\n";
else
FILENAME=$1 ;
FINALSIZE=$2 ;
DEVICE=$3 ;
FRAMERATE="24000/1001";
FINALKBSIZE=$(($FINALSIZE*1000)) ;
tcprobe -i /dev/$3 > tcprobe.tempinfo
SECONDS=`grep sec tcprobe.tempinfo | cut -c 28-32` ;
EN_TRACK=`grep kHz tcprobe.tempinfo | grep -n "ac3 en" | head -c1`
ES_TRACK=`grep kHz tcprobe.tempinfo | grep -n "ac3 es" | head -c1`
EN_INDEX=$(($EN_TRACK-1)) ;
ES_INDEX=$(($ES_TRACK-1)) ;
AUDIOSIZE=$(($SECONDS*24)) ;
DIFFERENCE=$(($FINALKBSIZE - $AUDIOSIZE)) ;
RATE=$((($DIFFERENCE*8) / $SECONDS)) ;
echo -e "Title: $FILENAME" ;
echo -e "Length: $SECONDS seconds" ;
echo -e "Rate is $RATE bps" ;
echo -e "English track is: $EN_INDEX $EN_TRACK"
echo -e "Spanish track is: $ES_INDEX $ES_TRACK"
echo -e "A $FINALSIZE MB mpeg-2 of $FILENAME is going to be created in 10 sec...." ;
sleep 10 ;
# tccat -i /dev/$4 -T 1,-1 -P > $1 ;
mplayer dvd://`lsdvd -d /dev/$3 | grep Longest | cut -c 16-17` -dvd-device /dev/$3 -dumpstream -dumpfile $1 ;
nice -+19 transcode -i $1 -y ffmpeg -F mpeg2video -N 0x2000 -E 48000 --export_prof \
dvd-ntsc --export_asr 3 --encode_fields b -o temp -D0 -s1 -m temp.ac3 \
-J modfps=clonetype=3 -s on,1,1,1 --export_fps 29.97 -a $EN_INDEX -w $RATE ;
tcmplex -i temp.m2v -p temp.ac3 -m d -o $1.mpg ;
rm temp.m2v temp.ac3 tcprobe.tempinfo
fi
exit
####################################################################################################
The script I use now uses a few packages like transcode, mplayer, and lsdvd.
Here's the little script that's referred to in the big script...it's called dumpstream.sh (put it on your $PATH somewhere):
#!/bin/bash
if [ -z "$1" ]; then
echo -e "\nEnter arguments as follows: MovieName DeviceName\n";
else
mplayer dvd://`lsdvd -d /dev/$2 | grep Longest | cut -c 16-17` -dvd-device /dev/$2 -dumpstream -dumpfile $1 ;
fi
#####################################################################################################
Then you're set to use mytranscode, which is below:
#!/bin/bash
if [ -z "$3" ]; then
echo -e "Enter arguments as follows: MovieName FinalsizeMB Device\n";
else
FILENAME=$1 ;
FINALSIZE=$2 ;
DEVICE=$3 ;
FRAMERATE="24000/1001";
FINALKBSIZE=$(($FINALSIZE*1000)) ;
tcprobe -i /dev/$DEVICE > tcprobe.tempinfo
SECONDS=`cat tcprobe.tempinfo | sed -e 's/ /\n/g' | grep -B 1 sec | head -n 1` ;
SECONDS='5711'
EN_TRACK=`grep kHz tcprobe.tempinfo | grep -n "ac3 en" | head -c1`
# ES_TRACK=`grep kHz tcprobe.tempinfo | grep -n "ac3 es" | head -c1`
EN_INDEX=$(($EN_TRACK-1)) ;
ES_INDEX=$(($ES_TRACK-1)) ;
AUDIOSIZE=$(($SECONDS*24)) ;
DIFFERENCE=$(($FINALKBSIZE - $AUDIOSIZE)) ;
RATE=$((($DIFFERENCE*8) / $SECONDS)) ;
echo -e "Title: $FILENAME" ;
echo -e "Length: $SECONDS seconds" ;
echo -e "Rate is $RATE bps" ;
echo -e "English track is: $EN_INDEX $EN_TRACK"
# echo -e "Spanish track is: $ES_INDEX $ES_TRACK"
echo -e "A $FINALSIZE MB mpeg-2 of $FILENAME is going to be created in 10 sec...." ;
sleep 10 ;
# tccat -i /dev/$DEVICE -T 1,-1 -P > $FILENAME ;
dumpstream.sh $FILENAME $DEVICE
eject $DEVICE ;
nice -+19 transcode -i $FILENAME -y ffmpeg --export_prof dvd-ntsc --export_asr 3 -F mpeg2video \
-o temp -D0 -b224 -N 0x2000 -s2 -u 30,3 -s on,1,1,1 -M 4 -m temp.ac3 -J modfps=clonetype=3 \
--export_fps 29.97 -a $EN_INDEX -w $RATE ;
mplex -f8 -o $FILENAME.mpg temp.m2v temp.ac3 ;
# rm temp.m2v temp.ac3
fi
exit