Inspired by a movable tripe blog post I came up with the following shell script to convert an AVI file to an ISO image that can be burned to disc and played back on a standard DVD player.
The script requires mencoder, ffmpeg, dvdauthor and mkisofs, and will let you know you if any of these are missing. Use it like follows:
./dvd.sh input.avi
Once the script has finished a "dvd.iso" file will be created, which can then be burned to DVD using your favourite disc burning tool.
#!/bin/bash
# AVI to DVD Script
# Ben Dowling - www.coderholic.com
# Change to "ntsc" if you'd like to create NTSC disks
format="pal"
# Check we have enough command line arguments
if [ $# != 1 ]
then
echo "Usage: $0 <input file>"
exit
fi
# Check for dependencies
missing=0
dependencies=( "mencoder" "ffmpeg" "dvdauthor" "mkisofs" )
for command in ${dependencies[@]}
do
if ! command -v $command &>/dev/null
then
echo "$command not found"
missing=1
fi
done
if [ $missing = 1 ]
then
echo "Please install the missing applications and try again"
exit
fi
function emphasise() {
echo ""
echo "********** $1 **********"
echo ""
}
# Check the file exists
input_file=$1
if [ ! -e $input_file ]
then
echo "Input file not found"
exit
fi
emphasise "Converting AVI to MPG"
ffmpeg -i ${input_file} -y -target ${format}-dvd -sameq -aspect 16:9 finalmovie.mpg
if [ $? != 0 ]
then
emphasise "Conversion failed"
exit
fi
emphasise "Creating DVD contents"
dvdauthor --title -o dvd -f finalmovie.mpg
first=$?
dvdauthor -o dvd -T
second=$?
if [ $first != 0 || $second != 0 ]
then
emphasise "DVD Creation failed"
exit
fi
emphasise "Creating ISO image"
mkisofs -dvd-video -o dvd.iso dvd/
if [ $? != 0 ]
then
emphasise "ISO Creation failed"
exit
fi
# Everything passed. Cleanup
rm -f finalmovie.mpg
rm -rf dvd/
emphasise "Success: dvd.iso image created"