#!/bin/bash # v20080221 # Florin Andrei if [ $# -ne "1" ]; then echo "Usage: $0 dirname" exit fi # Testing pre-requisites for exe in wine unix2dos mplex dvdauthor; do if [ -z `which ${exe}` ]; then echo "${exe} is not installed, bye" exit fi done name=$1 pushd $name # File that contains the DVD structure info xmlf="dvdauthor.xml" # The HC Encoder executable # Path is in Windows format (as seen inside Wine) encoder="C:\HCenc\HCenc.exe" aencoder="avs2yuv" # The Unix filesystem root is what "drive letter" under Wine? # (e.g., if drive is Z, then /home/user becomes Z:\home\user under Wine) rootdrive="Z" # pwd in "windows" format (replace / with \) unixpwd=`pwd` winepwd=`echo ${unixpwd} | tr / \\\ ` # HC Encoder general encoding parameters # Change ASPECT to 4:3 or 16:9, depending on the source # Change BITRATE up or down to adjust image quality and file size # The other parameters typically don't need to be adjusted cat - > HC.ini << HCINI *DBPATH ${rootdrive}:${winepwd} *MAXBITRATE 9500 *PROFILE best *AUTOGOP 15 *CQ_MAXBITRATE 5.000 *AQ 1 *DC_PREC 10 *DVSOURCE *NOSCD *MATRIX mpeg *LUMGAIN 1 *PRIORITY normal *WAIT 0 HCINI unix2dos HC.ini rm -f $xmlf # dvdauthor XML config head cat - >> $xmlf << XMLHEAD XMLHEAD max=`ls dv | wc -l` n=1 for inp in `ls dv`; do rem=$(( $max - $n )) echo echo -n "[" for i in `seq 1 $n`; do echo -n "+" done if [ $rem -ne 0 ]; then for i in `seq 1 $rem`; do echo -n "-" done fi echo "]" out=`basename $inp .avi` cat - > $out-video.avs << AVSFILE-VIDEO AviSource("${rootdrive}:${winepwd}\\dv\\${out}.avi") ConvertToYV12(interlaced=true) AVSFILE-VIDEO cat - > $out-audio.avs << AVSFILE-AUDIO AviSource("${rootdrive}:${winepwd}\\dv\\${out}.avi") ConvertToYV12(interlaced=true) SoundOut(output="ac3", filename="${rootdrive}:${winepwd}\\${out}.ac3", cbrrate=192, acmod=2, autoclose=true, wait=0, overwritefile="Yes", silentblock=false) AVSFILE-AUDIO unix2dos $out-video.avs unix2dos $out-audio.avs awinerun="wine ${aencoder} -frames 1 ${rootdrive}:${winepwd}\\${out}-audio.avs -o NUL" echo ${awinerun} `${awinerun}` winerun="wine ${encoder} -ini ${rootdrive}:${winepwd}\\HC.ini -i ${rootdrive}:${winepwd}\\${out}-video.avs -o ${rootdrive}:${winepwd}\\${out}.m2v -log ${rootdrive}:${winepwd}\\${out}.log -frames all" echo ${winerun} `${winerun}` mplex -f 8 -S 4400 $out.m2v $out.ac3 -o $out.vob 2>&1 | tee $out-mplex.log echo "" >> $xmlf n=$(( $n + 1 )) done # dvdauthor XML config tail cat - >> $xmlf << XMLTAIL XMLTAIL dvdauthor -o $name -x $xmlf chmod -R 0755 $name chmod 0644 $name/*_TS/* sync popd