Command line batch conversion to Xvid

vbimport

#1

I’ve recently created a batch file to convert MKV (AVC) video files to standalone compatible AVI (Xvid). I thought I’d share my results with you since it took quite a bit of time and effort to get it working, and the method is readily adaptable for other formats.

Tools required:

My first batch file is very simple. All it does is iterate through all the MKV files in a folder and then calls the second batch file with parts of each filename:


@echo off
rem change R: to the drive letter of your source disk
R:

rem change \cdtemp\cbb to the path to your source folder
cd "\cdtemp\cbb"

rem change *.mkv to match the files that you want to process
for %%a in (*.mkv) do call "d:\cdtemp\batch\mkv2avi.bat" %%~da %%~pa %%~na

%%~da is the drive letter of the file (e.g. R: )
%%~pa is the path to the file (e.g. \cdtemp\cbb)
%%~na is the name of the file without the extension (e.g. episode1)

The second batch file does all the work:


@echo off
rem %1 is drive letter, %2 is path, %3 is the name of the file minus the extension
if "%1"=="D:" set otherdrive=R:
if "%1"=="R:" set otherdrive=D:

rem demux video, audio and first subtitles (N.B. check stream ids with MediaInfo)
"D:\avtools\MKVtoolnix\mkvextract.exe" tracks "%1%2%3.mkv" 1:"%otherdrive%\cdtemp\cbb\%3.h264" 2:"%otherdrive%\cdtemp\cbb\%3.ac3" 3:"%otherdrive%\cdtemp\cbb\%3.ass"

rem dgindex video
"D:\avtools\dgavcdec\dgavcindex.exe" -i "%otherdrive%\cdtemp\cbb\%3.h264" -o "%1\cdtemp\cbb\%3.dga" -e

rem create avs file
echo loadplugin("D:\avtools\dgavcdec\DGAVCDecode.dll") > "%1\cdtemp\cbb\%3.avs"
echo loadplugin("D:\apps\AviSynth 2.5\plugins\VSFilter.dll") >> "%1\cdtemp\cbb\%3.avs"
echo AVCSource("%1\cdtemp\cbb\%3.dga") >> "%1\cdtemp\cbb\%3.avs"
echo TextSub("%otherdrive%\cdtemp\cbb\%3.ass") >> "%1\cdtemp\cbb\%3.avs"

rem xvid encoding
rem first pass
"d:\avtools\xvid_encraw.exe" -i "%1\cdtemp\cbb\%3.avs" -type 2 -o "%otherdrive%	mp
ull" -pass1 -framerate 23.976 -progress 24

rem second pass
"d:\avtools\xvid_encraw.exe" -i "%1\cdtemp\cbb\%3.avs" -type 2 -o "%1\cdtemp\cbb\%3.avi" -pass2 -framerate 23.976 -bitrate 1250 -quality 6 -vhqmode 4 -bvhq -qtype 1 -nopacked -notrellis -imin 1 -bmin 1 -pmin 1 -progress 24

rem mux video and audio
rem thanks to celtic_druid for this script (http://forum.doom9.org/archive/index.php/t-124626.html)
setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS

set TMPAMG=d:	mp\%3.amg

set SRCVFN=%1\cdtemp\cbb\%3.avi
set SRCAFN=%otherdrive%\cdtemp\cbb\%3.ac3
set MUXFLN=%otherdrive%\cdtemp\cbb\%3.avi

echo CLEAR > "!TMPAMG!"
echo LOAD !SRCVFN!>> "!TMPAMG!"
echo LOAD !SRCAFN!>> "!TMPAMG!"
echo SELECT FILE 1 >> "!TMPAMG!"
echo ADD VIDEOSOURCE >> "!TMPAMG!"
echo SET OUTPUT OPTIONS >> "!TMPAMG!"
echo WITH SET OPTION >> "!TMPAMG!"
echo OVERWRITEDLG 0 >> "!TMPAMG!"
echo CLOSEAPP 1 >> "!TMPAMG!"
echo DONEDLG 0 >> "!TMPAMG!"
echo MAXFILES OFF >> "!TMPAMG!"
echo STDOUTPUTFMT AVI >> "!TMPAMG!"
echo AVI ADDJUNKBEFOREHEADERS 0 >> "!TMPAMG!"
echo AUDIO INTERLEAVE 4 FR >> "!TMPAMG!"
echo PRELOAD 200 >> "!TMPAMG!"
echo AVI HAALIMODE 0 >> "!TMPAMG!"
echo OPENDML 0 >> "!TMPAMG!"
echo LEGACY 0 >> "!TMPAMG!"
echo RECLISTS 0 >> "!TMPAMG!"
echo END WITH>> "!TMPAMG!"
echo START !MUXFLN!>> "!TMPAMG!"
"D:\avtools\AVI-Mux_GUI\AVIMux_GUI.exe" "%TMPAMG%"
ENDLOCAL

  • I’ve swapped between two hard drives (D: and R: ) for better performance. If you only have one, then set otherdrive=%1 at the start of the script. The script also assumes that the folder structure has been created on both drives.
  • Use mp4box instead of mkvextract to demux mp4 files.
  • The MKV files that I wanted to convert contain H264 video, hence the use of DGAVCDec. A simple change to DGMPGDec (DGIndex) and you can use mpeg2 video as your source.
  • Since it uses an avs file as input to the Xvid encoding process, you can use the full power of AviSynth to modify your input video simply by adding lines to the script (Crop, LanczosResize etc.).
  • I tried various tools to mux the final avi (mencoder, ffmpeg) but in the end I found that AVI-Mux_GUI was the only one that produced standalone compatible output. Thanks go to celtic_druid at doom9 for the muxing script.

I hope this might be of use to some of you; I’m between jobs at the moment so may well carry on tinkering with it and make it more general. Who knows, it might even turn into a distributable package… :wink:

Slà inte

midders


#2

I couldn’t sleep, so I’ve tidied the batch files up a bit :slight_smile: I’ve only tested these ones with a dry run (using echo commands to show the output) so there may be minor glitches.

convert.bat:

@echo off
rem Source details
set src_drive=R:
set src_path=\cdtemp\cbb\
set src_files=mkv

rem Destination details
set dst_drive=D:
set dst_path=\cdtemp\cbb\

if "%temp%"=="" set temp=c:\windows	emp

rem Application paths and AviSynth plugins
set convert_aux=D:\cdtemp\batch\convert_aux.bat
set mkvextract=D:\avtools\MKVtoolnix\mkvextract.exe
set dgavcindex=D:\avtools\dgavcdec\dgavcindex.exe
set xvid_encraw=D:\avtools\xvid_encraw.exe
set avimux_gui=D:\avtools\AVI-Mux_GUI\AVIMux_GUI.exe
set dgavc_plugin=D:\avtools\dgavcdec\DGAVCDecode.dll
set vsfilter_plugin=D:\apps\AviSynth 2.5\plugins\VSFilter.dll

rem change to src drive
%src_drive%

rem change to src path
cd %src_path%

rem loop through matching files
for %%a in (*.%src_files%) do call "%convert_aux%" %%~na
pause

convert_aux.bat:

@echo off
rem demux video, audio and first subtitles
"%mkvextract%" tracks "%src_drive%%src_path%%1.%src_files%" 1:"%dst_drive%%dst_path%%1.h264" 2:"%dst_drive%%dst_path%%1.ac3" 3:"%dst_drive%%dst_path%%1.ass"

rem dgindex video
"%dgavcindex%" -i "%dst_drive%%dst_path%%1.h264" -o "%src_drive%%src_path%%1.dga" -e

rem create avs file
echo loadplugin("%dgavc_plugin%") > "%src_drive%%src_path%%1.avs"
echo loadplugin("%vsfilter_plugin%") >> "%src_drive%%src_path%%1.avs"
echo AVCSource("%src_drive%%src_path%%1.dga") >> "%src_drive%%src_path%%1.avs"
echo TextSub("%dst_drive%%dst_path%%1.ass") >> "%src_drive%%src_path%%1.avs"
echo LanczosResize(720,458) >> "%src_drive%%src_path%%1.avs"

rem xvid encoding
rem first pass
"%xvid_encraw%" -i "%src_drive%%src_path%%1.avs" -type 2 -o "%temp%
ull" -pass1 -framerate 23.976 -progress 24

rem second pass
"%xvid_encraw%" -i "%src_drive%%src_path%%1.avs" -type 2 -o "%src_drive%%src_path%%1.avi" -pass2 -framerate 23.976 -bitrate 1250 -quality 6 -vhqmode 4 -bvhq -qtype 1 -nopacked -notrellis -imin 1 -bmin 1 -pmin 1 -progress 24

rem mux video and audio
set TMPAMG=%temp%\%1.amg
set SRCVFN=%src_drive%%src_path%%1.avi
set SRCAFN=%dst_drive%%dst_path%%1.ac3
set MUXFLN=%dst_drive%%dst_path%%1.avi

echo CLEAR > "%TMPAMG%"
echo LOAD %SRCVFN%>> "%TMPAMG%"
echo LOAD %SRCAFN%>> "%TMPAMG%"
echo SELECT FILE 1 >> "%TMPAMG%"
echo ADD VIDEOSOURCE >> "%TMPAMG%"
echo SET OUTPUT OPTIONS >> "%TMPAMG%"
echo WITH SET OPTION >> "%TMPAMG%"
echo OVERWRITEDLG 0 >> "%TMPAMG%"
echo CLOSEAPP 1 >> "%TMPAMG%"
echo DONEDLG 0 >> "%TMPAMG%"
echo MAXFILES OFF >> "%TMPAMG%"
echo STDOUTPUTFMT AVI >> "%TMPAMG%"
echo AVI ADDJUNKBEFOREHEADERS 0 >> "%TMPAMG%"
echo AUDIO INTERLEAVE 4 FR >> "%TMPAMG%"
echo PRELOAD 200 >> "%TMPAMG%"
echo AVI HAALIMODE 0 >> "%TMPAMG%"
echo OPENDML 0 >> "%TMPAMG%"
echo LEGACY 0 >> "%TMPAMG%"
echo RECLISTS 0 >> "%TMPAMG%"
echo END WITH>> "%TMPAMG%"
echo START %MUXFLN%>> "%TMPAMG%"
"%avimux_gui%" "%TMPAMG%"

rem delete temp and intermediate files
del /f "%temp%
ull"
del /f "%temp%\%1.amg"
del /f "%dst_drive%%dst_path%%1.h264"
del /f "%dst_drive%%dst_path%%1.ac3"
del /f "%dst_drive%%dst_path%%1.ass"
del /f "%src_drive%%src_path%%1.dga"
del /f "%src_drive%%src_path%%1.avs"
del /f "%src_drive%%src_path%%1.avi"


#3

More tidying up, and better logging. Also changed ‘call’ command to ‘start /low /wait’ for better windows performance during encoding:

convert.bat:

@echo off
rem LOGFILE
set LOGFILE=D:\cdtemp\cbb\cbb.log
echo [%time%] Convert started. >%LOGFILE%

rem Source details
set SRC_DRIVE=R:
set SRC_PATH=\cdtemp\cbb\
set SRC_FILES=mkv
echo [%time%] Source = %SRC_DRIVE%%SRC_PATH%*.%SRC_FILES% >>%LOGFILE%

rem Destination details
set DST_DRIVE=D:
set DST_PATH=\cdtemp\cbb\
echo [%time%] Destination = %DST_DRIVE%%DST_PATH% >>%LOGFILE%

if "%temp%"=="" set temp=c:\windows	emp
echo [%time%] temp = %temp% >>%LOGFILE%


rem Application paths and AviSynth plugins
set CONVERT_AUX=D:\cdtemp\batch\convert_aux.bat
set MKVEXTRACT=D:\avtools\MKVtoolnix\mkvextract.exe
set DGAVCINDEX=D:\avtools\dgavcdec\dgavcindex.exe
set XVID_ENCRAW=D:\avtools\xvid_encraw.exe
set AVIMUX_GUI=D:\avtools\AVI-Mux_GUI\AVIMux_GUI.exe
set DGAVC_PLUGIN=D:\avtools\dgavcdec\DGAVCDecode.dll
set VSFILTER_PLUGIN=D:\apps\AviSynth 2.5\plugins\VSFilter.dll
echo [%time%] convert_aux = %CONVERT_AUX% >>%LOGFILE%
echo [%time%] mkvextract = %MKVEXTRACT% >>%LOGFILE%
echo [%time%] dgavcindex = %DGAVCINDEX% >>%LOGFILE%
echo [%time%] xvid_encraw = %XVID_ENCRAW% >>%LOGFILE%
echo [%time%] avimux_gui = %AVIMUX_GUI% >>%LOGFILE%
echo [%time%] dgavc_plugin = %DGAVC_PLUGIN% >>%LOGFILE%
echo [%time%] vsfilter_plugin = %VSFILTER_PLUGIN% >>%LOGFILE%

rem change to src drive
%SRC_DRIVE%

rem change to src path
cd %SRC_PATH%

rem loop through matching files
for %%a in (*.%SRC_FILES%) do start /low /wait "%CONVERT_AUX%" %%~na
pause

convert_aux.bat:

@echo off
echo [%time%] Processing %1... >>%LOGFILE%
set SRCFILE=%SRC_DRIVE%%SRC_PATH%%1.mkv
set H264FILE=%DST_DRIVE%%DST_PATH%%1.h264
set AC3FILE=%DST_DRIVE%%DST_PATH%%1.ac3
set ASSFILE=%DST_DRIVE%%DST_PATH%%1.ass
set DGAFILE=%SRC_DRIVE%%SRC_PATH%%1.dga
set AVSFILE=%SRC_DRIVE%%SRC_PATH%%1.avs
set TMPAVI=%temp%
ull
set XVIDSTATS=%temp%\xvid.stats
set XVIDFILE=%SRC_DRIVE%%SRC_PATH%%1_video.avi
set TMPAMG=%temp%\%1.amg
set AVIFILE=%DST_DRIVE%%DST_PATH%%1.avi
set XVIDENCOPTS=-type 2 -framerate 23.976 -bitrate 1250 -quality 6 -vhqmode 4 -bvhq -qtype 1 -nopacked -notrellis -imin 1 -bmin 1 -pmin 1 -progress 24
echo [%time%] SRCFILE = %SRCFILE% >>%LOGFILE%
echo [%time%] H264FILE = %H264FILE% >>%LOGFILE%
echo [%time%] AC3FILE = %AC3FILE% >>%LOGFILE%
echo [%time%] ASSFILE = %ASSFILE% >>%LOGFILE%
echo [%time%] DGAFILE = %DGAFILE% >>%LOGFILE%
echo [%time%] AVSFILE = %AVSFILE% >>%LOGFILE%
echo [%time%] TMPAVI = %TMPAVI% >>%LOGFILE%
echo [%time%] XVIDSTATS = %XVIDSTATS% >>%LOGFILE%
echo [%time%] XVIDFILE = %XVIDFILE% >>%LOGFILE%
echo [%time%] XVIDENCOPTS = %XVIDENCOPTS% >>%LOGFILE%
echo [%time%] TMPAMG = %TMPAMG% >>%LOGFILE%
echo [%time%] AVIFILE = %AVIFILE% >>%LOGFILE%

rem demux video, audio and first subtitles
echo [%time%] Demuxing %1... >>%LOGFILE%
"%MKVEXTRACT%" tracks "%SRCFILE%" 1:"%H264FILE%" 2:"%AC3FILE%" 3:"%ASSFILE%"
echo [%time%] Done. >>%LOGFILE%

rem dgindex video
echo [%time%] Indexing %1... >>%LOGFILE%
"%DGAVCINDEX%" -i "%H264FILE%" -o "%DGAFILE%" -e
echo [%time%] Done. >>%LOGFILE%

rem create avs file
echo [%time%] Creating AVS Script >>%LOGFILE%
echo loadplugin("%DGAVC_PLUGIN%") > "%AVSFILE%"
echo loadplugin("%VSFILTER_PLUGIN%") >> "%AVSFILE%"
echo AVCSource("%DGAFILE%") >> "%AVSFILE%"
echo TextSub("%ASSFILE%") >> "%AVSFILE%"
rem echo LanczosResize(720,458) >> "%AVSFILE%"
echo [%time%] Done. >>%LOGFILE%

rem xvid encoding
rem first pass
echo [%time%] Xvid encoding (first pass)... >>%LOGFILE%
"%XVID_ENCRAW%" -i "%AVSFILE%" -o "%TMPAVI%" -pass1 "%XVIDSTATS%" %XVIDENCOPTS%
echo [%time%] Done. >>%LOGFILE%

rem second pass
echo [%time%] Xvid encoding (second pass)... >>%LOGFILE%
"%XVID_ENCRAW%" -i "%AVSFILE%" -o "%XVIDFILE%" -pass2 "%XVIDSTATS%" %XVIDENCOPTS%
echo [%time%] Done. >>%LOGFILE%

rem mux video and audio
echo [%time%] Creating AMG Script >>%LOGFILE%
echo CLEAR > "%TMPAMG%"
echo LOAD %XVIDFILE%>> "%TMPAMG%"
echo LOAD %AC3FILE%>> "%TMPAMG%"
echo SELECT FILE 1 >> "%TMPAMG%"
echo ADD VIDEOSOURCE >> "%TMPAMG%"
echo SET OUTPUT OPTIONS >> "%TMPAMG%"
echo WITH SET OPTION >> "%TMPAMG%"
echo OVERWRITEDLG 0 >> "%TMPAMG%"
echo CLOSEAPP 1 >> "%TMPAMG%"
echo DONEDLG 0 >> "%TMPAMG%"
echo MAXFILES OFF >> "%TMPAMG%"
echo STDOUTPUTFMT AVI >> "%TMPAMG%"
echo AVI ADDJUNKBEFOREHEADERS 0 >> "%TMPAMG%"
echo AUDIO INTERLEAVE 4 FR >> "%TMPAMG%"
echo PRELOAD 200 >> "%TMPAMG%"
echo AVI HAALIMODE 0 >> "%TMPAMG%"
echo OPENDML 0 >> "%TMPAMG%"
echo LEGACY 0 >> "%TMPAMG%"
echo RECLISTS 0 >> "%TMPAMG%"
echo END WITH>> "%TMPAMG%"
echo START %AVIFILE%>> "%TMPAMG%"
echo Done. >>%LOGFILE%
echo [%time%] Muxing... >>%LOGFILE%
"%AVIMUX_GUI%" "%TMPAMG%"
echo [%time%] Done. >>%LOGFILE%

rem delete temp and intermediate files
echo [%time%] Deleting intermediary files... >>%LOGFILE%
del /f "%TMPAVI%"
del /f "%TMPAMG%"
del /f "%XVIDSTATS%"
del /f "%H264FILE%"
del /f "%AC3FILE%"
del /f "%ASSFILE%"
del /f "%DGAFILE%"
del /f "%AVSFILE%"
del /f "%XVIDFILE%"
echo [%time%] Done. >>%LOGFILE%
echo [%time%] Finished %1. >>%LOGFILE%


#4
  • fixed a bug with the start command (it assumes the first argument in quotes is the title of the window!).
  • added debug mode (alter STARTCMD var in convert.bat)
  • added process priority control via PRIORITY var /LOW, /NORMAL, /HIGH, /REALTIME, /ABOVENORMAL, /BELOWNORMAL
  • added option to save or delete temp files DELFILES=YES/NO
  • preserved XVID.STATS for each file in case of repeat processing
  • some more tidying up, capitalisation etc.

convert.bat.txt (2.03 KB)

convert_aux.bat.txt (3.41 KB)


#5
  • allows spaces in filename stem
  • basic error checking and resume from wherever the process failed
  • MP4 and MKV support (MKV assumes AVC,AC3,[ASS]) (MP4 can be AVC,AC3 or AAC)
  • command line syntax: _convert [mkv|mp4 [dest path]] e.g.
    _convert mkv d: emp (converts all mkv files to d: emp)
    _convert mp4 (converts all mp4 files to same dir)
    _convert (converts all mkv files to same dir)

_convert.bat.txt (2.46 KB)

convert_aux.bat.txt (6.3 KB)


#6

This represents a major change in the way that the tool works; hence I have renamed it to MakeAVI.bat.

  • MakeAVI will now generate a batch file to process all MKV, MP4 and MPG files in the current directory, along with corrsponding AVS (AVISynth) and AMG (AVIMuxGUI) scripts.
  • usage: MakeAVI [dest path] [AUTORUN] e.g.:
    MakeAVI
    (with no args destination is current folder)
    MakeAVI d: mp
    (destination set to d: mp)
    MakeAVI “d: mp\working folder 0” AUTORUN
    (destination set to “d: mp\working folder 0”, batch file will be started automatically after creation)
    N.B. the destination path must exist
  • support for MKV (AVC with AC3), MP4 (AVC with DTS or AC3), and MPG files (all video codecs with MPA)
  • by default the batch file won’t run allowing you to modify the AVS script and any other command line options as you desire.
  • a shutdown command is appended to the end of the batch script; delete this if you don’t want to shutdown after processing. If the shutdown window pops up then you have 30 seconds to disable it by running ‘shutdown -a’
  • error checking: if any process fails to produce the expected file then an error will be logged and processing will move to the next input file
  • resume partially completed conversions; just delete any partial files and run the generated batch file again. No existing files will be overwritten.
  • example batch file “[11h50_25] BuildAll.bat”
  • example log file “[11h50_25] MakeAVI.log”
  • N.B. keep the logfile until BuildAll.bat has completed since this is where progress will be logged

Two new tools are required for mpg support:
FFMpeg
DGMPGDec

MakeAVI.bat.txt (2.71 KB)

_MakeAVI.bat.txt (12.4 KB)

[12h06_35] BuildAll.bat.txt (15.8 KB)

[12h06_35] MakeAVI.log.txt (2.03 KB)


#7

Bugfix

  • drop through to MPG processing from MKV/MP4 stream fixed

_MakeAVI.bat.txt (12.4 KB)


#8

Bugfix

  • multiple bugs in MPG stream fixed. So much for testing :wink:

_MakeAVI.bat.txt (12.5 KB)


#9

Another update; I suppose I should start using version numbers!

  • command line changed:
    MakeAVI [“source file(s)”] [“output path”] [bit rate] [SHUTDOWN]
    All parameters are optional, but you must include all preceding parameters. i.e. to specify a bit rate you must also include source file(s) and output path.
  • FLV support added (requires FLVExtract)
  • m2v support added to mpg stream (this assumes that a matching mp2 audio file is in the source folder). Useful for encoding DVB streams after processing with ProjectX/Mpeg2Schnitt.
  • improvements to error-checking and resuming after interruption/failure
  • existing AMG or AVS scripts will no longer be overwritten.
  • if you want any particular file to be regenerated just delete it before running the batch file again

_MakeAVI.bat.txt (16.7 KB)

MakeAVI.bat.txt (3.18 KB)


#10

This is a major update:

  • USAGE CHANGED:
    Usage: MakeAVI /INPUT=“filespec” (manadatory, filespec can include wildcards, quotes optional)
    Optional arguments (order is not important):
    /OUTPUT=“folder” (default is current path, don’t include trailing )
    /PRIORITY=NORMAL|HIGH (process priority, default is low)
    /DELTEMPS=TRUE (delete temp files after processing, default is FALSE)
    /MAX_BITRATE=number (max encoding bitrate in kbps, default is 1600)
    /MIN_BITRATE=number (min encoding bitrate in kbps, default is 600)
    /ANAMORPHIC=FALSE (use non-anamorphic ratios)
    /SHUTDOWN=TRUE (force shutdown after completion)
    e.g.
    makeavi /INPUT=*.mkv /OUTPUT=d: mp /ANAMORPHIC=FALSE
    makeavi *.mkv (N.B. /INPUT= may be omitted if no other switches are used)

  • exportformat.txt file now required for use with mediainfo command line

  • batchfile organised into subroutines for better readability

  • videos wider than 720x??? are automatically resized to 720x??? anamorphic resolution

  • bitrate is now calculated to match frame size

  • FAAD used if NeroAACDec fails

  • AVI input support; DivX AVI files will be unpacked and converted to CBR audio for better standalone support

  • the deletion of temp files has been changed to delete all files with matching names in the input or output folders other than the source and final target file, so use with care! e.g. processing “My Film.mkv” will delete “My Film.*” excluding “My Film.mkv” and “My Film.avi”

New tools:
MpegModifier Command Line (for unpacking packed bitstream)
FAAD for decoding AAC
MediaInfo CLI

Known Limitations:

  • processing of files with no audio stream will currently halt after demuxing. This issue will be resolved in the next update.

exportformat.txt (137 Bytes)

_MakeAVI.bat.txt (27.1 KB)

MakeAVI.bat.txt (5.19 KB)


#11

Bugfix:

  • this addresses an issue with spaces in the command line input file or output path in certain circumstances

P.S. after some thought, I’ve decided not to address the ‘halt on video only streams’ as mentioned in the previous post, since it occurs so infrequently. For those few occasions when it occurs, I suggest manual modification of the created batch program to skip straight to video processing.

_MakeAVI.bat.txt (26.9 KB)

MakeAVI.bat.txt (5.42 KB)


#12
  • batch file extension changed to CMD, in line with current standards
  • (decrypted) vob support added; use /INPUT=VTS_01_0.VOB to incrementally add VTS_01_1.VOB, VTS_01_2.VOB… VTS_01_X.VOB
  • avi support extended to include downsizing of HD AVI to 720xHHH
  • added /BITRATE=number command line option to force specified bitrate
  • added /FORCEAVI=TRUE command line option to force re-encoding of avi files (useful to remove QPel/GMC etc.)
  • various small bugs fixed, and scripting tidied up considerably

I’ve just started using Crimson Editor to edit my script files and recommend it to everyone. Thanks yet again to all the wonderful peeps at sourceforge.

Slainte

midders

_MakeAVI.cmd.txt (28.7 KB)


#13

[B]Install guide for command line virgins (!) or other less experienced users.[/B]

Download and install the following tools; if the tools don’t come with an installer then just unzip them to a folder of your choice:

Download the latest [B]MakeAVI.cmd.txt[/B], [B]_MakeAVI.cmd.txt[/B] and [B]exportformat.txt[/B] files from this thread and place them in the same folder. The folder you choose should be part of the PATH environment variable; if unsure I suggest that you use c:\windows\system32. Remove the .txt extension from the .cmd files.

After installing, you will need to edit the MakeAVI.cmd file so that the paths to the various tools are correct (this need only be done once).

Open a cmd window and type makeavi to get a list of command line options.

Enjoy.

Slainte

midders


#14
  • fixed an issue where bitrate was carried over from previous file in certain circumstances
  • fixed an issue where resizing was carried over from previous file in certain circumstances

P.S. I’ve just noticed a tool that is missing from the list:
Nero AAC Codec
(If this is not present FAAD will be used instead)

_MakeAVI.cmd.txt (28.8 KB)


#15

Another major rewrite:

  • HCEnc now supported for conversion to DVD compliant video
  • basic DVD authoring (no menu)
  • I’ve included the TARGET=DVD option mainly for creating .m2v streams that I can then author with GUI for DVDAuthor, hence I’ve only included the most basic authoring capability.
  • the DVD_LENGTH option is useful if you want to create DVDs with multiple episodes on, e.g.: with four episodes of 45mins, use /DVD_LENGTH=180 to fit four episodes on a disk.

I’m currently working on a basic windows cmd prompt front-end for MakeAVI, which will be called YAFE (Yet Another Front-End!). Watch this space. YAFE also combines the two cmd files into one, introduces the concept of an ini file and will generate the exportformat.txt file as required.

Output from MakaAVI /?:

Generates batch files for converting video(s) to XVid AVI or DVD Video

“MakeAVI”
/INPUT=“filespec” (filespec can include wildcards, REQUIRED)
/OUTPUT=“folder” (DEFAULT is current path, don’t include trailing )
/PRIORITY=NORMAL,HIGH (process priority, DEFAULT: LOW)
/DELTEMPS=TRUE (delete temp files after processing, DEFAULT: TRUE)
/BITRATE=number (use specified bitrate over-riding calculation)
/MAX_BITRATE=number (max average encoding bitrate in kbps, DEFAULT: 1500)
/MIN_BITRATE=number (min average encoding bitrate in kbps, DEFAULT: 600)
/AUDIOEXT=AC3,MP3… (input audio file extension, DEFAULT: MP2)
/A2CH_BITRATE=number (2ch channel audio bitrate in kbps, DEFAULT: 224)
/A6CH_BITRATE=number (6ch audio bitrate in kbps, DEFAULT: 448)
/STANDARD=NTSC (set framesize to NTSC 720x480, DEFAULT: PAL 720x576)
/CHANGEFPS=TRUE (adjust framerate to match video size, DEFAULT: FALSE)
/ANAMORPHIC=FALSE (use non-anamorphic ratios, DEFAULT: TRUE)
/FORCEAVI=TRUE (force re-encoding of AVI file, DEFAULT: FALSE)
/TARGET=DVD (make DVD video instead of Xvid avi, DEFAULT=XVID)
/DVD_LENGTH=NNN (fit NNN minutes on a DVD, DEFAULT: fit to disc)
/AUTHOR=TRUE (create DVD file structure, DEFAULT is FALSE)
/AUTORUN=TRUE (run batch file after generating, DEFAULT is FALSE)
/SHUTDOWN=TRUE (forced shutdown of PC when done, DEFAULT: FALSE)
e.g.
“MakeAVI” /INPUT=*.mkv /OUTPUT=d: mp /ANAMORPHIC=FALSE /SHUTDOWN=TRUE
"MakeAVI" /input=“A filename with spaces & al.mp4” /output=r: mp /deltemps=TRUE

MakeAVI.cmd.txt (9.23 KB)

_MakeAVI.cmd.txt (41.5 KB)

exportformat01.txt (367 Bytes)


#16

Thanks a lot


#17

Ive been testing it to convert mkv to xvid avi and it almost work because my version of mkvextract dosnt find anything when it points to the %V_ID% and %A_ID% given by mediainfo. I fixed it myself editing makeavi.cmd and including this lines just before the mkvextract lines:

set V_ID=0
set A_ID=1

For somereason mediainfo reads track 1 to video and track 2 for audio but mkvextract reads track 0 for video and 1 for audio.
With this fix, we set the v_id to 0 and a_id to 1 so mkvextract can do its work.
I think it may have something to do with the version of mkvextract or mediainfo because I have downloaded it recently and the post is about two years old.
If someone can fix the script so there is no need to bypass mediainfo v_id and a_id variables it would be nice.
It would be appreciated to have an option to choose the audio or subtitle track instead of automatically choose the first one of each.


#18

[QUOTE=hardwarer;2662545]Ive been testing it to convert mkv to xvid avi and it almost work because my version of mkvextract dosnt find anything when it points to the %V_ID% and %A_ID% given by mediainfo. I fixed it myself editing makeavi.cmd and including this lines just before the mkvextract lines:

set V_ID=0
set A_ID=1

For somereason mediainfo reads track 1 to video and track 2 for audio but mkvextract reads track 0 for video and 1 for audio.
With this fix, we set the v_id to 0 and a_id to 1 so mkvextract can do its work.
I think it may have something to do with the version of mkvextract or mediainfo because I have downloaded it recently and the post is about two years old.
If someone can fix the script so there is no need to bypass mediainfo v_id and a_id variables it would be nice.
It would be appreciated to have an option to choose the audio or subtitle track instead of automatically choose the first one of each.[/QUOTE]

Another bug: The script is always assuming that mkv files are 25 fps. So if you convert a 23,976 film to xvid the duration is shorter than the original and the sound is out of sync.

<SOLVED>
EDITING this line in the _makeavi.cmd file will fix it, and now the final video will allways have the same bitrate that the source:

if /i .%FILE_TYPE%==.MKV set SHOW_VIDEO=AVCSource(%DGA_FILE%).AssumeFPS(%V_FRAMERATE%)
I have just added “.AssumeFPS(%V_FRAMERATE%)” at the end of the original line to set the framerate in the AVS script.