PDA

View Full Version : Information about the ratecontrol of x264


OvejaNegra
8th June 2009, 22:45
Some days ago i made this post: http://forum.doom9.org/showthread.php?t=147410

Ok, it was too much.


But i'm very interested in on this specific topic:

The ratecontrol.

If my info is correct, during 2pass encodes x264 adapts bit rate acording to the complexity of the scene. These changes are limited to avoid sudden bit rate peaks or very low bit rate parts. Usually the buffer controls that, and the buffer size is related to the chosen profile (or maybe to target some hardware device).


Now, what im trying to do (maybe this does not have any sense) is
allow x264 to use as high as possible bit rate for high motion scenes (to avoid blocks) and only the needed bit rate on the rest of the video to produce aceptable quality AND opposite.

No, i just made a mess.


Lower quantizers for high motion scenes (for better quality), producing medium quantizers for low motion scenes (like 18 - 22, but not 14-17). Simply take quality from the low motion scenes for the high motion scenes.

And
The opposite:

As low as possible quantizer for low motion scenes (14 -16) and quickly raise the quantizer on the high motion scenes to allow acceptable perceived quality with low bit rates (yes i know this will produce fluctuating quality but that's what i want). I have seen this behaviour on some real media encodes (nice looking low action scenes ,and suddendly blocky action scenes but the filesize is generally small).


If i'm not wrong, qcomp and cplxblur will help me with that, but i dont know how to use them (lower cplxblur and lower qcomp maybe?). But what about the bit rate? This sudden change on the quantizers will produce many fast bit rate changes and the buffer will avoid that.


Im trying to aim to a speceific size, not to a specific bit rate (like Xvid).


Sorry this is very confusing, for my bad english.

I'm saying something without sense please correct me.

LoRd_MuldeR
8th June 2009, 22:49
Now, what im trying to do (maybe this does not have any sense) is
allow x264 to use as high as possible bit rate for high motion scenes (to avoid blocks) and only the needed bit rate on the rest of the video to produce aceptable quality AND opposite.

That's exactly what the whole idea about 2-Pass ratecontrol is...

OvejaNegra
8th June 2009, 23:12
Oh, i believed that x264 favors low motion scenes and kill the high motion scenes most because deffects are hard to see.

Well, how can i give more quality for the high motion scenes even if that reduce a little the rest of the video?

MasterNobody
8th June 2009, 23:16
Well, how can i give more quality for the high motion scenes even if that reduce a little the rest of the video?

Increase --qcomp

LoRd_MuldeR
8th June 2009, 23:19
Oh, i believed that x264 favors low motion scenes and kill the high motion scenes most because deffects are hard to see.

Yeah, that's what CRF does compared to CQ mode. It lowers the quantizers in high motion scenes, so these don't eat as many bits as they would with a constant quantizer.
This is okay, because in high motion scenes we can usually deal with higher quantizers, as the loss is less visible. So CRF is a more bitrate-efficient version of CQ.

But 2-Pass will actually move bits towards the high motion scenes, compared to a 1-Pass ABR encode. The latter would blindly give all scenes the same bitrate (more or less).

akupenguin
8th June 2009, 23:39
But 2-Pass will actually move bits towards the high motion scenes, compared to a 1-Pass ABR encode. The latter would blindly give all scenes the same bitrate (more or less).
No. ABR will blindly give all prefixes of the movie about the same bitrate... but by the time you're encoding a whole movie, the time constant involved is a whole lot more than one scene. ABR takes advantage of the fact that the natural variation in total size scales with sqrt(length), and so for a longer movie it doesn't have to limit bitrate variation as much. That said, if there's a high motion scene at the beginning of the movie, then 2pass will give it more bits than ABR.

OvejaNegra
9th June 2009, 15:11
Yes, it works as it should.
Even lowering qcompj and using low bit rates looks nice on the slow motion scenes (and totally ruins the fast motion scenes) :)

Just curiosity: What will happen if i touch cplxblur? The quantizer fluctuations will be higher?