#!/bin/bash # # file name: burn_dvd.sh # # script to automate the createion of basic DVD movies (no menues etc, just plug-n-play). # November 2006. Pete Nesbitt (Thanks to Mike Thorpe for process information) # REQUIRES: # -an AVI DivEX encoded movie source, typically via a bit-torrent download (check legal aspects before proceeding) # -ffmpeg (available from http://ffmpeg.sourceforge.net or as an rpm [livna.org repo?]) # -dvdauthor (available from http://dvdauthor.sourceforge.net or as an rpm from ATrpms.net) # -mkisofs & growiso, usually included with your distribution # EXPECTS: # -the current directory (working directory) to contain the source avi file # -you to have write access to the working directory # -you to have write access to the dvd device # -the dvd device to be symlinked as /dev/dvd ############################### # VARS # use arg as base name SOURCE_NAME=$1 BASE_NAME="" error_mesg="" ############################### # FUNCTIONS # check if a step was suscessful check_success() { if [ $? -ne 0 ]; then echo "ERROR: $error_mesg" exit 1 fi } ######### # check if valid file is provided check_source() { while [ "$SOURCE_NAME" = "" ]; do printf " => Enter name of AVI file in Current Directory: [${SOURCE_NAME}] " read SOURCE_NAME done # is the avi file valid # use single quote to allow ! char error_mesg='File must be an avi in the current directory. NO SPACES or SPECIAL CHARACTERS IN NAME!' file ${SOURCE_NAME}|grep AVI } ######### # get the basic name get_base() { if [ `echo ${SOURCE_NAME}|grep -i ".avi$"` ]; then BASE_NAME="`echo ${SOURCE_NAME}|tr [:upper:] [:lower:]|sed s/.avi$//`" else BASE_NAME=${SOURCE_NAME} fi } ######### # this created the author xml file for basic play, you could do much much more with this. dvdauth_file() { echo "" > dvdauthor.xml echo " " >> dvdauthor.xml echo " " >> dvdauthor.xml echo " " >> dvdauthor.xml echo " " >> dvdauthor.xml echo " " >> dvdauthor.xml echo " " >> dvdauthor.xml echo " " >> dvdauthor.xml echo " " >> dvdauthor.xml echo "" >> dvdauthor.xml } ########## ################## # start of script ################## clear # print out what should be in place like disk in drive etc START_OK="Y" echo "" echo "Place ensure the following before continuing:" echo ' 1) NO SPACES or SPECIAL CHARACTERS IN NAME!' echo " 2) It is okay to over-write the dvdauthor.xml file if one already exists" echo " 3) It is okay to remove the DVD_ROOT directory and contents if it exists" echo " 4) A Blank DVD Disk is in the burner" echo "" printf " => Okay to continue (y/n)? [${START_OK}] " read START_OK if [ "${START_OK}" = "n" ] || [ "${START_OK}" = "N" ]; then echo "Exit by user" exit fi # check if valid file is provided error_mesg='File must be an avi in the current directory. NO SPACES or SPECIAL CHARACTERS IN NAME!' check_source check_success # now strip that down for use later error_mesg="File does not have a .avi extention, this script looks for one. ...ya ya, I know it is not required." get_base check_success # convert to mpeg error_mesg="Failed to create MPEG file" ffmpeg -tvstd NTSC -i ${SOURCE_NAME} -target dvd ${BASE_NAME}_dvd_master.mpeg check_success # make a directory to store all the iso files error_mesg="Failed to remove Old DVD_ROOT directory" if [ -d DVD_ROOT ];then rm -rf DVD_ROOT check_success fi error_mesg="Could not create DVD_ROOT dir" mkdir DVD_ROOT check_success # create dvdauthor.xml error_mesg="Failed to remove Old dvdauthor.xml" if [ -e dvdauthor.xml ];then rm -f dvdauthor.xml check_success fi error_mesg="Failed to create dvdauthor.xml file" dvdauth_file check_success # create the files to go into the iso error_mesg="Failed running dvdauthor" dvdauthor -o ./DVD_ROOT/ -x ./dvdauthor.xml check_success #Make the iso file error_mesg="Failed to make iso file" mkisofs -dvd-video -o ${BASE_NAME}_DVD.iso ./DVD_ROOT/ check_success # burn to disk error_mesg="Failed Burning iso image to DVD Disk" growisofs -dvd-compat -Z /dev/dvd=${BASE_NAME}_DVD.iso check_success echo "" echo "######################################################" echo "" echo "All steps completed." echo "" echo " ${BASE_NAME} DVD Succesfully created" echo "" eject #eof