The Lifecycle of Video

I do quite a lot of video manipulation.  Most of the stuff I watch is on computer, hooked to HDMI to my television.  That, attached with my being only a short step away from tagging in a couple of cable input cards on my computer, once I have the free cash.

Of course, as most know that have read my previous posts, I use Linux.  I have since 1996, which means it’s become an integral part of my life.  Sooooo, I do all conversion through a commandline 🙂  I know how it is to remember things constantly and not doing something in a while… then.. oh, what was that from 2 months ago?  I have a batch of scripts that I created which make life a lot easier, and I wanted to share them.  It’s always sweet to run into things when your looking for them, and I hope that someone else is helped by this.
Now, naturally we as humans do one of two things.  We have a DVD and want it in a lossless or compressed format on our harddrive, OR we have an AVI (or other format), and we want to put it onto DVD to play somewhere.  To add a little twist, I recently converted to widescreen (16×9, 720p) and this helps me convert to widescreen format as well.  Nevermind the fact that my DVD player automatically upscales to 1080p when necessary.. but hey…

Anyway, the lifecycle I run through:

  • Suck something off DVD to intermediate disk file (15-30 minutes)
  • Convert VOB intermediate disk file to AVI (4-5 hours)
  • Convert AVI to a DVD-Ready MPEG (15-30 minutes)
  • Convert a DVD-Ready MPEG to DVD (5-10 minutes)

Here are the scripts I’ve created that run through each of these needs as noted.  These were created on Red Hat Enterprise Linux 5.3 (or what I use, CentOS 5.3), but pretty much will work on any Linux environment that has the required executables.

This script (I call is a direct feed from DVD and converts to AVI.  The downfall with this one is that it utilizes the DVD through the entire method, and saves no time.  The upside is the lack of VOB creation which can take 3-6Gb.
 mencoder dvd://1 -ovc frameno -o frameno.avi -oac mp3lame -lameopts abr:br=128

 mencoder dvd://1 -nosound -oac copy -o /dev/null -ovc lavc -lavcopts \
 vcodec=mpeg4:vbitrate=800:vhq:vpass=1:vqmin=1:vqmax=31 -aspect 16/9

 mencoder dvd://1 -oac copy -o file.avi -ovc lavc -lavcopts \
 vcodec=mpeg4:vbitrate=800:vhq:vpass=2:vqmin=1:vqmax=31 -aspect 16/9

For those of us that want to use our DVD player once and, let the computer do it’s work after (the way I prefer), this script works nicely.  There will be a need of about 3-6Gb for the VOB file.


 if [ -z ${1} ]; then
 echo "Rips the DVD into VOB so you can have your way with it."
 echo "The VOB is saved into the directory you are currently in."
 echo "NOTE: the file will be approximately 3-6GB in size."
 echo ""
 echo "${0} <Name of movie without spaces>"
 echo ""
 echo "Logs are in the file ${LOGFILE}"

 mplayer dvd://1 -v -aspect 16/9 -dumpstream -dumpfile ${NAME}.vob 2>&1
 echo "${NAME}.vob copied."

Then, After the VOB file exists, convert it to AVI with the following script.


 if [ -z ${1} ]; then
 echo "Converts a VOB to AVI."
 echo "AVI is stored in current working directory."
 echo "e.g. `pwd`"
 echo ""
 echo "${0} <name of vob file>"
 echo ""
 echo "To track activities, logs are at ${LOGFILE}"

 AVIFILE=`echo ${VOBFILE} | sed "s/\.vob/\.avi/g"`
 # -msglevel all=0  -xvidencopts fixed quant=4
 mencoder -ovc xvid -oac mp3lame -vf scale=720:480 \
 -xvidencopts threads=4:fixed_quant=4 -lameopts cbr:br=192:aq=1 -aid 128 \
 -lameopts vol=3 -o ${AVIFILE} ${VOBFILE} 2>&1 > ${LOGFILE}
 echo "Completed!"

For the second leg of the travels, when we want to convert an AVI to a DVD (or just an mpeg…), we take the reverse scripts and run. will convert an AVI file into a DVD-compatible MPEG video file.

 # Requires:
 # mencoder
 # a little intelligence.

 if [ -z ${1} ]; then
 echo "Converts an AVI to a DVD-ready MPEG file"
 echo ""
 echo "${0} <name of AVI file>"

 MPEGFILE=`echo ${1} | sed "s/.avi/.mpg/g"`

 ####De-space the files...
 ####for i in *\ *; do newname=`echo $i|sed -e 's/ /-/g'`; mv -i "$i"
 $newname; done

 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd \
 -vf scale=720:480,harddup -srate 48000 -af lavcresample=48000 \
 -lavcopts threads=2:vcodec=mpeg2video:
 maxrate=9800:vbitrate=2176:keyint=18:aspect=16/9:acodec=ac3:abitrate=192 \
 -ofps 30000/1001 -o ${MPEGFILE} ${AVIFILE}
Then, to convert the MPEG file to a simple menu-less DVD, can be used.
 if [ -z ${1} ]; then
 echo "Converts the MPEG to a DVD ISO"
 echo "This can be burned to a DVD after."
 echo ""
 echo "${0} <name of mpeg file>"
 ISOFILE=`echo ${MPEGFILE} | sed "s/\.mpg/\.iso/g" | sed "s/\.mpeg/\.iso/g"`


 mkdir DVD
 cat << EOF > dvdauthor.xml

 <dvdauthor dest="DVD">
 <vmgm />
 <video widescreen="nopanscan" />
 <vob file="${MPEGFILE}"

30,3:00,3:30,4:00"/> </pgc> </titles> </titleset> </dvdauthor> EOF dvdauthor -x dvdauthor.xml 2>&1 > ${LOGFILE} cd DVD && mkisofs --dvd-video -o ../${ISOFILE}.iso . 2>&1 >> ${LOGFILE} cd .. echo "Complete!  ISO File is in `pwd` & named ${ISOFILE}" exit
After that, you have the DVD ISO ready to burn to disk!
All that needs to happen is tossing in a burnable DVD into your burner, and either using growisofs to burn the image, or running the following script
if [ -z ${1} ]; then
echo “Just flat out burns a DVD image.  Nothing fancy.”
echo “Just make sure you actually have the DVD in the drive.”
echo “”
echo “${0} <ISO file>”

if [ ${PARAM} == "1" ]; then
 echo "DVD/ Directory structure being used.  Now burning."
 growisofs -Z /dev/dvd -dvd-video DVD/

if [ ${PARAM} == "2" ]; then
 echo "ISO being used.  Now burning."
 growisofs -Z /dev/dvd=${ISOFILE}

So, in the end we have the scripts we need… (or &,,, &
There are requirements of executables for these scripts to run.  Make sure mencoder, mplayer, & dvdauthor are installed.
Thanks, and have fun!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s