4. Bitrate Control Topic

4.1. Bit rate stability

  • When the bit rate exceeds the threshold, frame loss can reduce the instantaneous rate fluctuation and maintain the image quality.

  • Recommended settings:

VENC_FRAMELOST_S::bFrmLostOpen = TRUE
VENC_FRAMELOST_S::u32FrmLostBpsThr = u32BitRate * 1.2
VENC_FRAMELOST_S::enFrmLostMode = FRMLOST_PSKIP
VENC_FRAMELOST_S::u32EncFrmGaps = 1

4.2. Improvement of image quality

  • u32MaxIQp, u32MaxQp are parameters that limit the maximum QP of macroblock. Lower value of the setting can ensure better image quality under low bit rate encoding or drastical scene changes. Meanwhile, it is easy to cause bit rate overshoot. It is recommended to adjust the appropriate maximum QP according to the application requirements

4.3. Control of breath-effect

  • s32IPQPDelta is the QP difference between IP frames. Setting a larger difference can reduce the breath-effect. When the scene is still, it is recommended to set a larger difference.

  • Recommended value of still scene: [2,6];

  • Recommended value of dynamic scene: [2,4]

  • Lower s32IPQPDelta slightly when the noise is loud in low-light scenes. Reducing I-frame rate and increasing P-frame rate can avoid breathing effect caused by excessive noise induced by high quality I-frame.

4.4. Limiting I-frame amplitude

  • Setting the I-frame minimum QP has the opportunity to reduce the I-frame bit rate, but has the risk of decreasing picture quality. But it is not easy to control. It requires operating experience in scenes to have better setting.Overhigh bit rate may still occur.

4.5. Reduction in motion streaks

  • Through texture-level rate control, one can effectively reduce the obvious streak of flat area. One can adjust the texture macroblock-level rate control parameters appropriately to reduce the steak of flat area and increase the details. Meanwhile, increasing the QP of the complex texture area may also make the area more distorted. It is suggested to adjust according to the balance between the target bit rate and scene.

4.6. Reduction in chroma shift

  • cb_qp_offset, cr_qp_offset are the parameters for chroma quality adjustments. Reducing the chroma QP can improve the quality of chroma image and reduce the color deviation of the image. Meanwhile, the brightness of the image may be reduced. It is suggested to adjust according to the balance between the target bit rate and scene.

4.7. Initial QP of bitrate control

  • An appropriate initial QP should be set by considering the scene, bit rate, resolution, and etc. Users can configure the appropriate initial QP value through VENC_RC_PARAM_S::s32FirstFrameStartQp. The interface is valid between creating the channel and encoding the first frame.

4.8. Low bit rate scenarios

  • Turn on texture-level macro block rate control. It is recommended to use default parameters or fine tune them appropriately. For example, in the outdoor scenario, set u32ThrdLv to value 3.

  • Reduce the frame rate according to the scene. For example, set the target frame rate to 20fps.

  • Configure to encode PSkip to dynamically reduce the frame rate VENC_FRAMELOST_S::enFrmLostMode = FRMLOST_PSKIP;VENC_FRAMELOST_S::u32EncFrmGaps = 1

  • Use a larger GOP. The rate statistical duration, u32StatTime, is recommended to match the GOP. GOP is recommended to set at 5-10 times the frame rate. For example, when frame rate is equal to 30fps, GOP is set to 150-300 and u32StatTime is set to 5-10 seconds.

  • It is recommended to use SmartP mode coding for still scenes such as fixed cameras. When using SmartP mode, u32BgInterval should match u32StatTime.

  • Reducing the sensitivity of AE in ISP module and increasing the reaction delay of AE can avoid the frequent adjustment of AE after the change of light intensity.

  • Increase the intensity of 3DNR denoising and reduce the intensity of Sharpeness appropriately to reduce the image details.

4.9. Precautions

  • U32Gop: Suggested to set it as an integral multiple of the coding frame rate. If not set as an integral multiple, the instantaneous bit rate will fluctuate due to the uneven distribution of I frame in time

  • u32StatTime: Recommended to set it to an integral multiple of (Gop / fps). For example, when frame rate is 30fps and GOP is 60, the statistical duration should be set to an integral multiple of 2 seconds.

  • u32MaxIQp, u32MaxQp:Limit the maximum QP within the frame. It is recommended to set to [40, 46]. When focusing on quality, it is easier to cause rate overshoot.

  • u32MinQp、u32MinIQp:Limit the minimum QP in frame. Appropriate settings can save the bit rate when the image is still or in s motion.

  • The ROI setting Qp can affect the stability of the code rate control if it is too low. The ROI should be set appropriately for the target bitrate.

  • OSD images are usually sharp-edged fonts, and an overly large OSD area may increase encoding pressure.