#!/bin/sh

# We clean up unnecessary files
# and make the necessary directories.
rm -r dvd dvd.iso
mkdir dvd
mkdir dvd/VIDEO_TS

# We make a DVD image here.
# This part has been taken from the
# writedvd script that goes with the dvdauthor tools.
# At first the IFO file is made and the table of contents.
# Finally the image itself is made with 'mkisofs'
cp $1 dvd/VIDEO_TS/VTS_01_1.VOB
chmod u+w dvd/VIDEO_TS/*.VOB
cd dvd/VIDEO_TS
ifogen ../../$1 -o ./VTS > VTS_01_0.IFO
tocgen . > VIDEO_TS.IFO
(cd dvd/VIDEO_TS; for i in *.IFO; do cp $i `basename $i .IFO`.BUP; done)
cd ../..
mkisofs -dvd-video -udf -o dvd.iso dvd/

# Here we burn the DVD on a DVD+RW
# Leave the comment signs before the dvd+rw-format line
# if your DVD is already formatted and does not contain any data.
# Remove them if you must format the disk.
# Remarkably enough these lines also work with an Imation -RW DVD! (???)
# dvd+rw-format -f /dev/scd0
# growisofs -Z /dev/scd0=dvd.iso

# Burns a DVD on a DVD-RW
# Remove the comment signs if you use such a drive
# Check the devicenumber with 'cdrecord -scanbus'
# Unfortunately I did not manage to get this piece working ;-((
# dvdrecord -dao speed=2 dev=1,0,0 dvd.iso

