Log in

View Full Version : Need Help with Batch Converter Script


DeathTheSheep
15th July 2007, 06:09
I need to batch encode 100s of files with the same avisynth script. That is, I want to apply this exact same script:
avs.avs

directshowsource("FILENAME.avi")
trim(2100,8000)
resampleaudio(48000)
...etc

with these exact same commandlines:
x264.exe --qp 21 --ref 8 --mixed-refs --no-fast-pskip --bframes 5 --b-rdo --bime --weightb --nf --direct auto
--subme 7 --analyse p8x8,b8x8,i4x4,p4x4 --threads auto --thread-input --progress --no-psnr --no-ssim --output
FILENAME_video.mp4" avs.avs

bepipe.exe --script "DirectShowSource(avs.avs)" | "neroAacEnc.exe" -br 128000 -lc -if - -of FILENAME_audio.mp4

MP4Box.exe -new -add FILENAME_video.mp4 -add FILENAME_audio.mp4 FILENAME.mp4


to all thousand files.

I want all the files to go in as FILENAME.avi and out as FILENAME.mp4. I don't want presets or predefined settings, just my avs and commandline settings.

How do I do this all at once, without manually changing the filename in the avs and doing a separate encode for each file?!

mitsubishi
15th July 2007, 20:14
I'm not exactly king of the batch scripts, but if you create this batch file in the same directory as the avi's

opp.batecho directshowsource(%1) > avs.avs
echo trim(2100,8000) >> avs.avs
echo resampleaudio(48000) >> avs.avs

"x264.exe" --qp 21 --ref 8 --mixed-refs --no-fast-pskip --bframes 5 --b-rdo --bime --weightb --nf --direct auto --subme 7 --analyse p8x8,b8x8,i4x4,p4x4 --threads auto --thread-input --progress --no-psnr --no-ssim --output "%~n1_video.mp4" avs.avs

"bepipe.exe" --script "DirectShowSource(avs.avs)" | "neroAacEnc.exe" -br 128000 -lc -if - -of "%~n1_audio.mp4"

"MP4Box.exe" -new -add "%~n1_video.mp4" -add "%~n1_audio.mp4" "%~n1.mp4"

replace the executables with full paths to where they are. Then bring up a command prompt and type
for %f in (*.avi) do opp "%f"

SealTooGreat
15th July 2007, 20:46
DeathTheSheep, you are using --nf, I thought that I'm the only one who doesn't use encoder's inloop. :) ...huh this is in conflict with your x264 guide. :D Anyway I suggest you to add --cqmfile "M4G MRM V2.cfg (http://forum.doom9.org/showthread.php?t=117041)" in your cmd line - this cqm is very good for blocks reducing - just a little support for --nf ;)

DeathTheSheep
18th July 2007, 22:30
Thanks, I'll give it a shot!

And thanks for the matrix, too. :)

PS: Akshully, iss justa exampul commanline I pull'd off 4 kiks, :D I'd never really uzit, see, unless 4 low complexity decodin'. ;)

smok3
18th July 2007, 23:14
check http://somestuff.org/blog/static.php?page=x264_ng
(it is meant to be used with total commander)

DeathTheSheep
24th July 2007, 15:54
mitsubishi, I've been using your script for a few days now, and I like it a lot. But I have a few questions:
1. How can I set the process priority to LOW? (I can't just type "start /LOW /B opp.bat")
2. How can I batch the batches? I mean, how do I make a .bat that will run an instance of for %f in (*.avi) do opp "%f" in different folders, or with different settings, one after another?

For example, how can I make a .bat like this work:
batchbatch.bat
chdir c:\first_group
for %f in (*.avi) do opp "%f"
chdir c:\group2
for %f in (*.avi) do opp2 "%f"
chdir c:\group3
for %f in (*.mkv) do opp3 "%f"
...where each "opp.bat" is in a different place and contains different settings or avisynth commands? (DOS reports 'f" is unexpected at this time' with this script).

mitsubishi
24th July 2007, 18:09
I can't seem to get priority setting to work, I've tried a few ways and each has it's own problem....


Within a batch file, you have to escape the %, so you need to use %%f rather than %f. That should work.

There's some good info here if you need to get complicated and manipulate the inputs path etc: http://www.windowsitpro.com/Articles/ArticleID/13443/13443.html?Ad=1