[Libav-user] How to use an existing CUDA context for decoding

Michael IV explomaster at gmail.com
Wed May 23 22:27:00 EEST 2018


Not sure if this is the right place, but Nvidia Video SDK page contains
wonderful examples with runnable source code which shows you how to decode
and encode. That's not FFMPEG, but from what you're trying to do it sounds
like you can do most of it with Nvidia NVENC and NVDEC and just use AV lib
to muxe encoded data into final output.

On Wed, May 23, 2018, 22:23 joep <joep at groovytunes.nl> wrote:

> Hello,
>
>
> I am trying to create a program that does the following:
>
> 1. decode frames with cuvid
>
> 2. run CUDA kernels on the decoded frames
>
> 3. encode result with nvenc
>
>
> In order to do step 2, I need the CUDA kernels to access the decoded frame
> which should be stored in the GPU memory.
>
> For this I think I need to provide the CUDA CUcontext to ffmpeg and give
> the pointer to the decoded frame to the kernel.
>
> I could not find any documentation about this topic.
>
> In the ffmpeg docs I see the AVCodecContext has hw_device_ctx which is a
> AVHWDeviceContext.
>
> AVHWDeviceContext has a hwctx field which can be a AVCUDADeviceContext.
>
> AVCUDADeviceContext has a cuda_ctx field which is a CUcontext.
>
>
> So I think I need to create a AVHWDeviceContext and set it on the AVCodecContext
> before calling avcodec_open2.
>
> Are my assumptions right?
>
> And how can I create a AVHWDeviceContext with the correct hwctx?
>
>
> Thanks,
>
> Joep
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20180523/f95935f9/attachment.html>


More information about the Libav-user mailing list