#! /bin/bash

## DVD Creator Script
## Written by Sreejith K, sreejithemk@gmail.com
## Visit, http://sreejithemk.net

echo "############## DVD Creator ##########" ;
read -p "DVD Name : " dvdname ;
read -p "Video path : " path ;
read -p "Temp Dir (Use /tmp ): " temp ;
read -p "Writing Speed (eg. 40x): " speed ;

echo "Converting $path to MPG format....." ;
ffmpeg -i $path -target dvd $temp/$dvdname.mpg ;
echo "Conversion completed." ;

echo "Creating DVD image....." ;
dvdauthor -o $temp/dvd -m -t -f $temp/$dvdname.mpg ;
echo "Image creation completed." ;

echo "Writing DVD....." ;
growisofs -dvd-compat -speed=$speed -Z /dev/dvdrw -dvd-video $temp/dvd/ ;
echo "DVD Burning completed." ;
echo "Ejecting DVD....." ;

echo "Cleaning the temp files .. .... " ;
rm -r $temp/dvd ;
rm $temp/$dvdname.mpg ;

echo "DVD Creation Completed....." ;
echo ;
echo "DVD Creator Script" ;
echo "Written by Sreejith K, sreejithemk@gmail.com" ;
echo "Visit, http://sreejithemk.net" ;
read key ;
