How to handle buffers when nvEncEncodePicture produces NV_ENC_ERR_NEED_MORE_INPUT

I’m working on implementing the NVIDIA Video Codec SDK, specifically NVENC. The documentation is not very clear on what it means when nvEncEncodePicture returns NV_ENC_ERR_NEED_MORE_INPUT. The ffmpeg docs (FFmpeg: NvEncodeAPI Data structures) seem to imply that when receiving NV_ENC_ERR_NEED_MORE_INPUT, we must keep the original output and inputs buffers around, then wait for NV_SUCCESS and read all of them in the same order (up until the current one). Looking at the sample code, it seems NvEncoder.cpp does keep multiple buffers around, but only for purposes of the output delay. Even when nvEncEncodePicture produces NV_ENC_ERR_NEED_MORE_INPUT, it will still only read the current buffer. Is this is a bug in NvEncoder.cpp? Or are the ffmpeg docs out of date?

Hi gerwin,
Have you looked into detailed documentation with an example available in nvEncodeAPI.h for NvEncEncodePicture() API? This is part of the SDK package.
Let me know if you have any further specific question.

Thanks.

Hi mandar,

Yes the example is what I am referring to with NvEncoder.cpp: NvEncoder is the example decoder implementation, which does not keep buffers around in the case of NEED_MORE_INPUT.