PDA

View Full Version : x264 2 Pass


Prim3
19th August 2007, 07:39
Hi! I had a question regarding x264 in cmd.

I'm trying to create a 2 pass script for x264 but I'm not quite sure on how to make it.

I made one with crf 18 but thats about it. 2 Pass is something completely new to me.

If anyone has any suggestions on how I can start it, please tell me. And I use the cmd.

Thanks,
Prim3

buzzqw
19th August 2007, 09:59
example of

1 pass fast) x264.exe --bitrate 644 --progress --keyint 250 --bframes 1 --qpmin 10 --qpmax 51 --no-psnr --ref 1 --filter 0,0 --subme 0 --direct none --vbv-maxrate 25000 --me dia --no-ssim --merange 8 --nf --no-cabac --no-b-adapt --no-chroma-me --threads auto --thread-input --output "C:\temp\temp\movie.mp4" "C:\temp\temp\movie.avs"

1 pass not so fast) x264.exe --bitrate 644 --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --ref 3 --filter 0,0 --subme 3 --direct auto --vbv-maxrate 25000 --me hex --no-ssim --weightb --analyse p8x8,b8x8,i4x4 --threads auto --thread-input --output "C:\temp\temp\movie.mp4" "C:\temp\temp\movie.avs"

2 pass balanced) x264.exe --pass 1 --bitrate 644 --stats "C:\temp\temp\.stats" --ref 1 --no-b-adapt --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --filter 0,0 --subme 1 --direct auto --vbv-maxrate 25000 --me dia --no-ssim --b-pyramid --analyse none --threads auto --thread-input --output NUL "C:\temp\temp\movie.avs"

x264.exe --pass 2 --bitrate 644 --stats "C:\temp\temp\.stats" --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --mixed-refs --trellis 1 --ref 4 --filter 0,0 --direct auto --vbv-maxrate 25000 --me hex --no-ssim --weightb --b-pyramid --b-rdo --bime --analyse p8x8,b8x8,i4x4 --threads auto --thread-input --output "C:\temp\temp\movie.mp4" "C:\temp\temp\movie.avs"

2 pass better quality) x264.exe --pass 1 --bitrate 644 --stats "C:\temp\temp\.stats" --ref 1 --subme 2 --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --filter 0,0 --subme 1 --direct auto --vbv-maxrate 25000 --me dia --no-ssim --b-pyramid --analyse none --threads auto --thread-input --output NUL "C:\temp\temp\movie.avs"

x264.exe --pass 2 --bitrate 644 --stats "C:\temp\temp\.stats" --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --mixed-refs --trellis 1 --ref 6 --subme 5 --filter 0,0 --direct auto --vbv-maxrate 25000 --me hex --no-ssim --weightb --b-pyramid --b-rdo --bime --analyse p8x8,b8x8,i4x4,i8x8 --8x8dct --threads auto --thread-input --output "C:\temp\temp\movie.mp4" "C:\temp\temp\movie.avs"

2 pass extreme quality) x264.exe --pass 1 --bitrate 644 --stats "C:\temp\temp\.stats" --ref 1 --subme 5 --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --filter -2,-1 --subme 1 --direct auto --vbv-maxrate 25000 --me dia --no-ssim --b-pyramid --analyse none --threads auto --thread-input --output NUL "C:\temp\temp\movie.avs"

x264.exe --pass 2 --bitrate 644 --stats "C:\temp\temp\.stats" --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --mixed-refs --trellis 1 --ref 12 --subme 5 --filter -2,-1 --direct auto --vbv-maxrate 25000 --me umh --no-ssim --weightb --b-pyramid --b-rdo --bime --analyse p8x8,b8x8,i4x4,i8x8,p4x4 --8x8dct --threads auto --thread-input --output "C:\temp\temp\movie.mp4" "C:\temp\temp\movie.avs"

2 pass insane quality) x264.exe --pass 1 --bitrate 644 --stats "C:\temp\temp\.stats" --ref 1 --subme 6 --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --no-fast-pskip --filter -2,-1 --subme 1 --direct auto --vbv-maxrate 25000 --me dia --no-ssim --merange 32 --b-pyramid --analyse none --threads auto --thread-input --output NUL "C:\temp\temp\movie.avs"

x264.exe --pass 2 --bitrate 644 --stats "C:\temp\temp\.stats" --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --no-fast-pskip --mixed-refs --trellis 2 --ref 16 --filter -2,-1 --subme 6 --direct auto --vbv-maxrate 25000 --me umh --no-ssim --merange 32 --weightb --b-pyramid --b-rdo --bime --analyse p8x8,b8x8,i4x4,i8x8,p4x4 --8x8dct --threads auto --thread-input --output "C:\temp\temp\movie.mp4" "C:\temp\temp\movie.avs"


:)

BHH

Taktaal
19th August 2007, 12:15
Does anyone know whether you can reuse a stats file for two similar but not quite equal encodes?

i.e. let's say I make a first pass off a movie, then change the bitrate, add some degraining filter, and run the second pass. Will x264 still get some useful info from the stats file or is the second pass going to end up horribly mismatched because its interpreting all the data the wrong way?

Dark Shikari
19th August 2007, 12:40
x264.exe --pass 1 --bitrate 644 --stats "C:\temp\temp\.stats" --ref 1 --no-b-adapt --progress --keyint 250 --bframes 3 --qpmin 10 --qpmax 51 --no-psnr --filter -2,-1 --subme 1 --direct auto --vbv-maxrate 25000 --me dia --no-ssim --b-pyramid --analyse none --threads auto --thread-input --output NUL "C:\temp\temp\movie.avs"

is definitely not a good first pass for "extreme quality". Using --subme 1 on first pass doesn't boost speed that much and, worse, drops SSIM by a couple percentage points in my experience; a surprising amount considering its only a ratecontrol change.

And why no-b-adapt? You can't run the second pass without no-b-adapt if the first pass has no-b-adapt (as the number of B-frames changes), plus it'll decrease quality.

buzzqw
19th August 2007, 13:41
about subme ... using subme 1 i got an average fps of 18.70, on the same sample the subme 5 (standard) give me 12.69 ... so the difference is present about 30% in speed

a small comparison (based on "1 pass not so fast")
subme 1 -> 18.70 fps -> final ratefactor: 21.02
subme 2 -> 16.06 fps -> final ratefactor: 18.79
subme 3 -> 15.63 fps -> final ratefactor: 18.64
subme 4 -> 14.07 fps -> final ratefactor: 18.52
subme 5 -> 12.69 fps -> final ratefactor: 18.44

so i can go with subme 2 in first pass but not subme 5...

You can't run the second pass without no-b-adapt if the first pass has no-b-adapt

well.. i basically borrowed this value from megui and on forum...

now a little table on 2 pass encoding using the "extreme settings"

using subme 1 , then subme 5
1 pass fps 2 pass fps final ratefactor drf (avinaptic)
23.41 3.12 21.27 18.247619

using subme 2 then subme 5
1 pass fps 2 pass fps final ratefactor drf (avinaptic)
22.96 3.04 19.32 18.225396

using subme 5 on both pass
1 pass fps 2 pass fps final ratefactor drf (avinaptic)
19.31 3.03 19.08 18.225396

using subme 1 then subme 5 and WITHOUT no-b-adapt on both passes
1 pass fps 2 pass fps final ratefactor drf (avinaptic)
22.75 3.02 21.27 18.247619

sing subme 2 then subme 5 and WITHOUT no-b-adapt on both passes
1 pass fps 2 pass fps final ratefactor drf (avinaptic)
19.71 2.87 19.32 18.225396

using subme 5 on both pass and WITHOUT no-b-adapt on both passes
1 pass fps 2 pass fps final ratefactor drf (avinaptic)
18.63 2.97 19.08 18.222222

so.. without no-b-adapt the difference is quite small but better , and the speed penalty is small

but the difference with subme 1 then 5 and subme 5 then 5 are 6fps and just 0.02 point of drf and from subme 2/5 is 0

i will update to subme 2 and without no-b-adapt

BHH

Dark Shikari
19th August 2007, 13:57
You should use a metric like SSIM... "drf" is pretty meaningless by comparison.

buzzqw
19th August 2007, 14:07
i don't belive in metrics ;)
i prefer simple and avaiable to mass instrument of analisys, so avinaptic and eyes

BHH

Dark Shikari
19th August 2007, 14:54
i don't belive in metrics ;)
i prefer simple and avaiable to mass instrument of analisys, so avinaptic and eyes

BHH
DRF is a metric, just a much more useless one.

Prim3
20th August 2007, 04:16
I have a script made but the thing is when I open it up in CMD, it gives me, "BITRATE:"

When I enter the Bitrate, it leaves me with... "the path cannot be specified etc.."

Here's the script. My friend helped me with it:





@ECHO OFF

ECHO.
set /p BITRATE="Bitrate: "
ECHO.

C:\Programme\Video\Encoder\x264_477\x264.exe --pass 1 --bitrate %BITRATE% --stats %1.stats --bframes 3 --b-pyramid --subme 1 --analyse none --me dia --progress --no-psnr --output NUL %1

ECHO.

C:\Programme\Video\Encoder\x264_477\x264.exe --pass 2 --bitrate %BITRATE% --stats %1.stats --ref 8 --mixed-refs --filter 0,0 --no-fast-pskip --bframes 3 --b-pyramid --b-rdo --bime --weightb --subme 7 --trellis 2 --analyse all --8x8dct --me esa --progress --no-psnr --aq-strength 1,0 --output %1.mkv %1

ECHO.
REM SHUTDOWN -s -t 600
PAUSE
REM SHUTDOWN -a

buzzqw
20th August 2007, 09:01
it's missing the input file... or you don't give it

modify as this

C:\Programme\Video\Encoder\x264_477\x264.exe --pass 1 --bitrate %1 --stats %2.stats --bframes 3 --b-pyramid --subme 1 --analyse none --me dia --progress --no-psnr --output NUL %2
C:\Programme\Video\Encoder\x264_477\x264.exe --pass 2 --bitrate %1 --stats %2.stats --ref 8 --mixed-refs --filter 0,0 --no-fast-pskip --bframes 3 --b-pyramid --b-rdo --bime --weightb --subme 7 --trellis 2 --analyse all --8x8dct --me esa --progress --no-psnr --aq-strength 1,0 --output %2.mkv %2

ECHO.
REM SHUTDOWN -s -t 600
PAUSE
REM SHUTDOWN -a
call this bat x264enc.bat (for example)

and from dos write:

x264enc.bat 500 movie.avs

the first argument is bitrate , the last is the file avs to process

BHH

Prim3
21st August 2007, 07:34
It's encoding. Thank you very much! I will let you know how the quality and settings for it are.

I had another question; regarding bitrate. Is there any way to calculate Bitrate for x264 besides using a bitrate calculator. What would you recommend for calculating it?

Thanks.

buzzqw
21st August 2007, 07:45
i can suggest this http://forum.doom9.org/showthread.php?t=122562

or for a more advanced calculator with correct computing of width/height use this http://aspect.fre3.com/

BHH

rbt01
27th August 2007, 04:24
but why i can't use --, the long option?
i can't use --pass 2 , --progress, etc.

rbt01
27th August 2007, 04:26
i can't use --pass 2 , --progress, etc.

rbt01
27th August 2007, 04:52
is the bitrate of 1 pass useful?

nm
27th August 2007, 08:55
is the bitrate of 1 pass useful?
Yes, you should use (approximately) the same bitrate for both passes.