Log in

View Full Version : x264 switching to Main Profile when -p 1 is set?


benwaggoner
17th July 2012, 00:26
I'm having a strange bug today; whenever I set the --pass parameter, profile gets overriden to Main.

Here's the simple test case where things work as I expect:

x264_32.exe --profile high -o "Smurfs15min_2500.mp4" "Smurfs start 720p.avs"
avs [info]: 1280x720p 0:0 @ 24000/1001 fps (cfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
x264 [info]: profile High, level 3.1

But once I specify number of passes, profile goes to Main:

x264_32.exe -p 1 --profile high -o "Smurfs15min_2500.mp4" "Smurfs start 720p.avs"
avs [info]: 1280x720p 0:0 @ 24000/1001 fps (cfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
x264 [info]: profile Main, level 3.1

Anyone have any idea what would cause this, or how to fix it?

This is the (totally vanilla) build I'm using:
x264 0.125.2200 999b753
(libswscale 2.1.0)
(libavformat 54.3.0)
(ffmpegsource 2.17.1.3)
built on May 23 2012, gcc: 4.6.3
configuration: --bit-depth=8 --chroma-format=all
x264 license: GPL version 2 or later
libswscale/libavformat/ffmpegsource license: LGPL version 2.1 or later

Groucho2004
17th July 2012, 01:00
I think the fast first pass settings (or one/some of them) force the profile to "main". Try "--slow-firstpass" if you are bothered by this.
Calling the "-p" parameter "number of passes" is a bit odd. It would imply that using "-p 2" executes 2 passes.

poisondeathray
17th July 2012, 01:01
It might be because --no-8x8dct is implied with --pass 1 (and thus main profile)


Using --pass 1 applies the following settings at the end of parsing the command line:

--ref 1
--no-8x8dct
--partitions i4x4 (if originally enabled, else none)
--me dia
--subme MIN( 2, subme )
--trellis 0




So you can try adding --slow-firstpass

http://mewiki.project357.com/wiki/X264_Settings#slow-firstpass


EDIT: ahh Groucho beat me to it

benwaggoner
17th July 2012, 01:09
Great feedback, thanks. Setting it to --slow-firstpass did the trick.

Leaving it at Main is probably okay, althogh I worry about given I'm testing with the max High Profile VBV, so a stock first pass would use a lower value. And 8x8dct is a feature that can change optimum bitrate at HD resolutions, since it varies in how helpful it is depending on the content. But if a first pass can get away with only one ref, it's probably inconsequential

Guess I'll try it both ways...

Blue_MiSfit
18th July 2012, 06:35
Does your second pass report high profile? See below:


D:\VideoTests\Test Sources\Parkjoy>x264 quicktest.avs --stats .stats --preset ve
ryfast --bitrate 5000 --vbv-maxrate 17500 --vbv-bufsize 17500 --level 31 --pass
1 --output nul
avs [info]: 1280x720p 0:0 @ 24000/1001 fps (cfr)
x264 [warning]: VBV bitrate (17500) > level limit (14000)
x264 [warning]: VBV buffer (17500) > level limit (14000)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
x264 [info]: profile Main, level 3.1
x264 [info]: frame I:2 Avg QP:25.81 size:195194
x264 [info]: frame P:251 Avg QP:34.30 size: 41706
x264 [info]: frame B:247 Avg QP:37.82 size: 7000
x264 [info]: consecutive B-frames: 1.2% 98.8% 0.0% 0.0%
x264 [info]: mb I I16..4: 24.1% 0.0% 75.9%
x264 [info]: mb P I16..4: 6.3% 0.0% 0.0% P16..4: 72.9% 0.0% 0.0% 0.0% 0
.0% skip:20.7%
x264 [info]: mb B I16..4: 0.5% 0.0% 0.0% B16..8: 12.4% 0.0% 0.0% direct:
18.4% skip:68.7% L0:18.7% L1:45.0% BI:36.3%
x264 [info]: final ratefactor: 28.87
x264 [info]: coded y,uvDC,uvAC intra: 81.9% 70.3% 52.3% inter: 29.2% 13.1% 3.1%
x264 [info]: i16 v,h,dc,p: 24% 14% 48% 14%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 15% 22% 9% 7% 7% 9% 7% 12%
x264 [info]: i8c dc,h,v,p: 62% 14% 18% 6%
x264 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x264 [info]: kb/s:4828.78

encoded 500 frames, 69.44 fps, 4828.78 kb/s

D:\VideoTests\Test Sources\Parkjoy>x264 quicktest.avs --stats .stats --preset ve
ryfast --bitrate 5000 --vbv-maxrate 17500 --vbv-bufsize 17500 --level 31 --pass
2 --output nul
avs [info]: 1280x720p 0:0 @ 24000/1001 fps (cfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
x264 [info]: profile High, level 3.1
x264 [info]: frame I:2 Avg QP:30.78 size:110259
x264 [info]: frame P:251 Avg QP:33.89 size: 43994
x264 [info]: frame B:247 Avg QP:37.33 size: 7355
x264 [info]: consecutive B-frames: 1.2% 98.8% 0.0% 0.0%
x264 [info]: mb I I16..4: 19.5% 33.0% 47.5%
x264 [info]: mb P I16..4: 1.7% 1.4% 0.9% P16..4: 41.2% 18.8% 15.6% 0.0% 0
.0% skip:20.3%
x264 [info]: mb B I16..4: 0.2% 0.1% 0.0% B16..8: 9.8% 4.1% 0.8% direct:
19.1% skip:65.9% L0:20.5% L1:42.6% BI:36.9%
x264 [info]: 8x8 transform intra:34.9% inter:19.2%
x264 [info]: coded y,uvDC,uvAC intra: 75.7% 63.9% 45.9% inter: 30.2% 14.0% 3.5%
x264 [info]: i16 v,h,dc,p: 34% 16% 39% 11%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 13% 41% 3% 6% 5% 5% 5% 7%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 15% 27% 9% 6% 6% 8% 6% 10%
x264 [info]: i8c dc,h,v,p: 62% 14% 19% 5%
x264 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x264 [info]: kb/s:5017.59

encoded 500 frames, 65.02 fps, 5017.59 kb/s


I think it doesn't matter in first pass, but those warnings make me raise an eyebrow, and wonder whether x264 is using the VBV values I specify, or using the MP max values. Can a dev or someone with a concrete understanding comment this?

Thanks!
Derek

MasterNobody
18th July 2012, 07:03
I think it doesn't matter in first pass, but those warnings make me raise an eyebrow, and wonder whether x264 is using the VBV values I specify, or using the MP max values. Can a dev or someone with a concrete understanding comment this?
It use user specified values (i.e. nothing is forced for level)

P.S. Ignore profile change during fast first pass, it doesn't really matter for stats it writes.

sirt
18th July 2012, 08:05
Does the fact main profile is used during the first pass even though high profile has been set has an importance, like in Blue_MSfit log ? I mean : what will change if High profile is effectively used during the first pass ?

detmek
18th July 2012, 09:30
Well, on my single test clip forcing High profile for fast first pass didn't really change much.
CMD line: --preset medium --bitrate 250 --pass x --b-adapt 2 --direct auto --tune ssim --ssim
Slow first pass SSIM: 19,558db --slow-firstpass
Fast first pass High SSIM: 19,543db --slow-firstpass --ref 1 --me dia --subme 2 --trellis 0 --partitions none for pass 1 only
Fast first pass SSIM: 19,547db
Change in quality is less then 0,2%.

sirt
18th July 2012, 09:40
Thanks, then it has some impact ; as far as I know, the second pass relies on the data collected from the previous first pass. Imagine, for some reason something bad happens while using Main profile during first pass, I guess the errors generated can reverberate thereafter. What do you think ?

detmek
18th July 2012, 10:19
The only difference between Main and High profile is 8x8dct which affects only compression of I frames. And if you look the numbers --ref 1 --me dia --subme 2 --trellis 0 have much bigger impact on quality than 8x8dct.
Purpose of the 1st pass is to create stats file for 2nd pass (+ frame type decision), not to do actual compression. It's just rough approximation of video complexity over time. Using 8x8dct during 2nd pass will improve quality up to 10% but on 1st pass it is not that useful as frames from 1st pass are discarded. So, it doesn't matter how I frames are compessed during 1st pass.

Dark Shikari
18th July 2012, 10:21
A profile isn't "used", the profile is the consequence of the features used by the encoder. Which features go in which profiles is a decision made by the authors of the spec and is completely unrelated to how important those features are with regards to first-pass accuracy in x264.

Why do you think x264 would have "something bad happen" when using only Main profile features? x264 doesn't have evil gremlins lurking inside that come out and bite when you disable a certain size of frequency transforms.

sirt
18th July 2012, 10:32
Thanks for the answers.

Dark Shikari, would you mind checking my "About fades x264" thread that is in fact a question for you. About mine there : I don't think "something bad" may happen but as detmek reported there is a difference of 0.2% perhaps due to 8x8dct. In fact, if you don't force slow-firstpass, Main profile will be automatically used during the first pass, am I right ? (Excepted with placebo maybe) ; what is the reason of that ? Is Main profile used because using High during the first pass will not affect the final output or is there another reason for that ?

Dark Shikari
18th July 2012, 10:49
Yes, using different settings in the first pass will give slightly worse results in the second pass.

No, the benefit of using slow settings on the first pass is so miniscule that it isn't typically worth the time, and you'd be better off using better settings on the second pass instead.

Placebo uses the same on both passes because its sole purpose is to waste your CPU time and earn money for power companies. Using slower settings on the first pass makes the encoder take longer, and so it uses up more electricity.

Like I said, main profile is not "used". You can't use a profile. A profile is the result of the parameters used, and does not in and of itself do anything at all.

JEEB
18th July 2012, 10:57
In fact, if you don't force slow-firstpass, Main profile will be automatically used during the first pass, am I right ? (Excepted with placebo maybe) ; what is the reason of that ? Is Main profile used because using High during the first pass will not affect the final output or is there another reason for that ?

The faster settings do not use features for which high profile would be needed, and thus the profile tag is set to something lower than that. Yes, it's basically a tag, auto-set by looking at the features your settings use to the lowest possible (unless you set a specific tag yourself, which is when x264 starts auto-limiting features to match that profile -- for example if I had preset placebo + profile main set, x264 would limit some things so it would be a valid main profile stream). If you want to see a general listing on what is changed during fast first pass settings (--pass 1 set with everything else but --preset placebo), see here (http://mewiki.project357.com/wiki/X264_Settings#slow-firstpass).

Blue_MiSfit
19th July 2012, 09:17
Thanks for the clarification, all!