In the past few weeks, I have been trying to change the bitrate of an encoded video on the fly. I am doing real-time game live streaming, and being able to do this would be helpful.
I have not found any solution to this, but I found this in NvEncodeAPI.h:
/**
* Indicates Dynamic Encode Bitrate Change Support.
* Support added from NvEncodeAPI version 2.0.
* \n 0 : Dynamic Encode bitrate change not supported.
* \n 1 : Dynamic Encode bitrate change supported.
*/
NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE,
I have not found this usage of NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE anywhere else in the whole Video SDK, so I am wondering: is this available for us to use? How would I get around to using it?
I found a function called NvEncReconfigureEncoder that allows the bitrate and resolution of the encoded video to change during encoding.
I gave it a shot, and reconfiguring the bitrate does not work. Reconfiguring the resolution works (though not perfectly - it ends up cropped if reducing resolution).
I also went to check the capabilities via NvEncGetEncodeCaps. NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE is supported.
I used the NvEncoder sample. What I did was call NvEncReconfigureEncoder in the CNvEncoder::EncodeMain function in NvEncoder.cpp, where the encoding loop occurs (line 20-30 below):