Normal screen:
ffmpeg -i film.avi -aspect 4:3 -target pal-dvd dvd.mpg (or ntsc-dvd)
Wide screen:
ffmpeg -i film.avi -aspect 16:9 -target pal-dvd dvd.mpg (or ntsc-dvd)
Make dvd files without menu in a dvd/ folder:
dvdauthor -o dvd/ -t dvd.mpg
Just add several movies this way
File the movies before burning in /dvd :
dvdauthor -o dvd/ -T
Burn:
growisofs -Z /dev/dvd -dvd-video dvd/
A rewritable will be erased automatically.
Here is a script to somewhat automate this process, read it and make sure the settings are the way you want them, to make it executable save it as whatever.sh and do
chmod +x whatever.sh
to make it executable.
Run it as:
./whatever.sh /path/to/file_to_run.
I tried it and it seems to work fine with single files.
#!/bin/bash
#packages used: ffmpeg, dvdauthor, dvd+rw-tools
#TODO
#somehow do length/size detection and split onto multiple dvd’s
#port to VCD, SVCD#FIXME
#cannot fast-forward through tracks#Functions~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#run
#runs the command and prints it to stderr
#only prints if $dryrun=true
run(){
echo -n “>> ” > /dev/stderr
if ! $dryrun; then
echo “$@” | tee /dev/stderr | sh -
return $?
else
echo “$@”
return 0;
fi
}cleanup(){
if $cleanup && [ "$cleanuplist" ]; then
echo “# cleaning up…”
run rm -R $cleanuplist
fi
}#Aspect-Ratio detection~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
getaspect(){
#2.350000 =Panavision (235:100)
#2.063888
#1.777777 =Widescreen (16:9)
#1.555555
#1.333333 =Normal (4:3)#parses out `height x 10000 / width` from “ffmpeg -i”
#(no decimal numbers in bash)
aspect=`ffmpeg -i “$1″ 2>&1 | grep “Stream\ #0.0″`
aspect=`echo “$aspect” | sed “s/.* \([1-9][0-9]*\)x\([0-9]*\).*/\10000 \/ \2/”`
echo “>> $aspect”
aspect=$(( $aspect ))
if [ $aspect -gt 20639 ]; then
#dvdauthor does not understand panavision aspect ratio (2.35)
#we must pad the video into widescreen (16:9)
aspect=”16:9″;
pana=”-s 720×380 -padtop 50 -padbottom 50″;
echo “# $1 is Panavision”
elif [ $aspect -lt 15555 ]; then
aspect=”4:3″
echo “# $1 is Normal.”
else
aspect=”16:9″
echo “# $1 is Widescreen”
fi
}#Encoding~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encode(){
#TODO do a better checking for DVD format
for avi in “$@”; do
case $avi in
*.DVD.mpg )
echo “# $avi is in DVD format, skipping…”
mpglist=”$mpglist \”$avi\”";;
* )
mpg=`echo “$avi” | sed “s/\.[^.]*$//g”`
mpg=”$mpg.DVD.mpg”
mpglist=”$mpglist \”$mpg\”"if ! [ -f "$mpg" ]; then
echo “# Encoding $mpg…”
if run “ffmpeg -i \”$avi\” -target $standard-dvd -y \
-aspect $aspect $pana $name.temp.DVD.mpg”; then
run “mv $name.temp.DVD.mpg \”$mpg\”"
cleanuplist=”$cleanuplist \”$mpg\”"
else
echo “# ffmpeg ERROR WHILE ENCODING \”$avi\”"
exit 1
fi
else
echo “# $avi already encoded! Skipping…”
fi;;
esac
done
echo “# Encoding complete!”
}#Authoring~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
author(){
if run dvdauthor -o $dvddir -v $standard+$aspect $mpglist; then
cleanup;
cleanuplist=”\”$dvddir\”"
else
echo “# dvdauthor error”
exit 1;
fi
run dvdauthor -o “$dvddir” -T
}#ISO creation~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
image(){
if run mkisofs -dvd-video -o $iso $dvddir; then
cleanup
cleanuplist=”\”$iso\”"
else
echo “# ERROR: mkisofs”;
exit 1;
fi
#at this point you can view the iso with:
# mplayer dvd:// -dvd-device name.iso
}#Burn~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
burn(){
if run growisofs -Z /dev/hdb=$iso -speed=8; then
cleanup
cleanuplist=”"
else
echo “# ERROR: growisofs”
exit 1
fi
}#displays help and exits
showhelp(){
helptext
exit 1
}helptext(){
echo “Usage: `basename $0` [OPTIONS]… clip1.avi clip2.avi…” ;
echo “Convert each clip to .mpg, author to a folder, convert to .iso image,”;
echo “then finally burn to DVD.” ;
echo ” -n, –name base name for created files (recommended)” ;
echo ” -c, –cleanup will cleanup intermediate files” ;
echo ” -d, –dryrun will display but not execute commands”;
echo ” -h, –help show more options” ;
echo “”;
echo “Target options:”;
echo ” -e, –encode only encode the clips.”;
echo ” -a, –author stop after encoding and authoring the clips”;
echo ” -i, –image only create a .iso image of a DVD, no burning.”;
echo ” -b, –burn only burn the specified image, no processing”;
}morehelptext(){
echo “”;
echo “MORE OPTIONS:”;
echo ” -p, –pal the PAL tv standard will be used (default NTSC)”;
echo “”
echo “Aspect options: (automatic aspect detection by default)”;
echo ” –norm clips will be encoded to normal 4:3″;
echo ” –wide clips will be encoded to widescreen 16:9″;
echo ” –pana clips will be encoded to panavision 2.35″;
echo “”;
echo “Process control options:”;
echo ” –no-encode – do not create DVD-compatible clips”;
echo ” –no-author – do not create a DVD-format directory tree”
echo ” –no-image – do notcreate ISO image for burning”;
echo ” –no-burn – disable burning”;
}#Main~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Set defaults
encode=”true”
author=”true”
image=”true”
burn=”true”
dryrun=”false”
cleanup=”false”
standard=”ntsc” #TV standard to use#Option processing
if ! [ "$1" ]; then
showhelp
fiwhile [ "$#" -gt 0 ]; do
case $1 in
-h|–help) helptext; morehelptext; exit 0;;
-d|–dryrun ) echo “Doing a dry-run.”; dryrun=”true”; shift;;
-c|–cleanup ) echo “Will cleanup files.”; cleanup=”true”; shift;;
-p|–pal ) standard=”pal”; shift;;
–norm ) echo “Aspect set to Normal.”; aspect=”4:3″; shift;;
–wide ) echo “Aspect set to Widescreen.”; aspect=”16:9″; shift;;
–pana ) echo “Aspect set to Panavision.”; aspect=”16:9″;
pana=”-s 720×380 -padtop 50 -padbottom 50″; shift;;
–no-encode ) echo “Encoding disabled.”; encode=”false”; shift;;
–no-author ) echo “Authoring disabled.”; author=”false”; shift;;
–no-image ) echo “Imaging disabled.”; image=”false”; shift;;
–no-burn ) echo “Burning disabled.”; burn=”false”; shift;;
-e|–encode)
echo “Will only do encoding.”
burn=”false”; author=”false”; image=”false”; shift;;
-a|–author)
echo “Will only author DVD to ‘$name.dvd/’.”
burn=”false”; image=”false”; shift;;
-i|–image)
echo “Will create but not burn ‘$name.iso’.”
burn=”false”; shift;;
-b|–burn)
echo “Will only burn $2.”
iso=”$2″; burn; exit 0 ;;
-n|–name )
echo “Setting base name to ‘$2′.”
name=”$2″; dvddir=”$name.dvd”; iso=”$name.iso”; shift 2;;
-* ) echo “ERROR: option = $1″;showhelp;;
* ) break;;
esac
doneshift $(($OPTIND – 1)) #takes the processed options out of $@
#More defaults…
if ! [ "$name" ]; then
#basename for files to be created
#strips non-alphanumeric characters and the extension
name=`echo “$1″ | sed -e “s/\.[^.]*$//” -e “s/[^[:alnum:]]/./g”`
dvddir=”$name.dvd” #folder to put DVD in
iso=”$name.iso” #iso file to be created & burned
fi#main processing
if $encode; then
if ! [ "$aspect" ]; then
getaspect “$1″;
fi
encode “$@”
else
for mpg in “$@”; do
mpglist=”$mpglist \”$mpg\”"
done
fiif $author; then
author;
else
cleanuplist=”"
fiif $image; then
image ;
else
cleanuplist=”"
fiif $burn; then
burn;
fi
exit 0
When you say :
“Make dvd files without menu in a dvd/ folder:
dvdauthor -o dvd/ dvd.mpg”
It kept giving me an error saying I needed to include “-t, -m, or -x” so I tried doing
“dvdauthor -o SAW4/ -t SAW4 saw4.mpg”
but it kept giving me a segmentation fault error. I then looked up another how-to using a similar method and they used
“dvdauthor -o DVD/ -t final.mpg” and then “dvdauthor -o DVD/ -T”
that didn’t return any segmentation errors and then I finished using your growisofs command
Thanks for the how-to! I feel so accomplished now!
Comment by Max — February 20, 2008 @ 7:01 pm
” dvdauthor -o DVD/ -T
”
was missing in the initials description. Thanks for sharing.
To be somewhat more specific: Without the “dvdauthor -o DVD/ -T” command in my case
” growisofs -Z /dev/hdd -dvd-video dvd/
”
returns:
” Executing ‘genisoimage -dvd-video dvd/ | builtin_dd
write failed: Input/output error
of=/dev/hdd obs=32k seek=0′
I: -input-charset not specified, using utf-8 (detected
in locale settings)
genisoimage: No such file or directory. Failed to open
VIDEO_TS.IFO
genisoimage: Can’t open VMG info for ‘dvd/’.
genisoimage: Unable to parse DVD-Video structures.
genisoimage: Could not find correct ‘VIDEO_TS’
directory.
genisoimage: Unable to make a DVD-Video image.
Possible reasons:
– VIDEO_TS subdirectory was not found on specified
location
– VIDEO_TS has invalid contents
“
Comment by Hans — August 4, 2009 @ 8:17 am
uh, thanks for the code, but could you post it with tags or something around? It’s full of unicode..
Comment by k — August 8, 2008 @ 6:07 pm
root@socrates:/home/chris/makedvd$ growisofs -Z /dev/hdb -dvd-video dvd/
write failed: Input/output error
Executing ‘mkisofs -dvd-video dvd/ | builtin_dd of=/dev/hdb obs=32k seek=0′
Setting input-charset to ‘ISO-8859-1′ from locale.
mkisofs: No such file or directory. Failed to open ‘dvd//VIDEO_TS/VIDEO_TS.IFO’.
mkisofs: Can’t open VMG info for ‘dvd/’.
mkisofs: Unable to parse DVD-Video structures.
mkisofs: Could not find correct ‘VIDEO_TS’ directory.
mkisofs: Unable to make a DVD-Video image.
root@socrates:/home/chris/makedvd$ ls dvd/VIDEO_TS/
VTS_01_0.BUP VTS_01_0.IFO VTS_01_1.VOB VTS_01_2.VOB
Comment by chris — August 9, 2008 @ 11:22 am
Hi, thank you very much for your code.
But, when I try it I could this error message:
marcelo@laia:~/bin$ ./gravar_dvd.sh ~/português.avi
./gravar_dvd.sh: line 253: unexpected EOF while looking for matching `”‘
./gravar_dvd.sh: line 260: syntax error: unexpected end of file
marcelo@laia:~/bin$
Could you help me? If is possible, could you send de answer to my mail account?
Bests.
Comment by Marcelo — November 21, 2008 @ 2:06 pm
The topic is quite hot in the net right now. What do you pay the most attention to when choosing what to write ?
p.s. Year One is already on the Internet and you can watch it for free.
Comment by Watch Year One Online Free — June 20, 2009 @ 9:00 pm
Great tutorial, works perfectly today is 19 Ot 2009
Comment by Barry de Graaff — October 19, 2009 @ 5:00 pm