Is there any way to reuse CUvideodecoder?

Hi, all:
I am trying to extract keyframes from various H264 shot videos. These videos are of different width and height. I want to decode keyframes and scale to 256 x 256.

Before calling cuvidCreateDecoder, a CUVIDDECODECREATEINFO struct should be filled. Specifically, the ulWidth and ulHeight field of CUVIDDECODECREATEINFO structure should be filled with video’s coded width and height respectively.

I found that this decoder creation and destroy cost much time compared to frame decoding. Is there any way to reuse CUvideodecoder so that video decoder be created only once?

Sample code:

    cuvidGetSourceVideoFormat(m_videoSource, &oFormat, 0);

    memset(&oVideoDecodeCreateInfo, 0, sizeof(CUVIDDECODECREATEINFO));
    oVideoDecodeCreateInfo.CodecType = oFormat.codec;
    oVideoDecodeCreateInfo.ulWidth = oFormat.coded_width;
    oVideoDecodeCreateInfo.ulHeight = oFormat.coded_height;

    CUresult oResult = cuvidCreateDecoder(&m_videoDecoder, &oVideoDecodeCreateInfo);

Hi liuxionghust,

Which video codec SDK are you using? If you are not using SDK 8.2, we would recommend to move to that SDK header version(Video_Codec_SDK_8.2.16). Before you want to use the 8.2 header, ensure that you have the right drivers installed on your machine, the Readme.txt mentions the minimum driver versions that are needed to be installed before you can use the SDK 8.2.

In version 8.2, we have added support of a new API (cuvidReconfigureDecoder). Please refer to section 4.6 in …/doc/NVDEC_VideoDecoder_API_ProgGuide.pdf which explains how you can use this API. This API provides you the capability where you can re-use a single decoder object instead of destroying and creating a new one.

The sample application inside the SDK also illustrates how to use the API, in case you want to get hold of a working code.

Let us know if you have any more questions.

Ryan Park

Hi rypark,
Thanks for your reply. Previously I was using codec sdk 7.1. After I found the new cuvidReconfigureDecoder API added in codec sdk 8.2, I tried it. It works well.

Hi rypark,

I checked the work cuvidReconfigureDecoder on

same code

  1.     work 

1080 TI work
Tesla K80 not work (green corrupted scree)

you can test work cuvidReconfigureDecoder no Tesla K80 card.