Cbr ratecontrol and QP ranges

Is there a way to constrain the QP range for I, P and B with CBR ratecontrol mode?
I set the following parameters in the encoder:

ctx->ratecontrol = V4L2_MPEG_VIDEO_BITRATE_MODE_CBR;
ctx->nMaxQpI = ctx->nMaxQpP = ctx->nMaxQpB = 51;
ctx->nMinQpI = ctx->nMinQpP = ctx->nMinQpB=40;

I can see actual QPs in the encoder output are below 40.

Any idea why my setting doesn’t work?
My platform is Jetson orin.

Thanks,

Hi,
The min/max QP range works in VBR mode. In CBR mode, it picks the QP value to have real bitrate as close as the set bitrate. QP range is not considered.

OK. In my application, I set CBR bitrate to a new value for each frame before encoding. What I found out actual bit count of the encoded frame is quite different from what I set (ex, I set 6mbps, but encoded bitcount is >12mbps)
Is there a way to configure an encoder so it follows my bitrate guidance closely on per frame basis?

Thanks,

Hi,
Runtime bitrate change is supported but it takes a few frames to take effect. If you changes the bitrate every frame, it may not properly. Would suggest have at least 5+ second interval while changing bitrate.

5 sec is not going to work for my application. My application requires a very tight control of bitrate per frame basis. Do you think VBR mode is applicable for this?

Thanks,

Hi,
You may try external rate control to set the parameters frame by frame. Please refer to
H265 bitstream size is too large when using external rate control

And check codes about populate_ext_rate_ctrl_Param() in 01_video_encode.

I reviewed the code of 01_video_encode., but not sure which part I need to add to use an external control?
Is there a doc which describe how to use an external rate control?

FC

Hi,
There is no document for the advancing function. Please refer to the user’s example and give it a try. And check the source code.