Page 1 of 1

QP vs CRF

Posted: Sun Oct 25, 2020 11:45 pm
by PierU
Hello,

I have been encoding movies with Handbrake for years on a 2011 iMac, using x264 codec with the CRF mode (or the 2 pass ABR mode). Using the "slow" preset it achieves an encoding rate of about 10fps on a 1080p video: quite slow, but acceptable for my usage.

Switching to h265 (which would be nice to reduce file sizes) was not really an option, as the with x265 the encoding speed drops to 4fps.

Then I recently got a mini-PC, with a Celeron/UHD600: definitely less powerful than my old iMac, but at least it has some hardware support (QSV) for h265 encoding. I have played a bit with it and it achieves about 20fps with the "balanced" preset, which is twice faster than x264 on the old Mac: it could be an alternative, but it has no CRF mode, only the QP mode.

From what I understand QP is less smart than CRF, as the latter is actually a kind of "variable QP" (higher QP on high motion frames). So I would need to use a lower QP value to compensate for that, and at the end I wouldn't obtain significantly smaller files...

However, this article ( https://slhck.info/video/2017/02/24/crf-guide.html ) tends to show that the advantage of using CRF instead of QP is the most important for low QP/CRF values and much less obvious for medium values (see the graphs that compare values of 17 and 23). Since I generally use medium values (such as 23!), this means that I wouldn't waste that much space by using QP...

What do you think ?

Re: QP vs CRF

Posted: Mon Oct 26, 2020 2:31 am
by Deleted User 13735
Don't bother with QSV and get a computer with good processing abilty for x265, my advice.

Re: QP vs CRF

Posted: Mon Oct 26, 2020 4:12 am
by mduell
The rate control method is a lot less significant than the lousy encoder. Stick to x264 for high efficiency 1080p encodes.

Re: QP vs CRF

Posted: Mon Oct 26, 2020 9:45 pm
by PierU
musicvid wrote: Mon Oct 26, 2020 2:31 am Don't bother with QSV and get a computer with good processing abilty for x265, my advice.
I guess that x265 will have to wait, then :lol: ! I don't plan replacing my main computer at the moment...

Re: QP vs CRF

Posted: Tue Oct 27, 2020 5:13 pm
by PierU
I have measured the bitrate GOP by GOP along 1 hour of a movie (1080p), encoded with:
- x265, crf=23, preset=slow
- QSV, qp=23, preset=quality

First of all, the average bitrate is much lower with x265 (1421 kb/s) than with QSV (2209 kb/s). It could just be that the CRF and QP values do not match, and that a higher QP value should be used (26 or so...). But interestingly the x265 bitrate curve looks like a kind of baseline for the QSV bitrate values (which are much more erratic):

https://i.imgur.com/8LVl4uU.png

Maybe just a coincidence... or not !

One important observation: the default GOP size is 1 sec. of video in QSV, compared to 10 sec. in x265 ! This means 10 times more keyframes, so obviously a higher required bitrate to achieve the same quality.

Re: QP vs CRF

Posted: Tue Oct 27, 2020 5:58 pm
by mduell
The quality is not the same between the different encoders, or even the same encoder with different settings.

Re: QP vs CRF

Posted: Wed Oct 28, 2020 12:52 pm
by PierU
Sure... I meant that "if all other things would be equal" the simple fact that there are 10 times more keyframes etc...

Re: QP vs CRF

Posted: Wed Oct 28, 2020 7:02 pm
by Deleted User 13735
You are matching the QP number with the CRF number and comparing? Don't do that, they are apples and oranges.
In order to come within a range of "quality" not even quite comparable with x265 CRF 23, you would need to encode your QSV at around QP=12 ! (Assuming motion video, not a slideshow).
Now compare file sizes. It's [cough] a little more than counting I-frames at work here. I hope you don't spend much more of your valuable life beating a dead horse.

Re: QP vs CRF

Posted: Thu Oct 29, 2020 10:37 am
by PierU
musicvid wrote: Wed Oct 28, 2020 7:02 pmYou are matching the QP number with the CRF number and comparing? Don't do that, they are apples and oranges.
This is not what is saying the article I have cited in my first post : https://slhck.info/video/2017/02/24/crf-guide.html

Matching CRF and QP for a given codec (if it offers both, like x265) makes sense. Between two different codec I agree this is less meaningful, as there are many other differences.
In order to come within a range of "quality" not even quite comparable with x265 CRF 23, you would need to encode your QSV at around QP=12 !
I just had a quick look to the results of x265 CRF=23 and QSV QP=23, but the quality don't look completely different...
Now compare file sizes. It's [cough] a little more than counting I-frames at work here
Did I say that it was only a matter of number of key frames ? No, I didn't...
musicvid wrote: Wed Oct 28, 2020 7:02 pmI hope you don't spend much more of your valuable life beating a dead horse.
Trying to understand what is behind the scenes is never a waste of time :)

Re: QP vs CRF

Posted: Thu Oct 29, 2020 1:52 pm
by mduell
PierU wrote: Thu Oct 29, 2020 10:37 amMatching CRF and QP for a given codec (if it offers both, like x265) makes sense. Between two different codec I agree this is less meaningful, as there are many other differences.
No, not particularly.

Re: QP vs CRF

Posted: Fri Oct 30, 2020 2:35 am
by Deleted User 13735
I just had a quick look to the results of x265 CRF=23 and QSV QP=23, but the quality don't look completely different...
That would be the crux of our differences. Good luck.