Automated AVS Script to DVD Conversion

This is a relatively simple script that takes any properly formatted AVISynth script and turns it into a valid DVD image ready to burn using DVD Decrypter or your favorite burning application.

If you have ever wanted to take a directory of AVS scripts and turn them into DVDs without having to hand-hold the process, then this script is for you. If you’re looking for all the appropriate Win32 tools that let you do each step of this process through the command line, then this is also the place for you. If you’re looking for a guide on how to use these tools then this is not for you as this isn’t a guide.  There are plenty of wonderful guides at Doom9. Look to this thread on Doom9 for other useful links to AVISynth command line apps and discussions.

UPDATE 10/12/05: Now that QuEnc is quite stable and produces reliable multiplexed audio, AVS2WAV, Quelcom, BeSweet and MPlex are no longer necessary to this batch. They are useful tools to have around however.

Here are the tools you need: (if any links are broken email me)

  • AVISynth – Version 2.55
    The most important part of this.
  • QuEnc – Version 0.61
    An absolutely awesome command line launched AVS to MPEG encoder.
  • DVDAuthor – v0.6.9
    Allows for authoring of compliant MPEG streams via an XML document.
  • CDRTools – v2.01a32
    Specifically you need the win32 version of mkisofs which lets you build proper UDF images for DVD video.

That’s the tools… now here is the batch:
(IMPORTANT: This script ONLY runs in Win2k or XP)

@set batchbin=C:\Library\bin
@set avisynth=%batchbin%\avisynth
@set quenc=%batchbin%\QuEnc
@set DVDAuthor=%batchbin%\DVDAuthor
@set cdrtools=%batchbin%\cdrtools
@SET QBitrate=5250
@SET QMaxBitrate=8000
@SET QPasses=1
@SET QGOPSize=15
@SET QMaxBFrames=3
@SET QAspectRatio=4:3
@SET QAudioCodec=AC3
@SET QAudioBitrate=384
@SET QField=t
@REM Set to b for bottom field first or t for top field first, ignore if not interlaced
@REM Leave QHQ blank if you want High Quality turned on, otherwise set it to no
@REM Leave QVBR blank if you want VBR turned on, otherwise set it to no
@REM Leave QSCENE blank if you want Scene Detection turned on, otherwise set it to no
@REM Leave QTRELL blank if you want Trellis Quant turned on, otherwise set it to no
@REM Leave QCGOP blank if you want to use Closed GOP, otherwise set it to no
@SET QInterlace=
@REM Leave QInterlace blank if you want to use Interlaced Encoding, otherwise set it to no
@SET QExtreme=no
@REM Leave QExtreme blank if you want to use Extreme encoding, otherwise set it to no
@SET QCMatrix=no
@SET QCMatrixFile=
@REM If you wish to use a Custom Matrix, leave QCMatrix blank and add your file path to QCMatrixFile,
@REM otherwise set QCMatrix to no, and leave QCMatrixFile blank.
@SET QCMD=-auto -close
@REM Use for additional parameters such as Silent, Auto, Close and Shutdown
FOR /F "usebackq delims==" %%y IN (`dir /b *.avs`) DO (
@REM Compress AVS file to M2V using QuENC
%quenc%\quenc.exe -i "%%~ny.avs" -o "%%~ny.mpg" -b %QBitrate% -maxbitrate %QMaxBitrate% -dc %QDC% -%QPasses% -mpeg%QMPEGType% -%QHQ%hq -%QVBR%vbr -%QSCENE%scene -%QTRELL%trell -%QCGOP%cgop -%QInterlace%interlaced -%QExtreme%extreme -gopsize %QGOPSize% -maxbframes %QMaxBFrames% -%QCMatrix%cmatrix %QCMatrixFile% -aspectratio %QAspectRatio% -mpeg2mux %QMPEG2MuxProfile% -audiocodec %QAudioCodec% -audiobitrate %QAudioBitrate% -%QField%ff %QCMD%
@REM Build XML File for DVD Author
echo ^<dvdauthor^> > "%%~ny.xml"
echo ^<vmgm /^> >> "%%~ny.xml"
echo ^<titleset^> >> "%%~ny.xml"
echo ^<titles^> >> "%%~ny.xml"
echo ^<pgc^> >> "%%~ny.xml"
echo ^<vob file="%%~ny.mpg" /^> >> "%%~ny.xml"
echo ^<post^> >> "%%~ny.xml"
echo jump chapter 1; >> "%%~ny.xml"
echo ^</post^> >> "%%~ny.xml"
echo ^</pgc^> >> "%%~ny.xml"
echo ^</titles^> >> "%%~ny.xml"
echo ^</titleset^> >> "%%~ny.xml"
echo ^</dvdauthor^> >> "%%~ny.xml"
@REM Author DVD from XML. DVD will be created in a directory the same name as the AVS
%dvdauthor%\dvdauthor -o "%%~ny" -x "%%~ny.xml"
@REM Create ISO Image from VOB Folder
%cdrtools%\mkisofs -dvd-video -o "%%~ny.img" "%%~ny"
@REM Remove the VOB folder and clean up
if exist "%%~ny.img" rmdir /S /Q "%%~ny"
if exist "%%~ny.img" del "%%~ny.xml"
if exist "%%~ny.img" del "%%~ny.mpg"



Obviously some changes will be necessary if you wish to have different compression settings from QuEnc or have files go to different places. All in all you should be able to get this to work with only minor tweaks to your specific needs. The biggest issue I see is the XML generation for DVDAuthor. For my needs, chapter points and menus are unnecessary. However if you want them just take out the entire ECHO section and simply create your XML file prior to starting the batch. The DVDAuthor website is fairly thorough in how to create these documents.That should do it. Hopefully you’ll find this helpful. Enjoy!

No comments yet.

Leave a Reply