PDA

View Full Version : How to do automated 2 pass with bat files


dark.soft
1st August 2006, 15:25
I need to do a 2 pass script for x264, but I don't know how, For now I've been using 2 separate bats for the two passes. I need to use bat files because guis don't let me manually modify the command line. Can you tell me how to make one bat that makes the first pass and when it's finished makes the second?

Here are the 2 scripts:

1 PASS
x264 --pass 1 --bitrate 1580 --stats ".stats" -A all --level 3 --no-fast-pskip --pictiming --aud --thread-input --nf --subme 6 --trellis 2 --analyse p8x8,b8x8,i4x4,p4x4 --me esa --progress --no-psnr --output NUL "a.avs"

2 PASS
x264 --pass 2 --bitrate 1580 --stats ".stats" -A all --level 3 --no-fast-pskip --pictiming --aud --thread-input --nf --subme 6 --trellis 2 --analyse p8x8,b8x8,i4x4,p4x4 --me esa --progress --no-psnr --output "a.264" "a.avs"

can you also tell me what can I remove from the first pass to increase speed without decreasing quality? Thanks.

alec_robertson
1st August 2006, 15:42
The following works for me (in linux):
x0="-B 2000 -b 2 --b-pyramid -w -8"
x1="-m 1 --me dia -A none"
x2="-m 6 --me umh -A all"
x264 $x0 $x1 -p 1 -o /dev/null $b.y4m # 26-45fps
x264 $x0 $x2 -p 2 -o $b-v.mkv $b.y4m # 12-21fps


There was also a recent post describing which parameters were necessary in the first pass:
http://forum.doom9.org/showthread.php?t=113302

dark.soft
1st August 2006, 17:09
Thank you, but I need a bat file working in windows, and I only need the commands necessary to make dos do the second pass after the first.

foxyshadis
1st August 2006, 18:42
Every line is a dos command, thus it only has to be two lines long!

x264 (first pass args)
x264 (second pass)

I like alec's style though, so here:

set x0=-B 2000 -b 2 --b-pyramid -w -8
set x1=-m 1 --me dia -A none
set x2=-m 6 --me umh -A all
x264 %x0% %x1% -p 1 -o nul %1
x264 %x0% %x2% -p 2 -o %~dpn1.mkv %1

bond
1st August 2006, 20:31
why not simply a .bat with those two lines:

x264 --pass 1 --bitrate 1580 --stats ".stats" -A all --level 3 --no-fast-pskip --pictiming --aud --thread-input --nf --subme 6 --trellis 2 --analyse p8x8,b8x8,i4x4,p4x4 --me esa --progress --no-psnr --output NUL "a.avs"
x264 --pass 2 --bitrate 1580 --stats ".stats" -A all --level 3 --no-fast-pskip --pictiming --aud --thread-input --nf --subme 6 --trellis 2 --analyse p8x8,b8x8,i4x4,p4x4 --me esa --progress --no-psnr --output "a.264" "a.avs"

foxyshadis
1st August 2006, 21:23
With alec's format it's dead simple to manage options between both, and you can drag&drop anything on it and the output will show up wherever your avs is with the same filename. :p (Or it could be added to the right-click menu for .avs files, "quick encode" say.)

Also, I just looked at the rest of your command-line, heh. But I think you forgot --ref 16. ;)

bob0r
1st August 2006, 23:58
Dont forget to add this before x264.exe (or any other CPU comsuming program):

start /low /b /w x264.exe

dark.soft
2nd August 2006, 12:18
Thank you bond, I haven't tried that because I only know how to do simple scripts with dos.

@alec_robertson
Can you explain precisely the lines of your script (also if it is for linux, it's interesting)

foxyshadis
2nd August 2006, 13:46
The first line is common to both passes. Anything related to the bitstream (b-frames, inloop, cqm usually) has to be identical in both. If you look at x264's help, it's the "Frame-type options". It's usually better to keep rate control options (like bitrate) in both as well, but not required.

The next two are per-pass; you never need to touch the first but anything quality-enhancing (bitrate, trellis, references, etc, anything in "Analysis") goes in second pass only.

The next two combine them together appropriately and give the output the same name as the input. It also creates a stats file automatically, if you want more control over it you should specify in a stats in x0.

If you look at it that way you'll see bond's post probably shouldn't be copied verbatim, especially with the me esa in it...