View Full Version : Is --b-adapt 2 worth it?
iSeries
9th November 2010, 17:19
Hi,
I just wondered what the general opinion of --b-adapt 2 was? I've been using the --preset slow option, which has --b-adapt 2 by default. I've been thinking about adding --b-adapt 1 to the command line as I've found --b-adapt 2 greatly slows down encoding, and to be honest I really can't tell the difference!
Does anyone notice any meaningful benefit using --b-adapt 2?
Groucho2004
9th November 2010, 17:34
and to be honest I really can't tell the difference!
If you can't tell the difference then there isn't really a point in using it, is there? :rolleyes:
iSeries
9th November 2010, 17:37
That may be so - but thats not my question is it! I'm asking for other people's opinions and whether THEY see a difference...
Groucho2004
9th November 2010, 17:40
I can't really tell the difference. :)
burfadel
9th November 2010, 19:05
Its not about seeing a difference at all! its about optimising the use of b-frames. --b-adapt 1 is a blind method, and usually you only get only a couple of b-frames even when set to 16. --b-adapt 2 is a smarter method, whereby a forward search is done to see the usefulness of the b-frames. --b-adapt 2 usually ends up with more b-frames used and hence more efficient encoding. The slowdown is relative to the number of b-frames set, such that if you set it to a respectful 4 b-frames it will be quite fast, but if you set it to 16 you will get a noticeable slowdown and no real advantage.
So, setting the maximum b-frames to a typical figure to suit your needs is important. If you're not constrained by compatibility with certain devices (whereby if the device calls for a maximum consecutive b-frames as 3, you should set --b-adapt 2 and -bframe 3), you can try encoding a couple of minutes from a number of shows, and have --b-adapt 2 and a high b-frame count (say, 10 set), and check the final test output from x264. There will be a line that reads (for instance):
x264 : consecutive B-frames: 2.5% 4.1% 13.6% 38.3% 24.1% 15.4% 2.0%
where the number of consec. are[I] 0 1 2 3 4 5 6
So, in the above example from one of my recent encodings, having 6 bframes set wasn't really much of an advantage due to such a low utilisation, if 6 wasn't set those would have been distributed amongst the other figures (hope that makes sense). If I had set 10 b-frames, the 7-10 percentages probably would have been 0 or very close too. The first number is 0, since thats the perfentage of single b-frames. Remember, you can't have just 1 b-frame thats consecutive! - so in fact the optimum (purely my suggestion, try it for yourself ;)!) of 5 is actually 6 b-frames in a row, as its 5 consecutive after the first...
So, after doing your encodings, count the first number as 0, the second number 1, and so on. Use the number thats on average, the highest one that gives you a good percentage of utilisation. In my example, that would be 5. By this, I don't mean setting it to 1 lol.
Now, for CRF you won't really see the difference between --b-adapt 1 and the better b-frame utilisation of --b-adapt 2, but you will see a reduction in filesize. In ABR mode (2-pass) (or CBR 1-pass, which really should be avoided) modes, there may be a quality increase, since more b-frames are utilised and remembering that in CRF mode the filesize was smaller, more bitrate can go to other frames and hence a potential quality increase :)
I have found the optimum number (discounting any use on constricted portable devices) is 5
iSeries
9th November 2010, 19:24
Thank you burfadel for the explanation - it all makes sense. I'm limited to 3 b frames as I'm maintaining blu ray compatibility - but I'm also using CRF (20). With regards to smaller filesize, in your experience what is the average reduction using --b-adapt 2 over --b-adapt 1? In one test I did, encoding an episode of "Spartacus: Blood and Sand" with --b-adapt 1 gave a file size of 5.7gb, and encoding with --b-adapt 2 gave me 5.69gb, so not much of a reduction! Are there any particular scenarios where --b-adapt 2 would make a bigger difference?
creamyhorror
9th November 2010, 19:39
In one test I did, encoding an episode of "Spartacus: Blood and Sand" with --b-adapt 1 gave a file size of 5.7gb, and encoding with --b-adapt 2 gave me 5.69gb, so not much of a reduction!
But you generally gain a bit of quality. Check the SSIM value, it might indicate as much.
Using a constant CRF value but changing other settings generally does not equate to achieving the same quality.
sneaker_ger
9th November 2010, 19:44
Thank you burfadel for the explanation - it all makes sense. I'm limited to 3 b frames as I'm maintaining blu ray compatibility - but I'm also using CRF (20). With regards to smaller filesize, in your experience what is the average reduction using --b-adapt 2 over --b-adapt 1? In one test I did, encoding an episode of "Spartacus: Blood and Sand" with --b-adapt 1 gave a file size of 5.7gb, and encoding with --b-adapt 2 gave me 5.69gb, so not much of a reduction! Are there any particular scenarios where --b-adapt 2 would make a bigger difference?
CRF means same quality for same settings, so your comparison is meaningless.
/edit: too late again...
iSeries
9th November 2010, 19:49
Sorry if I'm being thick but I don't understand how the comparison is meaningless if I encode once at CRF 20 with --b-adapt 1 and again at CRF 20 with --b-adapt 2? Are you saying that --b-adapt 2 makes NO difference when using CRF? If that's the case why both even with --b-adapt 1?
Dark Shikari
9th November 2010, 19:52
Better encoding options aren't about improving quality, they're about improving compression. It just happens that if you keep the size the same, better compression means better quality.
burfadel
9th November 2010, 20:14
Its not only file reduction thats the issue, its also the actual output quality. For instance, using --aq-mode 2, setting a low psy-trellis, say 0.2/0.3, setting --subme 10, etc will all affect the actual quality at the same CRF, the filesize is only one indicator. SSIM and PSNR are others, but not really useful when using psy etc. The main thing is the quality of the actual output, from the finest of details, to the darkest scenes and highest motion areas. I wouldn't have expected too much of a slowdown with only 3-bframes set using --b-adapt 2. Actually all of the above settings (--aq-mode 2, --subme 10 etc) will all affect the b-frame usage, and I believe setting of the above will... improve the b-frame usage. Those settings would be very very slow for 1920x1080 video though.
Just setting the preset to slower and b-frames to 3 won't make it fully bluray compatible, you also should set (according to the settings from Staxrip, preset slow, device bluray:
--level 4.1 --keyint 48 --open-gop normal --nr 400 --b-pyramid strict --vbv-bufsize 30000 --vbv-maxrate 40000 --aud --slices 4 --nal-hrd
In terms of speed, since you are only interested in 3 b-frames, the blind method may actually suffice! any higher then --b-adapt 2 becomes much more effective. If the slowdown when --b-adapt 2 is set is greater than the slowdown from going from --subme 8 to 9 or even 10, then in this scenario, setting the higher --subme could be more effective. In addition to this, if setting trellis to 2, and using slight psy-trellis (say 0.2), in addition to the --subme 9/10 change still proves to be the same or faster than using --b-adapt 2, I'd set those instead if the slowdown is an issue.
When getting to such high settings, it becomes more an issue of personal preference...
If using avisynth input, using Avisynth MT can be very beneficial I've found, this should reduce the avisynth bottleneck and some have found it to be very effective. A recent post in the avisynth 2.5.8 MT thread I believe, someone said they went from 8fps to 11fps (I would find it, but its 5:45am Wednesday here and I'm leaving shortly!). That may not sound like much, but its is a 37.5 percent speed boost!
ajp_anton
9th November 2010, 22:08
The first number is 0, since thats the perfentage of single b-frames. Remember, you can't have just 1 b-frame thats consecutive! - so in fact the optimum (purely my suggestion, try it for yourself ;)!) of 5 is actually 6 b-frames in a row, as its 5 consecutive after the first...
The first number is for 0 consecutive b-frames, meaning I/P-frames with no B's inbetween. 2nd number is for single b-frames between I/P-frames, etc.
ImmortAlex
10th November 2010, 04:29
By the way, in most of my encodes (movie rips, HD and SD) final b-frames distribution list shows big drop after 6th position, like in burfadel's example. I.e. --b-adapt 2 --bframes 5 can be usefull, more than 5 is useless most of time.
But number of b-frames in x264 presets rises from 3 in "slower" to 8 in "veryslow". So may be developers consider set --bframes 5 with --preset slower or --tune film?
Audionut
10th November 2010, 05:57
Here is a snippet of some results I posted on another site.
--keyint 240 --bframes 8 --open-gop normal
SSIM Mean Y:0.9875865 (19.061db)
x264 [info]: PSNR Mean Y:46.114 U:48.973 V:49.340 Avg:46.893 Global:46.527
encoded 5000 frames, 18.05 fps, 6006.39 kb/s
--keyint 240 --bframes 8 --b-adapt 2 --open-gop normal
SSIM Mean Y:0.9878675 (19.161db)
x264 [info]: PSNR Mean Y:46.186 U:49.090 V:49.479 Avg:46.977 Global:46.606
encoded 5000 frames, 17.30 fps, 6002.88 kb/s
On this source which I forget what it was (would have been a blu-ray film of some description), slightly smaller bitrate and decent increase in SSIM with b-adapt 2.
edit: ah the source was avatar, --seek 20000 --frames 5000
Blue_MiSfit
10th November 2010, 08:45
Tests involving PSNR or SSIM should be done with the --tune parameter set accordingly
Audionut
10th November 2010, 09:11
Just because I post SSIM and PSNR results doesn't mean I need to "tune" for them.
This is a real world example of the differences between --badapt 1 and --b-adapt 2.
GodofaGap
10th November 2010, 09:46
Yes, but you are using settings that don't optimize for SSIM. If you agree that SSIM is not a good measurement of quality on beforehand (since you didn't use SSIM tuning), then you cannot use it as a measurement of quality afterwards either.
LoRd_MuldeR
12th November 2010, 00:55
Yes, but you are using settings that don't optimize for SSIM.
Even worse. If you don't disable the Psy optimizations you are using settings that intentionally hurt metrics like SSIM/PSNR ;)
Such metrics can't provide a reliable prediction for the overall perceived quality anyway, but with Psy optimizations enabled they are completely misleading...
This is a real world example of the differences between --badapt 1 and --b-adapt 2.
If you want to compare the efficiency of "--badapt 1" vs. "--b-adapt 2" with respect to PSNR or SSIM, you still should disable the Psy optimizations in order to get meaningful results.
Not that a higher efficiency with respect to PSNR and/or SSIM necessarily implies better perceived quality...
Audionut
12th November 2010, 02:15
If you want to compare the efficiency of "--badapt 1" vs. "--b-adapt 2" with respect to PSNR or SSIM, you still should disable the Psy optimizations in order to get meaningful results.
Indeed, that makes sense.
Bill Ein
25th April 2014, 17:51
I have a big problem with blending in chroma after encoding anime. Only one thing realy fix it for 10bit (with psy-rd): b-adapt=1.
LoRd_MuldeR
25th April 2014, 19:08
I have a big problem with blending in chroma after encoding anime. Only one thing realy fix it for 10bit (with psy-rd): b-adapt=1.
Please don't cross post!
http://forum.doom9.org/showthread.php?t=170387
~closed~
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.