About "cudaDecodeD3D9" specify the range of frames to be decoded

Hi, everyone. :w00twave:

I use SDK 4.0 sample (cudaDecodeD3D9) for mpeg2 decoding, it works very well.
However, I want to specify the range of frames to be decoded, instead of decoding all the frames.
How can I do?
Do something in “HandlePictureDecode”?

When you say a “range of frames”, do you mean a range as in frame 1 --> frame X (option 1), or frame Y --> frame Z (option 2), or something else completely? (where X, Y, and Z are integrable values within the video’s frame range)

If you just want to limit the number of frames to be decoded (the 1st option above), the easiest way would probably be in the HandleVideoData callback function in VideoSource.cpp. It’s called on every frame, so you could add a VideoSource class member to keep count of the # frames ran thus far and exit when it hits the prescribed number.

Otherwise, if you’re looking for option 2, you could just not call the parser callback function (cuvidParseVideoData) from the HandleVideoData function until it hits the first frame (frame Y) you want to decode, then exit ala option 1 once frame Z is passed to the callback function.

Thank you very much,alrikai

I mean option 2.

I’m sorry for my poor English.

Oh, I found It’s called on every frame maybe wrong.

It’s called every packet. :smile:

if (pPacket->flags & CUVID_PKT_TIMESTAMP)


//now, a new frame


BTW, How can I freely seek video? thanks

Hm that’s interesting, my SDK cudaDecodeD3D9 project doesn’t seem to have that line… maybe each packet it grabs is a frame? Not sure…

I’m not sure how to seek through the video with the cuvid API, although I suppose you could always do it manually and feed the relevant portions of the video stream to the parser directly