PDA

View Full Version : question about CRF


vmrsss
21st February 2009, 19:45
Hi there.

Exactly what do I ask the encoder to do when I require a constant rate factor? I mean, is there a relationship to the average QP for say P-frames which can be expressed in some reasonably easy way? And with respect to a individual frame?

Eg, below are two encodes (via ffmpeg) of different sources both at CRF 21. The difference in the average QP is huge (2.26 for B frames)

[libx264 @ 0x10102e200]slice I:914 Avg QP:17.40 size: 45617
[libx264 @ 0x10102e200]slice P:26717 Avg QP:19.83 size: 17429
[libx264 @ 0x10102e200]slice B:53199 Avg QP:21.00 size: 7769

[libx264 @ 0x101014600]slice I:1902 Avg QP:19.14 size: 27009
[libx264 @ 0x101014600]slice P:84276 Avg QP:21.84 size: 8885
[libx264 @ 0x101014600]slice B:180596 Avg QP:23.36 size: 3741

I suspect this might be a silly question I ought to know the answer to. In that case, apologies in advance. Thanks.

Dark Shikari
21st February 2009, 20:09
CRF is a completely arbitrary measure of quality for a given set of encoding settings. It depends on overall frame complexity, adaptive quantization, and a few other things.

Adub
22nd February 2009, 08:41
When dealing with CRF, the general practice is to find a value that works for you on source, say your favorite DVD, and use it for the rest of your encodes. The CRF value will be evaluated such that your encode will reach the same level of "quality" with respect to your other encodes. I use quotes as everyone has their own level of quality. The usual values run anywhere from around 19-23 or so. Pick which one works for you.

JohannesL
23rd February 2009, 13:51
When dealing with CRF, the general practice is to find a value that works for you on source, say your favorite DVD, and use it for the rest of your encodes. The CRF value will be evaluated such that your encode will reach the same level of "quality" with respect to your other encodes. I use quotes as everyone has their own level of quality. The usual values run anywhere from around 19-23 or so. Pick which one works for you.
It depends on source. For example, with a higher resolution, you can generally get away with a higher CRF. For 256x224 videos I've found even 18 to be needed.

Chengbin
23rd February 2009, 14:13
It depends on source. For example, with a higher resolution, you can generally get away with a higher CRF. For 256x224 videos I've found even 18 to be needed.

That's not true, it should be the exact opposite.

akupenguin
23rd February 2009, 14:37
JohannesL is right, assuming you upscale all the different resolutions to the same physical size on playback, e.g. fullscreen. And if you don't display the videos at the same size, I don't see how you can even talk about comparing quality.

Sagekilla
23rd February 2009, 15:44
@Chengbin: Nope, with higher resolutions you can use higher crf values.

For a 1080p playback device, 1280x720 (crf 18) and 1920x1080 (cref 18), if you upscale the 1280x720 encode, your errors are enlarged by 50%. When you upscale, eveything becomes enlarged, including any noise/MB errors, etc. In other words, when playing back video on a high resolution device, the higher your resolution, the lower the relative size of MB errors.

vmrsss
23rd February 2009, 20:48
the point is that the variation at a given CRF (I've used 21 for tens and tens of encodings) can be very big and appears to me to be truly unpredictable, and I was curious understand what determines that. For instance, I easily meet TV serials whose episode N encoded at say 1600kbps and episode N+1 encodes at 2300kbps for exactly the same parameters and crf 21.

What unsettles me is that when for a test I encode N+1 with 2-pass @ 1600kbps, I can hardly see a difference... Am I going blind?

PS. I understand the discussion about needing lower crf for smaller resolutions; the example above happened at a relatively large 720x576

LoRd_MuldeR
23rd February 2009, 20:57
For instance, I easily meet TV serials whose episode N encoded at say 1600kbps and episode N+1 encodes at 2300kbps for exactly the same parameters and crf 21 ... Am I going blind?

No. That's CRF doing exactly what it's supposed to do ;)

The purpose of CRF is to give similar visual quality for different sources. It will choose whatever bitrate is required to preserve the selected level of quality.

So CRF offers predictable quality, at the cost of unpredictable output size.

At the same time 2-Pass reliably hits the desired output size (target bitrate), but the visual quality for a given bitrate may vary a lot from source to source.

You must decide yourself what mode better suits your needs ...

Sagekilla
23rd February 2009, 21:00
Well, crf is defined as being (more or less) constant quality. The more complex the movement in the video, and the more detail present, the more bits are required to encode at the same rate factor.

Would you expect a still scene of the sky to take the same amount of bits as a high speed chase in the city? Answer that, and you'll know why the bitrates can vary so much using crf mode.

Rumbah
24th February 2009, 14:11
What unsettles me is that when for a test I encode N+1 with 2-pass @ 1600kbps, I can hardly see a difference... Am I going blind?

Then CRF 21 at that resolution is near transparent for you, you could try encoding at CRF 21.5 or 22 or even higher and see if the output is good enough for you and encode at that setting.

Shinigami-Sama
25th February 2009, 17:12
Then CRF 21 at that resolution is near transparent for you, you could try encoding at CRF 21.5 or 22 or even higher and see if the output is good enough for you and encode at that setting.

then when you start watching them on the big screen it can turn into a mess

slippery slope is slippery

Sagekilla
26th February 2009, 15:02
I actually find it to be the other way around. On my laptop or desktop screen, where I'm typically only a few feet away from the screen, it's a lot easier to see any problems with my encodes. I usually use crf 18 (19 for HD) because of this. If I'm sticking something on my PS3 though, I can get away with crf 20-21 because watching it on my projector, where I'm sitting more than 10 or 15 away from the screen, it's -a lot- harder to see the individual macroblocks and any problems with them.


Just don't go above crf 25 though, at that point your video is going to turn to mush.