@ECHO OFF :: ----------Locations------------ SET workingdir=D:\enc\ SET x264=D:\enc\x264.exe SET mp4box=D:\enc\MP4Box.exe SET besweet=D:\Program Files\AMVapp\Audio Apps\BeSweet\BeSweet.exe :: ---------x264 Settings---------- SET fps=23.976 SET numofpasses=3 SET othersettings=--bframes 3 --ref 8 --subme 7 --8x8dct --weightb --trellis 1 :: Target size in MB of a video Min:Sec long (This will determine x264 bitrate for you) SET lengthminutes=4 SET lengthseconds=21 SET targetfilesize=40 :: -----Set Audio Bitrate Kb/s - Use 128, 192, 320, etc----- SET audiobitrate=320 :: ++++++++++++DO NOT MODIFY THE BELOW LINES++++++++++++++ IF [%1]==[] ( ECHO You must drop an AVI on the batch file rather than double clicking it. GOTO endofscript ) ELSE (GOTO start) :start :: Converting to YV12 colorspace ECHO AVISource(%1).converttoyv12() > "%workingdir%video.avs" SET /A bitrate=%targetfilesize%*8192/(%lengthminutes%*60+%lengthseconds%)-%audiobitrate% SET arguements=%othersettings% --bitrate %bitrate% --fps %fps% --progress --output "%workingdir%video.264" "%workingdir%video.avs" :: Begin Encoding IF %numofpasses%==1 (GOTO onepass) ELSE (GOTO firstpass) :onepass ECHO. ------------------- ECHO. Encoding Video - Single Pass ECHO. ------------------- ECHO. "%x264%" %arguements% GOTO encodeaudio :firstpass ECHO. Running multiple passes ECHO. ------------------- ECHO. Encoding Video Pass 1 ECHO. ------------------- ECHO. "%x264%" --pass 1 %arguements% SET currentpass=1 :multipass SET /A currentpass=%currentpass%+1 ECHO. ------------------- ECHO. Encoding Video Pass %currentpass% ECHO. ------------------- ECHO. "%x264%" --pass 3 %arguements% IF %currentpass%==%numofpasses% (GOTO encodeaudio) ELSE (GOTO multipass) :encodeaudio :: Transcoding Audio ECHO. ECHO. ------------------- ECHO. Encoding Audio ECHO. ------------------- ECHO. "%besweet%" -core( -input %1 -output "%workingdir%video.mp3" ) -lame( -p --alt-preset cbr %audiobitrate% ) :: Muxing file ECHO. ECHO. ------------------- ECHO. Muxing MP4 ECHO. ------------------- ECHO. "%mp4box%" -add "%workingdir%video.264" -add "%workingdir%video.mp3" -fps %fps% "%~d1%~p1\%~n1.mp4" ECHO. ECHO. ------------------- ECHO. Encoding Finished ECHO. ------------------- :endofscript PAUSE CLS EXIT