Batch file fun!

The x264 compressor is great, but it is really slow! Sometimes it goes at 2fps! So what I did is coming up with a simple way to split a large encode in smaller pieces which can be done separately:


set X264OPTS=--crf 24
d:\multimedia\convert\x264.exe "%~f1" --frames 1 --output "%~dpn1_stat.mp4" 2>"%~dpn1.stats"
for /f "tokens=7,8 delims=() " %%F in (%~dpns1.stats) do if "%%G"=="frames" SET FRAMES=%%F
set /a REMAIND="%FRAMES% %% 10000"
set /a RESULT="(%FRAMES%-%REMAIND%)/10000"
set /a RESULTMINONE="%RESULT%-1"
set /a LASTONE="%FRAMES%-%REMAIND%"
echo %REMAIND% %RESULT% %RESULTMINONE%
echo start /belownormal /B /wait x264.exe --progress --frames 9999 %X264OPTS% -o stage_0.264 "%~nx1" >stage_0.bat
echo echo "Done!" ^>stage_0.txt >>stage_0.bat
for /l %%n in (1,1,%RESULTMINONE%) do (
echo set /a NUMBER=%%n >stage_%%n.bat
echo set /a SEEKFRAME="%%NUMBER%% * 10000" >>stage_%%n.bat
echo start /belownormal /B /wait x264.exe --progress --seek %%SEEKFRAME%% --frames 9999 %X264OPTS% -o stage_%%n.264 "%~nx1" >>stage_%%n.bat
echo echo "Done!" ^>stage_%%n.txt >>stage_%%n.bat
)
echo start /belownormal /B /wait x264.exe --progress --seek %LASTONE% %X264OPTS% -o stage_%RESULT%.264 "%~nx1" >stage_%RESULT%.bat
echo echo "Done!" ^>stage_%RESULT%.txt >>stage_%RESULT%.bat

So feed it a avs file and it will split a bunch on stage_xx.bat files which encode each 10000 frames.


geeky