avi2dvd

Convert .avi files to a DVD.

Introduction

Converting the AVI to a format dvdauthor understands

Warning: The sound in the resulting mpg will be crap with these settings. Any idea what’s wrong?

#!/bin/bash

# sudo apt-get install transcode mplayer mjpegtools ffmpeg dvdauthor 

if [ $# -ne 2 ]; then

    echo "Usage: avi2dvd.sh <avifile> <outbase>"
    exit 1

fi

echo
echo "*************** processing $AVIFILE ***************"
echo

AVIFILE=$1
OUTBASE=$2

du -hs $AVIFILE


echo
echo "*************** transcode to m2v and ac3 ***************"
echo

M2VFILE=$OUTBASE.m2v
AC3FILE=$OUTBASE.ac3


[[ ! -e $OUTBASE.m2v && ! -e $OUTBASE.ac3 ]] && 
    nice -19 transcode -i $AVIFILE -y ffmpeg --export_prof dvd-pal --export_asr 3 
    -o $OUTBASE -D0 -s2 -m $AC3FILE -J modfps=clonetype=3 
    --export_fps 25 
    || echo "Skipping transcode."

du -hcs $M2VFILE $AC3FILE


echo
echo "*************** tcextract to 5.1 sound (if available) ***************"
echo

AC351FILE=$OUTBASE-51.ac3

if mplayer -vo dummy -identify $AVIFILE 2>/dev/null | grep -q "5.1 ("; then
    echo "Cool, we have 5.1 sound!"
    [[ ! -e $AC351FILE ]] && 
	(nice -19 tcextract -d2 -i $AVIFILE -a0 -x ac3 
	| nice -19 tcextract -d2 -x ac3 -t raw > $AC351FILE ) 
	|| echo "Skipping tcextract."
    AUDIOFILE=$AC351FILE
else
    AUDIOFILE=$AC3FILE
fi



echo
echo "*************** mplex to mpg ***************"
echo

MPGFILE=$OUTBASE.mpg



[[ ! -e $MPGFILE ]] && 
    nice -19 mplex -f 8 -o $MPGFILE $M2VFILE $AUDIOFILE 
    || echo "Skipping mplex."


echo
echo "*************** done ***************"
echo
du -hs $MPGFILE



# eof

Postprocessing

<dvdauthor dest="DVD">
  <vmgm />
  <titleset>
    <titles>
      <pgc>
        <vob file="movie.mpg" chapters="0,15:00,30:00,45:00,1:00:00"/>
      </pgc>
    </titles>
  </titleset>
</dvdauthor>
dvdauthor -x dvdauthor.xml
xine dvd:/full/path/to/DVD/VIDEO_TS/

or

mplayer dvd:// -dvd-device ./DVD
growisofs -Z /dev/dvd -dvd-video DVD/

Other Tools

dvd2avi