Log in

View Full Version : A list for the maximum allowed vbv-bufsize & vbv-maxrate per level


takla
8th August 2022, 09:32
I forced ffmpeg to show me some values (by specifying way too high values it showed me the maximum)

Here you go, if anyone else needs this.
https://docs.google.com/spreadsheets/d/e/2PACX-1vT6iaRc25bYPV5xQlZANlr68fkbl29rEn5ma1aKyOG4-Szs1I4F68997YYHyGwxw0VPgtt0Ggz3mcwd/pubhtml

Any reason why I shouldn't always use the highest allowed vbv-bufsize? After all, if a device supports a given level, it would also need to support the maximum possible bufsize.

The reason why I do this in the first place is, I measured the difference in VMAF, and using the highest allowed vbv-bufsize always had better scores.

In my tests (1920x1080p60 8000CBR preset medium), the worst frames improved by up to 5.5% at the cost of 1.3% encoding speed.
That was a higher improvement then going from preset medium to preset slow.

Medium: Average: 87.422148 Worst: 54.726831
Slow: Average: 87.610072 Worst: 54.896813
Medium+maximum vbv-bufsize: Average: 87.828082 Worst: 57.739257

Selur
9th August 2022, 16:49
What's wrong with the values from
https://en.wikipedia.org/wiki/Advanced_Video_Coding#Levels
https://en.wikipedia.org/wiki/Advanced_Video_Coding#Decoded_picture_buffering
?

benwaggoner
9th August 2022, 17:43
Any reason why I shouldn't always use the highest allowed vbv-bufsize? After all, if a device supports a given level, it would also need to support the maximum possible bufsize. The reason why I do this in the first place is, I measured the difference in VMAF, and using the highest allowed vbv-bufsize always came out ahead.
Using the max allowed vbv-bufsize for Profile @ Level is a good default.

There are a few reasons why someone would lower it

Reducing it by a bit to give some headroom to make SURE it is VBV compliant.
Making an adaptive streaming multiple bitrate ladder and wanting to get a good distribution of fragment sizes per segment.
Encoding for real-time playback over potentially slower network conditions.
Targeting a specific platform with different limits. For example, Blu-ray supports H.264 up to 40 Mbps.
Content has some very difficult to encode sections that will always consume the max bitrate, starving other, easier parts of the title and reducing the overall quality of experience.


But for local file playback, yeah using the max values offers the most flexibility to the encoder to redistribute bits to minimize quality fluctuations.

takla
10th August 2022, 01:18
What's wrong with the values from
https://en.wikipedia.org/wiki/Advanced_Video_Coding#Levels
https://en.wikipedia.org/wiki/Advanced_Video_Coding#Decoded_picture_buffering
?

None of those values are for Profile: High

Using the max allowed vbv-bufsize for Profile @ Level is a good default.

There are a few reasons why someone would lower it

Reducing it by a bit to give some headroom to make SURE it is VBV compliant.
Making an adaptive streaming multiple bitrate ladder and wanting to get a good distribution of fragment sizes per segment.
Encoding for real-time playback over potentially slower network conditions.
Targeting a specific platform with different limits. For example, Blu-ray supports H.264 up to 40 Mbps.
Content has some very difficult to encode sections that will always consume the max bitrate, starving other, easier parts of the title and reducing the overall quality of experience.


But for local file playback, yeah using the max values offers the most flexibility to the encoder to redistribute bits to minimize quality fluctuations.

All good reasons. Thanks for sharing👍
My use case here was real-time streaming. In this case, I don't think device compatibility will be an issue with Level 4.2 in 2022😉

Selur
10th August 2022, 02:19
None of those values are for Profile: High
iirc. for
* High, maxBitrates should be multiplied by 1.25
* High10, maxBitrates should be multiplied by 3
* High422/High444, maxBitrates should be multiplied by 4
and Buffers should be multiplied by 3

takla
10th August 2022, 14:16
iirc. for
* High, maxBitrates should be multiplied by 1.25
* High10, maxBitrates should be multiplied by 3
* High422/High444, maxBitrates should be multiplied by 4
and Buffers should be multiplied by 3

But that already fails to be true:

The maximum allowed bitrate with Level 4.2 for Constrained Baseline, Baseline, Extended and Main is 50000 and 50000*1.25 is 62500 or 50000*3 is 150000, when in reality, the maximum vbv-bufsize for profile=high is 78125.

You are just making numbers up. I already added all real max values for relevant levels as a link to the OP, which you seems to have missed.

rwill
10th August 2022, 16:50
But that already fails to be true:

The maximum allowed bitrate with Level 4.2 for Constrained Baseline, Baseline, Extended and Main is 50000 and 50000*1.25 is 62500 or 50000*3 is 150000, when in reality, the maximum vbv-bufsize for profile=high is 78125.

You are just making numbers up. I already added all real max values for relevant levels as a link to the OP, which you seems to have missed.

You are mixing bitrate and CPB size. If you don't trust Wikipedia at least be pro enough and go to www.itu.int, download the H.264 standard and run the numbers yourself.

Selur
10th August 2022, 16:53
I don't think I made them up (I collected that data 10+years ago), but to be sure I did a quick search. :)
According to the specification T-REC-H.264-200503-S (https://www.itu.int/rec/T-REC-H.264-200503-S; document was superseded but the restrictions stayed the same afaik.)
A.3.1 Table A-1 for limits for the Baseline, Main, and Extended profiles
A.3.3 Table A-2 for the "Specification of cpbBrVclFactor and cpbBrNalFactor"
I should be correct, https://forum.doom9.org/showthread.php?p=1215709#post1215709 does seem to agree with me too.
Profile | cpbBrVclFactor | cpbBrNalFactor
High | 1250 | 1500
High 10 | 3000 | 3600
High 10 Intra | 3000 | 3600
High 4:2:2 | 4000 | 4800
High 4:2:2 Intra | 4000 | 4800
High 4:4:4 Predictive | 4000 | 4800
High 4:4:4 Intra | 4000 | 4800
CAVLC 4:4:4 Inta | 4000 | 4800
=> if you find a specification that specified different cpbBrVclFactor and cpbBrNalFactor please let me know and please share a link.

Cu Selur

Ps.: but maybe I understood you wrong for what you are looking for and you are looking for something totally different ¯\_(ツ)_/¯

takla
11th August 2022, 03:19
If you use ffmpeg, and specify a vbv-bufsize, vbv-maxrate & bitrate of something ridiculous like 800k, as well as a profile and level, it will tell you the correct max values for bitrate and buffer. All of these values can be found in the google sheet link in the OP. I'm no longer looking for these values. Thanks anyways.

MasterNobody
11th August 2022, 08:41
Why don't you want to just open the H.264 specs?
And just multiply by 1.25 for the High profile.

https://i.postimg.cc/1RCFvrcK/levels.png (https://postimg.cc/BtFt6Dz8)

takla
11th August 2022, 10:51
Why don't you want to just open the H.264 specs?
And just multiply by 1.25 for the High profile.

https://i.postimg.cc/1RCFvrcK/levels.png (https://postimg.cc/BtFt6Dz8)

I actually did try to find it in pdf.
1) There are dozens of pages labeled as "levels and profiles".
2) How should I have known to multiply those values by 1.25 (Why don't they show the values directly in the docs?)

excellentswordfight
11th August 2022, 13:46
I actually did try to find it in pdf.
1) There are dozens of pages labeled as "levels and profiles".
2) How should I have known to multiply those values by 1.25 (Why don't they show the values directly in the docs?)
There are different sections for lower profiles (i.e. Baseline, Constrained Baseline, Main, or Extended) and higher ( High, Progressive High, Constrained High, High 10, Progressive High 10, High 4:2:2, High 4:4:4 Predictive, High 10 Intra, High 4:2:2 Intra, High 4:4:4 Intra, or CAVLC 4:4:4 Intra). If you look at A.3.3 Profile-specific level limits you will find this:

In bitstreams conforming to the High, Progressive High, Constrained High, High 10, Progressive High 10,
High 4:2:2, High 4:4:4 Predictive, High 10 Intra, High 4:2:2 Intra, High 4:4:4 Intra, or CAVLC 4:4:4 Intra
profiles, for the VCL HRD parameters, BitRate[ SchedSelIdx ] <= cpbBrVclFactor * MaxBR and
CpbSize[ SchedSelIdx ] <= cpbBrVclFactor * MaxCPB for at least one value of SchedSelIdx, where
cpbBrVclFactor is specified in Table A-2 and BitRate[ SchedSelIdx ] and CpbSize[ SchedSelIdx ] are given as
follows

Which are refering to the values in Table A-2 which Selur posted.

But I dont see anything about 3x for buffsize, shoudlnt it just be MaxCPB table and x 1,25 there as well?