PDA

View Full Version : CRF question (and x264 setting improvements)


Chengbin
28th February 2009, 04:33
I wasted a lot of time encoding Kung Fu Panda from Blu-Ray to CRF 20.

To my knowledge, CRF is a quality measure, where x264 use as many bit as it wants to achieve that quality.

Also, there are many x264 settings that help compression.

So I use these two settings, one the simplest possible, one a very complex one.

Simple setting (for some reason AutoMKV didn't use 0 ref frames)

cabac=0 / ref=1 / deblock=1:-1:-1 / analyse=0x1:0x111 / me=dia / subme=2 / psy_rd=0.0:0.0 / mixed_ref=0 / me_range=4 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / chroma_qp_offset=0 / threads=6 / nr=0 / decimate=1 / mbaff=0 / bframes=0 / keyint=25 / keyint_min=13 / scenecut=40(pre) / rc=crf / crf=20.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / vbv_maxrate=25000 / vbv_bufsize=14000 / ip_ratio=1.40 / aq=0

Complex slow setting

cabac=1 / ref=16 / deblock=1:-1:-1 / analyse=0x3:0x113 / me=umh / subme=9 / psy_rd=1.0:0.0 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / chroma_qp_offset=-2 / threads=6 / nr=0 / decimate=1 / mbaff=0 / bframes=16 / b_pyramid=1 / b_adapt=2 / b_bias=0 / direct=3 / wpredb=1 / keyint=250 / keyint_min=25 / scenecut=40(pre) / rc=crf / crf=20.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / vbv_maxrate=25000 / vbv_bufsize=14000 / ip_ratio=1.40 / pb_ratio=1.30 / aq=1:1.00

The simple setting produced a file size of 3.39GB. The slow setting produced a file size of 3.26GB. ??????? I used AutoMKV and x264 r1114 to encode this.

Also, for some reason I can't play the file encoded with the simple profile to play properly. The frame rate is very unstable, ranging from 10-20fps. I've tried ffdshow MT, CoreAVC, and hardware acceleration. The video encoded with the slow profile played perfectly.

akupenguin
28th February 2009, 04:45
Among the options you changed were psy-rd and AQ. Those affect the quality metric. It is meaningless to ask for two encodes to have the same quality if you aren't measuring quality the same way.
Sure, the overall average bitrate of a given CRF value with and without psy are supposed to be similar, but that's only the average over many movies, and I can't promise that we adjusted it exactly right.

And that's just he most blatant problem with your comparison. Most of x264's speed-quality tradeoff options both improve quality and reduce bitrate at a given QP, so even if you did get a size reduction that looked right, you wouldn't be seeing the whole difference.

Chengbin
28th February 2009, 04:49
But still, the video encoded with the complex setting should be SIGNIFICANTLY smaller as I didn't use CABAC, deblock, b-frame, and only 1 ref-frame.

So if I disable psy-rd and AQ I'll get the same quality metric right?

Wait, I didn't use psy-rd in the complex setting.

Just a question, does trellis 2=psy trellis?

Dark Shikari
28th February 2009, 05:47
CRF is not a measure of quality. It is an arbitrary point on the curve between quality and bitrate that is only "constant" at a certain combination of settings. If you change those settings, you move the point on the curve.

J_Darnley
28th February 2009, 12:55
Simple setting (for some reason AutoMKV didn't use 0 ref frames)
That's because you can't use zero reference frames. A frame without references is an I-frame.

Just a question, does trellis 2=psy trellis?
No.

Chengbin
28th February 2009, 14:38
So how do you know how much compression a setting give you? I've read that people did that with CRF encoding. The point of this encode is to see how much extra compression do I get by using the (almost) highest x264 settings compared to the lowest x264 setting.

How do you enable psy-trellis?

vmrsss
28th February 2009, 15:18
CRF is not a measure of quality. It is an arbitrary point on the curve between quality and bitrate that is only "constant" at a certain combination of settings. If you change those settings, you move the point on the curve.

Thanks DS. Say, if one only changes --me and --subme at a fixed --crf, should one observe a size decrease at the same quality? Could you list the parameters that behave this way and those which "move" the point on the curve?

vmrsss
28th February 2009, 15:20
How do you enable psy-trellis?

For instance:

--trellis 2 --psy-rd 1.0:0.2

Dark Shikari
28th February 2009, 18:22
Thanks DS. Say, if one only changes --me and --subme at a fixed --crf, should one observe a size decrease at the same quality?The entire point of my post is that the answer to that question is "no". Increasing subme will improve quality vs bitrate--but could raise quality and bitrate, or lower quality and bitrate, depending on the source.Could you list the parameters that behave this way and those which "move" the point on the curve?It depends on the source and your other settings, so it's impossible to generalize.

jmnk
28th February 2009, 19:31
@Dark Shikari - I took liberty to highlight part of your post.
- generalization of Dark Shikari's post: Increasing a given setting when doing CRF encode will improve quality vs bitrate --but could raise quality and bitrate, or lower quality and bitrate, depending on the source.
I think I've had a pretty good idea of what CRF is but this, at least to me, truly summarizes the essence of CRF in one sentence.