We are using Multimedia API 28.1 video encoder to encode H264 video stream at 30FPS with resolution 1080p. The rate control mode is VBR.
We constantly adjust the encoder bitrate using NvVideoEncoder::setBitrate() API based on estimated network bandwidth. While sometimes we can get requested bitrate, but other times, we only get portion of the request bitrate. For example, we requested 5Mbps, but the encoder only output ~2Mbps. After comparing the metadata of encoded frames of these two scenarios, we found when we got the desired bitrate, the average QP was around 20, whereas when we got less bitrate than we asked, the average QP was around 28. Additionally, if we fix our QP by using the API NvVideoEncoder::setQpRange() to 20, the encoder does give us higher bitrate, however the actual bitrate is less stable, we saw many spikes where the output bitrate exceeded what we requested.
What is the right way to set up the encoder in order to have it output requested bitrate all the time?