Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 10th February 2021, 23:41   #1  |  Link
YaBoyShredderson
Registered User
 
Join Date: Jul 2020
Posts: 76
Minimum and maximum QP with 2 pass ABR

Ok, let me try to explain my intentions with this.

The benefit of CRF is that no matter what video you encode, the same level of quality will come out the other end (assuming equal quality sources). The downside is that the file size is entirely unpredictable.

The benefit of ABR is that the file size is predictable, but the quality isnt. Easily compressible content will come out bloated, and difficult to compress content will come out degraded.

My thought with this is to use the minimum and maximum QP settings to allow easily compressed content to compress more than the set bitrate would typically allow, and it would allow hard to compress content to be higher in bitrate, with all the regular stuff coming out where i want it.

This way, my thinking is this will have everything come out at the same bitrate, EG 7mbits, but will allow the extreme outliers a bit of leaway. The easy stuff will be, say 5 mbits, and the harder stuff will be maybe 10.

Have i got this right? Will it just shift the average up or down if i do this? Or am i missing something?
YaBoyShredderson is offline   Reply With Quote
Old 11th February 2021, 01:45   #2  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
No, it will not just shift the average up or down. All that does is clip the value if the encoder wants to go above or below the QP limits.

It would limit how far above or below the average could go but to have any effect with real content it would need to be set too restrictive. You would get a lot of blocks that looked terrible (difficult to compress) while also allocating extra bits to blocks that don't need it (easily compressed). The encoder will also use much lower QPs for blocks that get referenced a lot and much higher QPs for non-reference B-frames.

These QP values will be much lower and higher than the average, so to have clipping the min/max QP significantly affect the file size you need to set them very restrictive which then destroys most of the benefit of the rate control. It moves you toward a constant QP rate control, i.e. less quality for larger file sizes.

If you want a specific size use two pass. If not use CRF. That the file size is entirely unpredictable with crf is a feature, you don't want to waste bits or have any videos look terrible do you?

Edit: An example for why raising the minimum QP just a bit does not really change the average QP. The few I frames that would have used that lower QP now get forced to use a higher one. This means future blocks that use that frame as a reference will have more significant difference blocks, requiring a lower QP for the same quality in all those blocks. This value will not get clipped because it is still much higher than the QP the I frame would have used. This can reduce the final quality with no change in the final size (or the final size could be slightly smaller or even increase, it depends on the source, but it will always be lower quality per bit).
__________________
madVR options explained

Last edited by Asmodian; 11th February 2021 at 01:57.
Asmodian is offline   Reply With Quote
Old 11th February 2021, 09:46   #3  |  Link
YaBoyShredderson
Registered User
 
Join Date: Jul 2020
Posts: 76
Quote:
Originally Posted by Asmodian View Post
No, it will not just shift the average up or down. All that does is clip the value if the encoder wants to go above or below the QP limits.

It would limit how far above or below the average could go but to have any effect with real content it would need to be set too restrictive. You would get a lot of blocks that looked terrible (difficult to compress) while also allocating extra bits to blocks that don't need it (easily compressed). The encoder will also use much lower QPs for blocks that get referenced a lot and much higher QPs for non-reference B-frames.

These QP values will be much lower and higher than the average, so to have clipping the min/max QP significantly affect the file size you need to set them very restrictive which then destroys most of the benefit of the rate control. It moves you toward a constant QP rate control, i.e. less quality for larger file sizes.

If you want a specific size use two pass. If not use CRF. That the file size is entirely unpredictable with crf is a feature, you don't want to waste bits or have any videos look terrible do you?

Edit: An example for why raising the minimum QP just a bit does not really change the average QP. The few I frames that would have used that lower QP now get forced to use a higher one. This means future blocks that use that frame as a reference will have more significant difference blocks, requiring a lower QP for the same quality in all those blocks. This value will not get clipped because it is still much higher than the QP the I frame would have used. This can reduce the final quality with no change in the final size (or the final size could be slightly smaller or even increase, it depends on the source, but it will always be lower quality per bit).
Ah that makes sense, just in idea i had. Thanks.
YaBoyShredderson is offline   Reply With Quote
Old 11th February 2021, 12:25   #4  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
Quote:
Originally Posted by YaBoyShredderson View Post
Ah that makes sense, just in idea i had. Thanks.
It is not a bad idea at the start.

It just doesn't work well with the way QPs are used by modern encoders.
__________________
madVR options explained
Asmodian is offline   Reply With Quote
Old 12th February 2021, 18:33   #5  |  Link
YaBoyShredderson
Registered User
 
Join Date: Jul 2020
Posts: 76
Quote:
Originally Posted by Asmodian View Post
It is not a bad idea at the start.

It just doesn't work well with the way QPs are used by modern encoders.
Given that my idea wont work too well in practice, what x265 crf results in an average of 6-7mbits roughly speaking? Obviousl it would vary by content, and also preset i think. Ball park estimate though, across all kinds of content?

Or, whatever crf+preset is most similar to x264 high profile crf 18 veryslow in terms of quality.

Last edited by YaBoyShredderson; 12th February 2021 at 18:44. Reason: Additional information.
YaBoyShredderson is offline   Reply With Quote
Old 12th February 2021, 20:04   #6  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,843
Quote:
Originally Posted by YaBoyShredderson View Post
Given that my idea wont work too well in practice, what x265 crf results in an average of 6-7mbits roughly speaking? Obviousl it would vary by content, and also preset i think. Ball park estimate though, across all kinds of content?

Or, whatever crf+preset is most similar to x264 high profile crf 18 veryslow in terms of quality.
A CRF of 18 in x264 corresponds to a CRF of 21-22 in x265. Keep in mind that the mapping of CRF in x264 and x265 is not 1:1
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is online now   Reply With Quote
Old 12th February 2021, 21:41   #7  |  Link
YaBoyShredderson
Registered User
 
Join Date: Jul 2020
Posts: 76
Quote:
Originally Posted by microchip8 View Post
A CRF of 18 in x264 corresponds to a CRF of 21-22 in x265. Keep in mind that the mapping of CRF in x264 and x265 is not 1:1
Yh not 1:1 makes sense. Do those numbers make sense no matter what preset i use tho? I noticed bitrates tend to increase when going slower with x265, and the opposite with x264.
YaBoyShredderson is offline   Reply With Quote
Old 12th February 2021, 23:47   #8  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,750
Quote:
Originally Posted by YaBoyShredderson View Post
Yh not 1:1 makes sense. Do those numbers make sense no matter what preset i use tho? I noticed bitrates tend to increase when going slower with x265, and the opposite with x264.
Generally the slower presets can look better at the same CRF than faster presets.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 13th February 2021, 11:13   #9  |  Link
YaBoyShredderson
Registered User
 
Join Date: Jul 2020
Posts: 76
Quote:
Originally Posted by benwaggoner View Post
Generally the slower presets can look better at the same CRF than faster presets.
Yes i know but the bitrates tend to increase with a disproportionatly large increase in quality. X264 the slower the preset the bitrates go down, with a disproportionatly small decrease in quality.
YaBoyShredderson is offline   Reply With Quote
Old 13th February 2021, 15:10   #10  |  Link
excellentswordfight
Lost my old account :(
 
Join Date: Jul 2017
Posts: 322
Quote:
Originally Posted by YaBoyShredderson View Post
Given that my idea wont work too well in practice, what x265 crf results in an average of 6-7mbits roughly speaking? Obviousl it would vary by content, and also preset i think. Ball park estimate though, across all kinds of content?

Or, whatever crf+preset is most similar to x264 high profile crf 18 veryslow in terms of quality.
You have all the tools you need, why dont you just try it out? You havnt even said what you are going to encode... VHS? DVDs? Blurays? Home videos? Its much easier just to do some tests to see what works for you, we dont know your quality preferences, we dont know your limit when it comes to encoding time vs compression etc etc.

Eitherway... If we assume that you are going to re-encode 1080p SDR blurays, then some ballpark answer would be that preset slow, crf 18-19, no-sao would be rather close to crf 18 veryslow @ maybe a 25% size reduction and would be in the 5-7Mbps range.

And yes, the behavior in x265 is that the slower the preset, the higher the bitrate @ the same crf level. As CRF can only be used as a constant quality metrical @ the same settings, you should always do your tests when trying to find out settings and quality with 2pass (if you are going to compare different encoders and or settings), when you find the settings and bitrate you are happy with tune in an crf value that ends up in the same bitrate level as your 2pass tests.

Last edited by excellentswordfight; 13th February 2021 at 16:03.
excellentswordfight is offline   Reply With Quote
Old 13th February 2021, 16:37   #11  |  Link
YaBoyShredderson
Registered User
 
Join Date: Jul 2020
Posts: 76
Quote:
Originally Posted by excellentswordfight View Post
You have all the tools you need, why dont you just try it out? You havnt even said what you are going to encode... VHS? DVDs? Blurays? Home videos? Its much easier just to do some tests to see what works for you, we dont know your quality preferences, we dont know your limit when it comes to encoding time vs compression etc etc.

Eitherway... If we assume that you are going to re-encode 1080p SDR blurays, then some ballpark answer would be that preset slow, crf 18-19, no-sao would be rather close to crf 18 veryslow @ maybe a 25% size reduction and would be in the 5-7Mbps range.

And yes, the behavior in x265 is that the slower the preset, the higher the bitrate @ the same crf level. As CRF can only be used as a constant quality metrical @ the same settings, you should always do your tests when trying to find out settings and quality with 2pass (if you are going to compare different encoders and or settings), when you find the settings and bitrate you are happy with tune in an crf value that ends up in the same bitrate level as your 2pass tests.
Im doing some tests at the moment, the reason im asking is that testing can take a long time. Ball park figures make it much quicker. But yes i am encoding 1080p blurays. Crf 18 is far too high at veryslow. Ill see if i can tell the difference at a faster preset/higher crf.
YaBoyShredderson is offline   Reply With Quote
Reply

Tags
2 pass, abr, crf, hevc, quantisation parameter

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:48.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.