View Full Version : x264 profiles: b-frames > 3 not useful?
Hi!
When using the presets of x264 I recognize, that b-frames are increased quite late. First time with "veryslow" and also in conjuction with [further] increased refs and merange.
If I encode a video with --crf and medium/slow/slower with increased b-frames, say -b5 or -b8, I always recognize that x264 likes to use that frame-type.
So, quesion is, why b-frames are increased so late in the presents?
Doesn't x264's auto-usage of b-frames mean that they're good for compression?
D:\x264.exe source.avs --sar 1:1 --tune film --preset slower --deblock -2:-2 --min-keyint 2 --keyint 96
--vbv-bufsize 24000 --vbv-maxrate 24000 --qcomp 0.75 --crf 17 -r4 -b5
--colorprim "bt709" --transfer "bt709" --colormatrix "bt709" -o output.1080p.mkv
avs [info]: 1920x1080p 1:1 @ 24000/1001 fps (cfr)
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
x264 [info]: profile High, level 4.0
x264 [info]: frame I:1414 Avg QP:14.94 size:313609
x264 [info]: frame P:29720 Avg QP:17.72 size:150288
x264 [info]: frame B:75674 Avg QP:18.89 size: 77192
x264 [info]: consecutive B-frames: 1.9% 3.4% 39.2% 22.8% 12.0% 20.7%
x264 [info]: mb I I16..4: 6.9% 81.2% 11.9%
x264 [info]: mb P I16..4: 1.6% 34.8% 2.4% P16..4: 26.7% 24.9% 6.4% 0.5% 0.4% skip: 2.2%
x264 [info]: mb B I16..4: 0.2% 7.3% 0.3% B16..8: 34.7% 17.7% 4.3% direct:18.1% skip:17.4% L0:33.8% L1:32.9% BI:33.3%
x264 [info]: 8x8 transform intra:90.0% inter:59.3%
x264 [info]: direct mvs spatial:100.0% temporal:0.0%
x264 [info]: coded y,uvDC,uvAC intra: 96.9% 94.7% 74.4% inter: 55.0% 51.5% 13.7%
x264 [info]: i16 v,h,dc,p: 17% 11% 12% 61%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 11% 12% 8% 11% 10% 12% 11% 14%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 10% 3% 9% 15% 14% 15% 11% 13%
x264 [info]: i8c dc,h,v,p: 48% 21% 17% 14%
x264 [info]: Weighted P-Frames: Y:1.1%
x264 [info]: ref P L0: 58.3% 15.5% 19.3% 4.7% 2.3% 0.0%
x264 [info]: ref B L0: 87.0% 11.3% 1.7%
x264 [info]: ref B L1: 95.3% 4.7%
x264 [info]: kb/s:19307.60
aborted at input frame 106878, output frame 106808
encoded 106808 frames, 0.85 fps, 19294.95 kb/s
Here I lowered refs to 4 (and vbv), because I wanted to stay in 4.0, but as you can see, consecutive B-frames are used quite often.
Is that just because I told x264 to do so, and does this not necessarily mean better compression?
Is -b5 just a waste of time?
AnonCrow
6th May 2010, 17:04
Doesn't x264's auto-usage of b-frames mean that they're good for compression?
Yes - more b-frames are only used when they do improve compression and/or quality.
x264 [info]: frame I:1414 Avg QP:14.94 size:313609
x264 [info]: frame P:29720 Avg QP:17.72 size:150288
x264 [info]: frame B:75674 Avg QP:18.89 size: 77192
x264 [info]: consecutive B-frames: 1.9% 3.4% 39.2% 22.8% 12.0% 20.7%
Is -b5 just a waste of time?
That's quite subjective. With the above example , I'd at least do another encode with b6 to see how many times that many would actually be used.
With preset slower (b-adapt 2) , you could also do an encode with -b16 , and an encode with preset slower but set b-adapt 1 and b16 and see how the numbers in the 4 quoted x264 output lines change , and compare the changed compression speed vs change in quality vs change in final bitrate and choose which one you prefer.
Personally, when encoding with b-adapt 2 , I wouldn't go with a higher number of b-frames than whichever is the last one with at least 5% listed in the x264 output.
But if you're targeting for Blu-Ray encode, you'd have to limit the number of b-frames to 3 anyway. A lazy man might do an encode with b-adapt 0 and b2 , and spend the saved time elsewhere like a higher subme.
Any particular reason for increasing qcomp to 0.75 ?
For my media-player I don't need Blu-ray-restrictions of -b3. It has got some ref-restriction I haven't figured out yet, but with B's I can go up to -b16
I already checked -b8 and -b16:
B-frame insertion was saturating at 5 consecutives, >5 were all shown as 0.0%(for a shorter piece though), so I think for this film -b5 should be fine.
But sadly this setting takes ages to finish - I'm getting 0.9-1.0fps with this full-HD piece.
Perhaps I'm just interpreting these x264-profiles wrong, and "slower" really just means "slower" and not automatically "better quality". :rolleyes:
But then I wonder why we don't have any profiles with e.g. -r3 -b5 as an alternative "slower"-profile. Actual "slower" has got "-r8 -b3"...
Are ref-frames _that_ effective over b-frames?
Well, obviously they're better for _encoding-speed_, because they were chosen in the profiles, but are they also better for quality? What's the technical reason for this?
> Any particular reason for increasing qcomp to 0.75 ?
I had some bad results (blocking) in fades and dark areas, for which that helped. That was December or so. It could've been a bug of x264, what's already fixed now. (I was also using --deblock 0:0 or -1:-1)
[must do some tests about this]
--crf xx
When encoding with a const crf, but changing number of refs, b-frames, motion-search,...
A smaller output-size would tell me that I've received better quality with this specific setting, right?
Dark Shikari
6th May 2010, 18:24
Before the modifications to pyramid, x264 rarely used more than 3 B-frames. Now it uses up to around 5-6, max. The presets, accordingly, might be able to use some tweaking. However, do keep in mind that more B-frames worsens the effectiveness of multithreading.
AnonCrow
6th May 2010, 19:45
For my media-player I don't need Blu-ray-restrictions of -b3. It has got some ref-restriction I haven't figured out yet, but with B's I can go up to -b16
I already checked -b8 and -b16:
B-frame insertion was saturating at 5 consecutives, >5 were all shown as 0.0%(for a shorter piece though), so I think for this film -b5 should be fine.
If not targeting for Blu-Ray, did you try removing --min-keyint 2 altogether (or setting it to 1x FPS yourself) ?
Testing number of consecutive B-frames with a too short a piece doesn't really give accurate results; one would assume that if -b5 shows 20.7% at 5 consecutive frames, -b6 ought to take a considerable fraction of them.
A smaller output-size would tell me that I've received better quality with this specific setting, right?
Depending on the settings you change, either that, or
the same exact or similar quality at a smaller bitrate,
or even lower quality , but a better quality vs. bitrate ratio.
Hmm, I've done some further tests with different -r and -b settings and got some rather confusing results - until I found my error.
First, lowering refs and b's indeed increase bitrate, but PSNR was *better*, even if I lowered crf until i received the same bitrate.
e.g. -r11-b8--crf20 had lower PSNR than -r3-b3-crf20.1
Error: I used the --tune film :rolleyes:
My question now is: How can I compare different encodings correctly without using my eyes?
Just using --no-psy and then compare PSNR?
Warperus
7th May 2010, 12:52
It's impossible, just impossible.
There is no single number that can correctly estimate quality difference for every single situation.
Even if it would exist, x264 quality measurment does not use one. So different modes can produce unexpected results of super-number...
Y-PSNR is quite common. It is not perfect and you still have to compare pictures youself to overrule some weird situations.
You're right for comparing *quality*, but I first just want to compare coding efficiency.
For this, comparing mathematical offsets of the source-file should do the trick, right?
However, that still causes some problems for me:
\x264.exe dvd.d2v --preset slower --psnr --sar 64:45 --crf 20 -r5 -b8 --merange 16 -o r5b8me16.mkv --seek 38800 --frames 2000
avs [info]: trying MPEG2Source... succeeded
avs [info]: 720x576p 64:45 @ 25/1 fps (cfr)
x264 [info]: using SAR=64/45
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
x264 [info]: profile High, level 3.0
x264 [info]: frame I:11 Avg QP:15.81 size: 48179 PSNR Mean Y:48.79 U:50.12 V:52.24 Avg:49.40 Global:49.16
x264 [info]: frame P:423 Avg QP:19.09 size: 17747 PSNR Mean Y:45.43 U:47.34 V:49.66 Avg:46.17 Global:45.63
x264 [info]: frame B:1566 Avg QP:22.02 size: 5207 PSNR Mean Y:44.34 U:47.41 V:49.66 Avg:45.27 Global:44.53
x264 [info]: consecutive B-frames: 0.7% 0.6% 20.8% 2.6% 3.8% 71.5% 0.0% 0.0% 0.0%
x264 [info]: mb I I16..4: 15.2% 78.8% 6.0%
x264 [info]: mb P I16..4: 3.8% 19.3% 1.1% P16..4: 43.6% 16.1% 4.8% 0.5% 0.3% skip:10.6%
x264 [info]: mb B I16..4: 0.4% 1.1% 0.1% B16..8: 42.1% 8.3% 1.9% direct: 5.7% skip:40.5% L0:42.1% L1:43.2% BI:14.7%
x264 [info]: 8x8 transform intra:77.8% inter:79.7%
x264 [info]: direct mvs spatial:99.9% temporal:0.1%
x264 [info]: coded y,uvDC,uvAC intra: 69.0% 74.2% 46.0% inter: 20.2% 25.9% 2.3%
x264 [info]: i16 v,h,dc,p: 53% 15% 15% 17%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 9% 23% 7% 10% 12% 8% 10% 8%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 6% 5% 9% 17% 20% 11% 12% 8%
x264 [info]: i8c dc,h,v,p: 45% 22% 20% 13%
x264 [info]: Weighted P-Frames: Y:1.4%
x264 [info]: ref P L0: 52.3% 11.8% 18.8% 7.9% 7.1% 2.2% 0.0%
x264 [info]: ref B L0: 85.0% 11.0% 3.1% 1.0%
x264 [info]: ref B L1: 94.4% 5.6%
x264 [info]: PSNR Mean Y:44.597 U:47.413 V:49.679 Avg:45.486 Global:44.761 kb/s:1619.05
encoded 2000 frames, 8.25 fps, 1619.12 kb/s
How's PSNR Avg and Global calculated? Or, where do these Y/U/V mean averages come from?
We've got YUV 4:2:0, so if I take the PSNR Mean values and calc (4*Y44.597+U47.413+V49.679)/6 I get a wrong(?) value: 45.91333
Blue_MiSfit
7th May 2010, 19:25
If you want to see how x264 does with PSNR, then --tune psnr or --tune ssim (for SSIM obviously).
Don't use these in the real-world, since psy optimizations reduce PSNR but increase subjective quality a lot :)
We're NOT getting into YET ANOTHER subjective vs objective battle. Please no....
~MiSfit
Hmm, I personally wanted to compare compression efficiency. If this has been discussed so many times, could you point me to a related thread, please?
Unfortunately, Dark Shikari's new post leaves me a little baffled. Can be found here: http://forum.doom9.org/showthread.php?p=1397861#post1397861You should never use --no-psy. [...] Use --psy-rd 0, not --no-psy, because the latter does other things that you probably don't want. Of course, --tune ssim also implies --no-psy.
So, I shall not use --no-psy (which's implied by --tune <psnr|ssim>)?
Or is it still OK for my intention to compare raw compression efficiency?
(I know, that comparing compression efficiency of course doesn't imply equal efficiency when using psy)
If you want to compare by psnr or ssim you need to apply the tune switches. The result will indicate how efficient x264 would be if good psnr or ssim values were the goal.
psy is intended to ruin psnr and ssim to improve visual quality since neither of these metrics are equal to the human eyes and brains perception.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.