Decoding, processing and displaying video w/ Nvidia Codec SDK & CUDA interop using OpenGL GLFW

I’m using: CUDA version 11.3 project w/ Visual Studio 2019 on a Windows 10 machine and a Quadro RTX 3000 GPU.

In an older version of Cuda, I implemented an OpenGL video decoder using Cuda and GLFW. (my code would read in a frame of video, color process it and implement pre-distortion to the video frame) This was developed about 5 years ago when the decode operations on the GPU were built into Cuda. Recently, the Codec capabilities of the GPUs have been implemented directly in the hardware and Nvidia provides a Codec SDK to decode (and encode) video. I’m trying to update my original project w/ the new SDK.

Within the example projects provided with the Codec SDK is an application showing the decode of a video stream using CUDA interop with OpenGL (called AppDecGL). The problem is that that example is built around using the FreeGLUT OpenGL library. I tried to adapt the code in use there (the demuxer and the decoder) for use in my GLFW code. However when I run the code, as it goes to display the first frame of video, I get an Unhandled Exception when it tries to run the line of code:

CUDA_DRVAPI_CALL(cuStreamSynchronize(m_cuvidStream));

in the NvDecoder.cpp file.

Can anyone give me either:

  1. Some advice on how to debug this unhandled exception
    or
  2. Point me to an example of using OpenGL GLFW with CUDA interop (and the newest decode capabilities of the Cuda SDK)?

I was able to solve this issue and figured I’d provide some comments on what I found. In the previous incarnation of my code, I would define the interaction between frames on the GPU using the cuGLMapBufferObject(…) method. However, in the newer Cuda version, this process is carried out by defining a CUgraphicsResource and a CUDA_MEMCPY2D resource fr defining and controlling the frame handling (via the cuMemcpy2DAsync command).

The details are shown in the AppDecGL example project in the FramePresenterGlut::Render function.

1 Like

Hello @eprechtl and welcome to the NVIDIA developer forums!

Thank you for sharing your solution, that is very much appreciated!

I changed the category of your OP so more people can benefit from your findings.

Thanks again,

Markus

Thanks Markus!

Best,

-Eric

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.