Automated DVD Creation

Thanks to a buddy of mine, I was able to write a bash script to pretty much fully automate DVD creation from video files. The original article can be found HERE if you would like to see how I started.

This is an open source script to feel free to take it and do with it what you wish!

Please also note this script only works on Linux

Before this script will work you will need to install the following tools:

  1. ffmpeg
  2. dvdauthor
  3. genisoimage
  4. growisofs (usually pre-installed)

Here is the Script (you'll also need to change the "/media/raid" to part of the path where you store your videos, this allows for the ability to use full paths or not. Also, you will need to change the OUTFOLDER variable path):

#!/bin/bash

# creates DVD iso Files from Video Files
#

FFMPEG="/usr/bin/ffmpeg"
DVDAUTHOR="/usr/bin/dvdauthor"
GENISO="/usr/bin/genisoimage"
ECHO="/usr/bin/echo"
OUTFOLDER="/media/raid/dvd_burn"
REMOVE="/usr/bin/rm -rf"

if [[ $# -eq 0 ]]; then
  $ECHO "Need to provide path to a video file."
else
  INPUT=( "$@" )
fi

for inFile in "${INPUT[@]}"; do
  if [[ $inFile == *"/media/raid/"* ]]; then
    MOVIENAME=$($ECHO ${inFile:26})
  else  
    MOVIENAME=$inFile
  fi
  $FFMPEG -fflags +genpts -threads 4 -i $inFile -f dvd -c:v:0 mpeg2video -aspect 16:9 -s 720x480 -r 24000/1001 -g 18 -b:v:0 8000000 -maxrate:v:0 8000000 -minrate:v:0 8000000 -bufsize:v:0 1835008 -packetsize 2048 -muxrate 10080000 -b:a 192000 -ar 48000 -c:a:0 ac3 -c:a:1 ac3 -map 0:v -map 0:a -map -0:s:0 -target ntsc-dvd "$OUTFOLDER/$MOVIENAME.mpg"

  export VIDEO_FORMAT=NTSC
  $DVDAUTHOR --title -o "$OUTFOLDER/$MOVIENAME" -f "$OUTFOLDER/$MOVIENAME.mpg"
  $DVDAUTHOR -T -o "$OUTFOLDER/$MOVIENAME"
  $GENISO -dvd-video -o "$OUTFOLDER/$MOVIENAME.iso" "$OUTFOLDER/$MOVIENAME"
  $REMOVE "$OUTFOLDER/$MOVIENAME"
  $REMOVE "$OUTFOLDER/$MOVIENAME.mpg"
done


$ECHO "COMPLETE"

Don Oerkfitz

Read more posts by this author.