cuvidCreateVideoParser being fed with nvenc output doesn't call callbacks

I’m trying, for testing purposes, to re-feed nvdec with nvenc’s output. I’m quite sure nvenc’s output is correct (I can use libav or other decoders to get back the original stream) but I can’t seem to get cuvidCreateVideoParser to call any of the callbacks. I’m setting it up like this

CUVIDPARSERPARAMS videoParserParameters = {};
videoParserParameters.CodecType = cudaVideoCodec_H264;
videoParserParameters.ulMaxNumDecodeSurfaces = 1;
videoParserParameters.ulMaxDisplayDelay = 2;
videoParserParameters.pUserData = (void*)udata;
// videoParserParameters.ulErrorThreshold = 20;
videoParserParameters.pfnSequenceCallback = HandleVideoSequenceProc;
videoParserParameters.pfnDecodePicture = HandlePictureDecodeProc;
videoParserParameters.pfnDisplayPicture = HandlePictureDisplayProc;
NVDEC_API_CALL(cuvidCreateVideoParser(&m_hParser, &videoParserParameters));

cuvidCreateVideoParser gets called multiple times (so it’s not a buffering issue) but none of the callbacks are ever called.

How can I debug this?

You need to call cuvidCreateVideoParser() only once to create the parser, and then call cuvidParseVideoData() multiple times to inject the elementary stream data.