1

Choosing the best CRF value for Capped CRF encoding

Jan Ozer
February 3, 2020

In a blog full of unstable compressed articles, this may be the most unstable article of all articles. If you do not use capped CRF encoding, or consider using the same encoding, you will almost certainly not be interested in it. However, if you use the upper limit CRF encoding (for constant rate factor), you will almost certainly find it interesting and possibly even enlightening.

Quick background description. At the end of last year, I consulted a large OTT store that used the upper limit CRF code with a CRF value of 19 for the top files in the coding ladder. Most of the analysis shown below is for this customer (he approved my discussion in an article). I haven't written this article yet because I think it is too obscure for most readers.

However, this morning, I downloaded a video from Vimeo and noticed that they were encoded using the upper limit CRF with a CRF value of 20, as you can see in MediaInfo below. Why am I playing Vimeo? Because they made a big promise a few months ago that they will use the AV1 codec to encode product selections. I will download a file regularly to see if this is the case; so far, there is no AV1 encoding. This does not mean that Vimeo does not use AV1, it may be that my download tool does not capture AV1 encoding at all.

However, I did notice that Vimeo uses CRF 20, which, IMHO, is sub-optimal and prompted the resurrection of this article. There is no disrespect for Vimeo, he has an excellent team of coding professionals. But this is what I think and why.

image.png

As a background, most producers use capped CRF as a DIY per-title encoding technique. When you use CRF and unlimited encoding, FFmpeg will prioritize quality rather than bit rate, and change the bit rate to provide the specified quality, ranging from 1 to 51, with lower numbers providing higher quality. Please refer to here for a complete description of the capped CRF including the FFmpeg command line. CBR and VBR encode the opposite, and adjust the quality to meet the specified data rate.

Of course, you cannot use CRF-only encoding for streaming media, because limiting the data rate is the key to deliverability. Therefore, you add an upper limit or maximum bit rate. To generate the upper limit CRF, you need to specify the CRF value as well as the maximum rate and buffer size, which are also highlighted in the MediaInfo screen above. Essentially, Vimeo tells FFmpeg to encode a CRF value of 20, the maximum rate is 5500, and the VBV buffer is 15000 (for more information on VBV buffers, see here ).

One of the files I downloaded is Light Speed, which is displayed in the Bitrate Viewer below. You will see that the average bit rate is about 4664 kbps, but the average data rate (shown by the light blue line) is above 5 Mbps most of the time. When there is enough space below the line, such as those pointed to by the line controlled by the CRF, it means that the CRF is setting the quality level. When the data rate is pushed to 5.5 Mbps, this is the upper limit of the enforced limit.

image.png

Visual capping crf encoding

What's wrong with using CRF 20? Well, if you don't care about spending too much on bandwidth, it's nothing. However, if you use capped CRF to reduce the bandwidth of easy-to-encode videos, you may be able to use a higher value (and provide a slightly lower quality) and reduce the bandwidth without anyone noticing.

VMAF 93 = good enough

Several points on VMAF, I will mention later. First of all, as RealNetworks CTO Reza Rassool built on here , a VMAF score of 93 points means that "the vast majority of viewers at will find that the content either indistinguishable from the original content or has obvious but not annoying distortion." , If your score is 93-95, your video may be "good enough." If it is higher, then you are spending money to provide additional quality that no one will notice.

Another point about VMAF is that the average score of VMAF in the test video used in my book Video Encoding by the Numbers using CRF 23 and x264 encoding is 95.96, as shown in the following table. Therefore, if you use CRF 20, you are almost certain that the VMAF quality you provide is higher than 93-95 (because lower CRF values provide higher quality). This means that the data rate of all the videos you distribute may be too high, or at least higher than it needs.

You can see this in the table below, which shows most of the same clips encoded in CRF 19, with an upper limit of 5 Mbps. The easy-to-encode video whose data rate is mainly controlled by the CRF value has a CMAF score of 96.90, which is unnecessarily high. The hard-to-encode videos controlled by the upper limit are still north of 93, so their quality is not bad.

image.png

What happens when you use a higher CRF value with the same upper limit? As shown below (click the table to view it in full resolution). In CRF 23, you reduced the data rate of easy-to-encode videos by 33%, while reducing VMAF from 96.9 to 96.15, which is irrelevant. As a result, you have achieved a key goal of encoding by title, which is to reduce the data rate of videos that are easy to encode.

image.png

For videos that are difficult to encode, the data rate and quality increment between CRF 19 and CRF 23 is much lower, because the upper limit of the data rate controls the bit rate and quality of these clips, not CRF. Nevertheless, under CRF 23, you reduce the bit rate by 8.57%, but only reduce the VMAF score from 94.68 to 94.41.

Most importantly, if you use the upper limit CRF for encoding and your CRF value is less than 23, then you may waste bandwidth on easy-to-encode clips. Run some tests on CRF 23 to see how this affects bandwidth and significant quality.

image.png

For more information on calculating and using video quality indicators, I have a video course that contains more than 3 hours of video instruction. For more information about the course, click here .


Yujiaao
12.7k 声望4.7k 粉丝

[链接]