VideoHelp Forum

+ Reply to Thread
Page 1 of 3
1 2 3 LastLast
Results 1 to 30 of 61
Thread
  1. 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
    Quote Quote  
  2. 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.
    Quote Quote  
  3. Yes I know that. Why does CRF give the worst result? Moreover, CRF is the standard of use, and CQP is not taken seriously.
    Quote Quote  
  4. 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.
    Quote Quote  
  5. 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.
    Quote Quote  
  6. 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 .
    Quote Quote  
  7. Post your source
    Need to upload a video and write a link to it? Or take a screenshot of the same frame?

    https://drive.google.com/file/d/1dN6aGIcgFzj8S1-VAtJAn5dn2-j7j6U8/view?usp=share_link
    Quote Quote  
  8. Your source seems to be a WhatsApp highly compressed video with low details. Not particularly the best footage to test and compare encoders .....
    Quote Quote  
  9. I have many of these videos. What conclusions can be drawn? CQP is better, but CRF makes file size smaller?
    Quote Quote  
  10. 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.html
    Last edited by Sharc; 25th May 2023 at 17:13.
    Quote Quote  
  11. Originally Posted by gelo333 View Post
    I have many of these videos. What conclusions can be drawn? CQP is better, but CRF makes file size smaller?
    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.
    Quote Quote  
  12. 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.
    Quote Quote  
  13. 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.
    Quote Quote  
  14. 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.
    Quote Quote  
  15. 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.
    Quote Quote  
  16. Test 1000 other "normal" sources, and 999/1000 will show CRF is visually better.
    I will be grateful to you if you show these examples.

    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 ?
    Source info
    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.
    If you focus on perception when watching a video, then why is there a frame-by-frame analysis? A lot of things will not be noticeable when viewing, but so much work is being done to find image optimization, anti-noise, sharpness, etc. And it's always frame-by-frame. Today the eyes see one thing, and tomorrow another. What I'm saying is visible throughout the video, I'm just showing one frame as an example. Probably I can not correctly explain what kind of image deterioration I'm talking about. If we imagine that the picture consists of color puzzles, then with CRF these puzzles move and change shades. This happens much less with CQP.
    But if - for your case - you find CQP to be consistently better (for same file size) then why not just keep it?
    It confuses me that CQP is not used by anyone for encoding.
    Last edited by gelo333; 26th May 2023 at 12:17.
    Quote Quote  
  17. Originally Posted by gelo333 View Post
    It confuses me that CQP is not used by anyone for encoding.
    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.
    Quote Quote  
  18. A not so quick CRF vs CQP comparison.
    Image Attached Files
    Quote Quote  
  19. Originally Posted by gelo333 View Post
    If you focus on perception when watching a video, then why is there a frame-by-frame analysis? A lot of things will not be noticeable when viewing, ....
    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.
    I am using it with --qp 0 for lossless intermediates (same as --crf 0 for x264) for example, but never for the final distribution/export for the reasons mentioned before.
    Quote Quote  
  20. Originally Posted by sophisticles View Post
    A not so quick CRF vs CQP comparison.
    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.
    Quote Quote  
  21. Originally Posted by sophisticles View Post
    A not so quick CRF vs CQP comparison.
    Thank you. I do see higher CRF sharpness in some places. but also I still see the detail change. so the question is, which of the examples is more consistent with the original?
    Quote Quote  
  22. There is single question from my side - how you wiling to control bitrate in CQP mode?
    Try randomly and see what happens. The bitrate is not important to me, the file size matters. Sometimes it is a twofold reduction of the original, sometimes a fivefold reduction of the original. The general meaning, reducing the file size, without a strong loss in quality, removing noise and adding sharpness.
    Quote Quote  
  23. Originally Posted by gelo333 View Post
    There is single question from my side - how you wiling to control bitrate in CQP mode?
    Try randomly and see what happens. The bitrate is not important to me, the file size matters. Sometimes it is a twofold reduction of the original, sometimes a fivefold reduction of the original. The general meaning, reducing the file size, without a strong loss in quality, removing noise and adding sharpness.
    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.
    Quote Quote  
  24. Originally Posted by gelo333 View Post
    The bitrate is not important to me, the file size matters
    ROFL
    Please explain your logic.
    Quote Quote  
  25. I'm looking at how much the file is reduced after encoding. If the result suits, then ok. And the bitrate can be 700 or more than 1000. Of course, I check the image visually.
    Originally Posted by pandy View Post
    btw if you are so brave in your statements please try to compress noise with CQP and CRF.
    I have seen in several videos that CQP leaves blocks that are very difficult to remove.
    Last edited by gelo333; 26th May 2023 at 19:25.
    Quote Quote  
  26. 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 .
    Quote Quote  
  27. Originally Posted by gelo333 View Post
    Thank you. I do see higher CRF sharpness in some places. but also I still see the detail change. so the question is, which of the examples is more consistent with the original?
    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.
    Image Attached Files
    Last edited by sophisticles; 27th May 2023 at 00:11.
    Quote Quote  
  28. Originally Posted by sophisticles View Post
    I personally think there is little difference between the two, it comes down to what you want to focus on.
    The keyframe pumping (step change in sharpness) is stronger for CQP. See for example the trasition frame 249->250 or 2879->2880 (gray shirt with squares).
    Image Attached Thumbnails Click image for larger version

Name:	2879.png
Views:	6
Size:	192.3 KB
ID:	71260  

    Click image for larger version

Name:	2880.png
Views:	8
Size:	150.2 KB
ID:	71261  

    Last edited by Sharc; 27th May 2023 at 03:54.
    Quote Quote  
  29. Originally Posted by gelo333 View Post
    I have seen in several videos that CQP leaves blocks that are very difficult to remove.
    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.
    Quote Quote  
  30. Originally Posted by Sharc View Post
    The keyframe pumping (step change in sharpness) is stronger for CQP. See for example the trasition frame 249->250 or 2879->2880 (gray shirt with squares).
    How it can be if CQP imply same QP to every frame so you have pure VBR? In CQP there should be no pumping unless this is not CQP but some other mode with bitrate shaping.
    Quote Quote  



Similar Threads