#! /bin/bash

# CD-CD copy - cdrdao copy --source-device /dev/hdb --device /dev/hda
# Modified by Jos Collin

read -p "VCD Name : " vcdname ;
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 ntsc-vcd $temp/$vcdname.mpg ;
echo "Conversion completed." ;

echo "Creating VCD image....." ;
vcdimager -l "$vcdname" -b $temp/vcd.bin -c $temp/vcd.cue $temp/$vcdname.mpg ;
echo "Image creation completed." ;

echo "Writing VCD....." ;
cdrdao write --device /dev/cdrw --driver generic-mmc-raw --speed $speed --eject $temp/vcd.cue ;
echo "VCD Burning completed." ;
echo "Ejecting VCD....." ;

echo "Cleaning the temp files .. .... " ;
rm $temp/vcd.bin ;
rm $temp/vcd.cue ;
rm $temp/$vcdname.mpg ;

echo "VCD Creation Completed....." ;
read key ;
