NVDEC - problems with seeking

I used the decoder SDK to create DirectShow decoder. I have written a lot of filters including other encoders and decoders using various SDKs so I (more or less) know my way around. My decoder generally works great except when I try to seek while playing a file. After a seek I deliver a set of frames starting with the previous KEY and followed by 0 or more DELTAs to get to the target frame - I also set PREROLL on all but the last frame but that’s not something NVDEC cares about. I set CUVID_PKT_DISCONTINUITY on the first frame. This works with all my other decoders including some 3rd party ones but not with my NVIDIA hardware decoder. I get garbled video - exactly as if I were delivering out of sequence DELTA frames. If I hit PLAY after this it will show a few more garbled frames then as soon as it hits the next KEY frame it resumes playing OK.

So it behaves as if its not getting that initial KEY frame.

Is there some additional magic spell I need to use in addition to setting the DISCONTINUITY flag?

Hi Al_Chisholm,

CUVID_PKT_DISCONTINUITY should be sufficient to reset the parser. Please provide more details about this issue. Is this issue codec specific?

Can you share the test application and steps for us to reproduce this issue.

Thanks.

I should have mentioned that this is an H264 stream and that I am sending complete NAL units (CUVID_PKT_ENDOFPICTURE is always set).

I did find a workaround.

As you know when doing a seek one generally sends the previous IFRAME with DISCONTINUITY followed by any needed PFRAMEs to get to the desired seek point in the video, typically with all but the last frame set to PreRoll. After some thought about the symptoms I decided to try sending the IFRAME to cuvidParseVideoData() twice - once with DISCONTINUITY and again without DISCONTINUITY. That solved the problem. So it appears to me that perhaps your internal decoder has an ‘off by one’ problem. It appears that perhaps you expect the frame AFTER the DISCONTINUITY to start the new sequence. You could check with your engineers on this.

If you want any more info (including source code) I would be happy to provide it but for the moment I have a solution that seems to work well.