OneStep DVD-Video (v0.3)

Summary: A shell script to convert, and make an DVD-Video image of a specified video file.

Requirements:

  • ffmpeg
  • dvdauthor
  • mkisofs

Code:

#!/bin/bash
TMP="${TMPDIR}/"
LOG="${HOME}/.OneStepDVDVideo.log"

##Write Date & Time to Log File
echo "-------------------------------------" > "${LOG}"
echo "`date +%B %d, %Y`" >> "${LOG}"
echo "-------------------------------------" >> "${LOG}"
 
echo "OneStep DVD-Video"
echo "Scripted by Blake Johnson"
echo "http://www.simplescripts.net/"
echo


if [ "$1" ]
then
	if [ -r "$1" ]
	then
		InputFileLocation="${1%/*}/"
		InputFileName="${1##*/}"
		OutputPath="${InputFileLocation}${InputFileName}.iso"
	else
		echo "Source file either does not exist, or it is not readable."
		exit 2
	fi
else
	echo "Source not specified."
	exit 1
fi

echo



FFmpegCommand="ffmpeg -y -i ${InputFileLocation}${InputFileName} -aspect 3:4 -target ntsc-dvd ${TMP}${InputFileName}.m2v"
DVDAuthorStep1Command="dvdauthor -o ${TMP}${InputFileName}_temp/ -t ${TMP}${InputFileName}.m2v"
DVDAuthorStep2Command="dvdauthor -o ${TMP}${InputFileName}_temp/ -T"
MKISOFSCommand="mkisofs -dvd-video -o ${OutputPath} ${TMP}${InputFileName}_temp/"

##Let's run FFmpeg
echo -n "Step 1 of 4: Converting video to a MPEG2 file..."
FFmpegOutput="`${FFmpegCommand} > /dev/null 2>&1`"

if [ $? == 0 ]
then
	echo -n -e "33[1;32mOK!"
	echo -e "33[0m"

	##Let's run DVDAuthor, Step1
	echo -n "Step 2 of 4: Building initial DVD-Video structure..."
	DVDAuthorStep1Output="`${DVDAuthorStep1Command} > /dev/null 2>&1`"
	
	if [ $? == 0 ]
	then
		echo -n -e "33[1;32mOK!"
		echo -e "33[0m"

		##Let's run DVDAuthor, Step 2
		echo -n "Step 3 of 4: Finalizing DVD-Video structure..."
		DVDAuthorStep2Output="`${DVDAuthorStep2Command} > /dev/null 2>&1`"
		
		if [ $? == 0 ]
		then
			echo -n -e "33[1;32mOK!"
			echo -e "33[0m"

			##Let's run MKISOFS.
			echo -n "Step 4 of 4: Creating an ISO image of the DVD..."
			MKISOFSOutput="`${MKISOFSCommand} > /dev/null 2>&1`"
			
			if [ $? == 0 ]
			then
				echo -n -e "33[1;32mOK!"
				echo -e "33[0m"

				##Everything worked.
				echo "DVD-Video ISO complete."
			else
				echo -n -e "33[1;31mFailed!"
				echo -e "33[0m"

				##MKISO failed to build ISO.
				echo "Failed to build ISO image."
				exit 6
			fi
		else
			echo -n -e "33[1;31mFailed!"
			echo -e "33[0m"

			##DVDAuthor, Step 2 failed.
			echo "Failed to finalize the DVD structure."
			exit 5
		fi
	else
		echo -n -e "33[1;31mFailed!"
		echo -e "33[0m"

		echo "Failed to build the initial DVD directory structure."
		exit 4
	fi
else
	echo -n -e "33[1;31mFailed!"
	echo -e "33[0m"

	##Conversion to MPEG2 failed.
	echo "Conversion of source video to an MPEG2 file failed."
	exit 3
fi

Changes:
v0.3: Bug fixes and revisions.
v0.2: Bug fixes and revisions.
v0.1: Initial release.