CRF is an encoding standard. About CQP it is written everywhere that it is not for use, it is for experiments. But I compared the results of their coding. CQP made a sharper picture. CRF breaks the "mosaic" of the image. CQP makes the result much closer to the original. I tested on several images. Example:
Codec: x264, 0.164.3094+13-7816202-.Mod-by-Patman.-x64-gcc11.2.0.
Container: MP4Box, 2.1-DEV-rev79-gdf29bc8a0-x64-gcc11.3.0 Patman.
I set different quantization so that the file sizes match. If the quantization is the same, the difference is even more visible.
1) CRF 25, 5.7mb
2) CQP 28, 5.3mb
https://imgsli.com/MTgxMzA0
+ Reply to Thread
Results 1 to 30 of 61
Thread
-
-
CQP is constant quantization factor - bitrate is not controlled at all - it is pure VBR - fastest possible and easiest to implement - quite frequently implemented in simple hardware encoders.
-
Yes I know that. Why does CRF give the worst result? Moreover, CRF is the standard of use, and CQP is not taken seriously.
-
It is not very meaningful to compare single frames only.
Simply speaking, CRF aims at obtaining a constant visual quality experience for watching a movie, means it 'blurs' certain scenes where a viewer would not notice the lower quality (e.g. fast action, low details), and spends the bits at other scenes instead where the viewer will more easily notice any quality deficiencies (more static scenes with more details). CRF adjusts the quantizer dynamically.
CQ (constant quantizer) does not make this difference. Hence for same viewing experience CRF is more efficient and will typically produce smaller file size.
--cq 0 and --crf 0 are equivalent and produce lossless encodes btw.Last edited by Sharc; 25th May 2023 at 06:30.
-
I did not find such frames where CRF would be much better. But there are many frames where CQP is better. It is important that CRF not only blurs the image, it seems to change the picture, move the cells of the image parts. And I see it when watching a video, and not when I watch individual frames.
-
Also no AQ for CQ. Look especially at AQ sensitive areas such as flat regions, shadow areas - those areas will be blurred by CQ because the quantization will be higher
Post your source - it might be your scene is too short, or selective content, or you made maybe you made a mistake , or maybe you're comparing I frame vs. B frame . -
Post your source
https://drive.google.com/file/d/1dN6aGIcgFzj8S1-VAtJAn5dn2-j7j6U8/view?usp=share_link -
Your source seems to be a WhatsApp highly compressed video with low details. Not particularly the best footage to test and compare encoders .....
-
I have many of these videos. What conclusions can be drawn? CQP is better, but CRF makes file size smaller?
-
CRF gives normally better overall perceived quality at same file size. CRF is more efficient. It assigns the bits more intelligent. But at the end just do what you find is more pleasing to your eyes and keep in mind that every re-encode will basically reduce the quality - unless you go for lossless encoding.
See also here for example:
https://slhck.info/video/2017/03/01/rate-control.html
https://slhck.info/video/2017/02/24/crf-guide.htmlLast edited by Sharc; 25th May 2023 at 17:13.
-
CQP may be better in case of your sources but CRF is better in more universal context - so statistically CQP is suboptimal way of encoding.
As i wrote earlier - CQP is very simplistic, primitive, doesn't need to control bitrate - just bruteforce when CRF trying to shape bitrate and quality.
Many factors involved and to draw any conclusion thorough analysis should be performed. -
On decent quality content - where you can actually see clear details to begin with - crf is significantly better than qp using same settings when you hit the same bitrate. Many threads discussing this with examples in the past. If you can't find them I probably have dozens of tests somewhere archived .
It's a bigger difference to human eye, not like what you posted. You don't have AQ with --qp . That's one of the best x264 features. Once you do the tests for yourself on varied content, you will never use --qp again for general use. -
Thanks everyone for the replies. I read all this about CRF and I know that it is popular for coding. But I have the opposite effect. Why is the result so different from the original with CRF? With CQP the result is much closer to the original.
Another example is CRF-25 (1.50mb, PSNR 44.4286) and CQP-25 (1.51mb, PSNR 44.5643).
https://imgsli.com/MTgxNTY5
I changed the AQ setting from Variance to Auto-variance. The picture looks better, but still falls short of CQP. -
Not sure about your 1st test clip. Test 1000 other "normal" sources, and 999/1000 will show CRF is visually better. Usually test sources are a bit higher in quality, and you will see the --qp degradation , and other problems like temporal fluctuations
In general , psy opts and AQ will decrease PSNR. If you look at --tune psnr preset; psy-rd , psy-trellis and AQ are disabled in order to "score" higher dB, but generally it looks worse. PSNR is not a good measurement for lossy encoding by itself - there is a large deviation between human perception and PSNR. The coefficent of correlation is low. When combined with other analysis, other metrics, PSNR can still be useful for trends. Also to determine if something is lossless
For the 2nd clip, maybe your tests are too short if your filesizes are <2Mb for 1280x720 ? Is that a few frames ? It's probably not even 1 GOP. Is that "representative" of what you encode ?
If CRF 25 and QP 25 both achieve similar filesizes, then the clip is not typical. Usually a lower CRF will match up in filesize with a higher QP and still be higher in quality. -
Yes, something is odd when you obtain the same file size with the same value for CRF and CQP (25 in your 2nd example). Probably your clip is too short, not giving CRF a sufficient number of frames to look ahead for adjusting the quantizer properly.
And as said before, single frames can be misleading. You can't judge the beauty of a waterfall by analyzing a few dropplets only. CQ usually gives stronger perceived quality fluctuations along the timeline of a movie. You won't see this by inspecting single frames (apart from comparing frames of the same type I,P,B). But even CRF is not perfect and you might find frames and conditions (e.g. dark scenes or transitions) which are not perfect.
Also take a look at the discussions from about 20 years ago over at doom9 when rate control has been developped and investigated in depth.
But if - for your case - you find CQP to be consistently better (for same file size) then why not just keep it?Last edited by Sharc; 26th May 2023 at 02:53.
-
Test 1000 other "normal" sources, and 999/1000 will show CRF is visually better.
For the 2nd clip, maybe your tests are too short if your filesizes are <2Mb for 1280x720 ? Is that a few frames ? It's probably not even 1 GOP. Is that "representative" of what you encode ?
File Size: 10.0 mb
Frames : 321
Time : 00:13.388
Framerate : 23.976023 (24000/1001)
Format : YUV420P8
And as said before, single frames can be misleading. You can't judge the beauty of a waterfall by analyzing a few dropplets only.
But if - for your case - you find CQP to be consistently better (for same file size) then why not just keep it?Last edited by gelo333; 26th May 2023 at 12:17.
-
Obviously you must be confused - and it is simply untrue - i use CQP quite frequently with low CQP as substitute for intermediate codecs and/or for capture (and this is quite common and only one justified case for use CQP).
There is single question from my side - how you wiling to control bitrate in CQP mode?Last edited by pandy; 26th May 2023 at 12:13.
-
Sure, but movies and videos are made for watching rather than pixel peeping, no?
It confuses me that CQP is not used by anyone for encoding. -
Thanks.
CRF is better IMO, preserving more details and is sharper. See for example people's hair or the market scene (vegetables and details in the bright sky in the background where CQP smoothes the details totally away althoug the file size (bitrate) is 6% higher). In flat scenes CQP has stronger blocking artefacts.
But again, this is just frame peeping.
At the end we should also compare against the original.Last edited by Sharc; 26th May 2023 at 13:38.
-
-
There is single question from my side - how you wiling to control bitrate in CQP mode?
-
I don't need to try to understand in what type of application CQP can provide benefits over CRF.
If bitrate is not important for you and only file size matters please explain if there is any dependency between bitrate and file size?
btw if you are so brave in your statements please try to compress noise with CQP and CRF. -
Last edited by gelo333; 26th May 2023 at 19:25.
-
filesize = bitrate * running time
So bitrate is as important to you as filesize
Have you looked at x265? It's was poor at the beginning development years but it's very good and mature now, especially 10bit and if you know how to tune the encodes. It's very good for lower bitrate encodes and preserving details
If you're still interested I'll post some examples this weekend regarding --qp...I'm sure there are many old threads and examples on various forums already. This topic has been beaten to death and settled many years ago
The --qp problems should be visible to see on basically any random source. Look especially in darker areas, shadow regions or flat areas like skies, gradients, or things like water. If your eyes are bad , or you have a bad display, boost the gamma for your analysis. A qp encode will obliterate shadow detail because there is no AQ in --qp mode. It's the same mechanism behind massive banding in skies, or blocky artifacts - it's because --qp encoding isn't smart enough to allocate to those areas. The --qp encode will always be worse than the --crf encode in terms of banding and blocky artifacts in those areas. Now 8bit crf can still look bad in terms of banding and mushy shadows, but the point it will not look as bad as --qp in those areas , and the main reason is AQ. You can demonstrate if you disable or lower AQ strenght, the crf encode nowexhibits similar issues as --qp encoding. Therefore, AQ is a main contributor in this difference
Another issue --qp mode is prone to fluctations in frame quality, especially on a new GOP I-frame of a same scene (ie a longer scene). It's one of the causes of "keyframe pumping." The frame quality will "jump" and it will look like flicker
Encoders (in general) tend to underallocate to flat, dark areas. AQ combats that, but the main side effect of AQ is bits are taken away from edges to distribute to those flat and shadow areas. The edge quality can deteriorate slightly using --crf with AQ (default mode is 1, strength 1), but it's usually a much better trade off then --qp. It's a good balance across generic content, that's why those are default, and why crf is default encoding mode, not qp. Edges are important for content like cartoons, anime - that's why --tune animation preset has reduced AQ strength . -
I personally think there is little difference between the two, it comes down to what you want to focus on.
I did three more encodes, one with vp9 and two with svt-av1.
For those that don't know, vp9 has the ability to encode a lower resolution frame and then upscale it during playback, svt-av1 has the same ability but it can be applied to some or all frames.
What the encoder does during bit-rate constrained encodes is it encodes two versions of a frame, a full resolution copy and a scaled down version and compares the quality of each to see which is higher and discards the other one.
VP9 is only capable of doing this with certain frames.
For the vp9 encode, I enabled this feature and set everything else for the fastest encode, for svt-av1 I set the speed to 12 and for A I disabled the feature and for B, I enabled it for all frames.
The source was created by downloading all the Netflix El Fuente videos from https://media.xiph.org/video/derf/ , combining them in Shotcut and exporting them as a lossless 10-bit 4:4:4 FFV1 file.
Side note, if anyone wants some really high quality test sources, in addition to the Netflix stuff in the above link, check out https://media.xiph.org/svt/2022/ , these were designed as torture tests for encoders and https://www.cablelabs.com/4k , these were shot using RED Epic cameras and they are some really nice stuff.Last edited by sophisticles; 27th May 2023 at 00:11.
-
Last edited by Sharc; 27th May 2023 at 03:54.
-
Blocks means QP is high - but blocks are normal for every codec based on blocks - that's why since h.264 (at least) you have deblocking (in-loop filter) being integral part of encoding process.
-
Similar Threads
-
What's NVENC H264 CQP for X264 CFR 18 and 23?
By Flagship in forum Video ConversionReplies: 2Last Post: 7th Jun 2022, 09:18 -
About the value of CRF!
By Valentin98 in forum Video ConversionReplies: 10Last Post: 24th May 2022, 14:16 -
CRF values?
By Chauceratemyhamster in forum Video ConversionReplies: 18Last Post: 28th Mar 2021, 21:06 -
CRF Values
By Anakin in forum Video ConversionReplies: 11Last Post: 7th Sep 2020, 18:12 -
NVENC is better than X264 with the same CRF / CQP ?
By DunnoNo in forum Video ConversionReplies: 19Last Post: 11th Feb 2019, 14:00