Log in

View Full Version : x264: confused by --crf and --preset + --tune


MadMonkey57
26th March 2012, 17:41
Hi,

--crf <float> Quality-based VBR (0-51) [23.0]

My understanding is that --crf targets a certain quality level, no matter what --preset & --tune used.

--crf 20 --preset placebo --tune film
--crf 20 --preset ultrafast --tune grain

would then give the same quality level, right? And the only difference would then be the resulting file size (and encoding time), right?

Is it that simple or am I missing anything?

Thanks

Snowknight26
26th March 2012, 18:03
You're thinking of --qp.

LoRd_MuldeR
26th March 2012, 18:24
Hi,

--crf <float> Quality-based VBR (0-51) [23.0]

My understanding is that --crf targets a certain quality level, no matter what --preset & --tune used.

Then your understanding is wrong. Or at least inaccurate.

What CRF does: The same CRF value will give the same subjective quality (roughly!) for different sources.

So usually you can find the highest possible CRF value that still satisfies your requirements. And then you can use that value for all your future encoders.

But this only applies as long as you don't change other influential encoder options! Using a different preset/tune does change influential options :eek:

Consequently you may need to re-adjust your CRF value after changing the preset and/or the tune...

--crf 20 --preset placebo --tune film
--crf 20 --preset ultrafast --tune grainwould then give the same quality level, right? And the only difference would then be the resulting file size (and encoding time), right?

Nope. The only thing you know is that the "placebo" encode will have a better "quality per bit" ratio, compared to the "ultrafast" encode.

But the overall quality may also be different for the same CRF value, when using such very different encoder settings ;)

Consequently it could happen that, for example, the "placebo" encode comes out at a better quality and a bigger file size at the same time!

(Of course for the same level of quality an "ultrafast" encode would have to be even bigger - much bigger)

nm
26th March 2012, 18:46
But the overall quality may also be different for the same CRF value, when using such very different encoder settings...

Yep. In my experience, the fastest presets (veryfast to ultrafast) tend to be visually clearly worse than the slow presets at the same CRF value. At least in the common CRF 18 to 25 range.

Ultrafast turns off in-loop deblocking, which causes a notable difference at higher CRF values.

mandarinka
26th March 2012, 18:52
Ultrafast turns off everything, including adaptive quantization, which I suspect is guaranteed to mess up almost any source.

MadMonkey57
26th March 2012, 19:11
Much clearer now. Thanks. So now comes a corollary question.

Since both --crf and --preset (i.e other settings) influence the overall quality, I wonder what is the importance of each setting.

For instance, comparing:
A/ --preset placebo --crf 21
B/ --preset ultrafast --crf 20

Is it possible/likely/unlikely that B gives a better quality now A? Depending on the complexity of the input (dark areas, fast motion, ...)?

LoRd_MuldeR
26th March 2012, 19:14
You should be able to get the same level of quality with any Preset - you will just have to re-adjust the CRF value accordingly!

Of course, for the same level of quality (not same CRF value!), a "slower" Preset will be able to get away with a smaller file size, compared to a "faster" Preset.

I would suggest to first pick the slowest Preset that you can accept and then adjust the CRF value according to your quality requirements.

MadMonkey57
26th March 2012, 19:39
Actually, I can accept --preset veryslow, and I am looking at [20, 21, 22] for --crf.
Sources will be DVDs and blurays that I'd like to re-encode to watch on my Apple TV / 52 inches LCD.

My initial thought was about veryslow/21 vs medium/20...

MadMonkey57
28th March 2012, 17:26
Experimented with a few--crf settings together with --preset veryslow and found a quality/size I am very pleased with:

- 1080p: 22
- 720p: 21
- SD: 20

Thanks for your advices