#!/bin/bash # create dvd-iso from avi with .idx/.sub subtitles # requires: ffmpeg, dvdauthor, mkisofs, mencoder, mplayer USAGE="Usage: dvdiso [hi|low] " # This script doesn't work with MPlayer 1.0rc2! 1.0rc1 is fine, and can be installed locally: MPLAYER=~/install/MPlayer-1.0rc1/mplayer if [ $# -ne 3 ]; then echo $USAGE exit 1 fi QUALI=$1 BITRATE=$2 INFILE=$3 # detect movie aspect: aspect=`ffmpeg -i $INFILE.avi 2>&1 | grep "Stream\ #0.0"` aspect=`echo "$aspect" | sed "s/.* \([1-9][0-9]*\)x\([0-9]*\).*/\10000 \/ \2/"` aspect=$(( $aspect )) if [ $aspect -gt 20639 ]; then echo ">>> padding panavision to widescreen" aspect="16/9" scale="scale=720:432,expand=720:576" elif [ $aspect -lt 15555 ]; then aspect="4/3" scale="scale=720:576" else scale="scale=720:576" aspect="16/9" fi echo ">>> aspect: $aspect" # mencoder options: DVDFORMAT="-ovc lavc -of mpeg -mpegopts format=dvd:tsaf -vf $scale,harddup -ofps 25" AUDIO2CHAN="-srate 48000 -af lavcresample=48000 -oac lavc -lavcopts acodec=ac3:abitrate=192" if [ $QUALI = 'hi' ]; then QUAL="-lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=$BITRATE:keyint=15:aspect=$aspect:trell:mbd=2:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:cbp:mv0:vqmin=1:lmin=1:dc=10:vstrict=0" else QUAL="-lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:vbitrate=$BITRATE:keyint=15:aspect=$aspect:vstrict=0" fi # create named pipe and convert avi to mpeg with subtitles: if [ -e stream.yuv ]; then rm stream.yuv fi mkfifo stream.yuv echo '>>> creating audio track tmp_audio.wav' $MPLAYER "$INFILE.avi" -dumpaudio -dumpfile tmp_audio.wav echo '>>> converting avi to mpeg with vobsub subtitles' $MPLAYER "$INFILE.avi" -vobsub "$INFILE" -nosound -noframedrop -vo yuv4mpeg >> something went wrong: no tmp_video.mpeg found. Try a different MPlayer version?" exit fi echo ">>> creating dvd iso" dvdauthor -o ./tmp_dvd/ -t tmp_video.mpeg dvdauthor -o ./tmp_dvd/ -T rm tmp_video.mpeg mkisofs -dvd-video -o "$INFILE.iso" ./tmp_dvd rm -r ./tmp_dvd echo ">>> done."