<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi!
<div class=""><br class="">
</div>
<div class="">It is possible to do what you want to do. We do that, and more. Have a look at the ffmpeg-dev forums. There are some pretty interesting discussions about how to use your own cuda context, and even your own cuda stream.</div>
<div class=""><br class="">
</div>
<div class="">Good luck!</div>
<div class=""><br class="">
</div>
<div class="">Oscar<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">El 23 maig 2018, a les 8:24, joep <<a href="mailto:joep@groovytunes.nl" class="">joep@groovytunes.nl</a>> va escriure:</div>
<br class="Apple-interchange-newline">
<div class="">
<meta name="Generator" content="Kopano WebApp v8.6.80" class="">
<title class=""></title>
<div class=""><!-- begin sanitized html -->
<div class="bodyclass">
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class="">Hello,</span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><br class="">
</span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class="">I am trying to create a program that does the following:<br class="">
</span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class="">1. decode frames with cuvid</span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class="">2. run CUDA kernels on the decoded frames</span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class="">3. encode result with nvenc</span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><br class="">
</span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class="">In order to do step 2, I need the CUDA kernels to access the decoded frame which should be stored in the GPU memory.</span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class="">For this I think I need to provide the CUDA CUcontext to ffmpeg and give the pointer to the decoded frame to the kernel.</span></div>
<p style="padding: 0; margin: 0;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""></span></p>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class="">I could not find any documentation about this topic.<br class="">
</span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class="">In the ffmpeg docs I see the AVCodecContext has hw_device_ctx which is a </span><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class="">AVHWDeviceContext.</span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 13.3333px;" class="">AVHWDeviceContext has
 a hwctx field which can be a AVCUDADeviceContext.</span></span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 13.3333px;" class="">AVCUDADeviceContext has
 a cuda_ctx field which is a CUcontext.</span></span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 13.3333px;" class=""><br class="">
</span></span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 13.3333px;" class="">So I think I need to
 create a AVHWDeviceContext and set it on the </span></span><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 13.3333px;" class="">AVCodecContext
 before calling avcodec_open2.</span></span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 13.3333px;" class="">Are my assumptions right?</span></span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 13.3333px;" class="">And how can I create
 a AVHWDeviceContext with the correct hwctx?</span></span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 13.3333px;" class=""><br class="">
</span></span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 13.3333px;" class="">Thanks,</span></span></div>
<div style="padding: 0px; margin: 0px;" class=""><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;" class=""><span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 13.3333px;" class="">Joep</span></span></div>
</div>
<!-- end sanitized html --></div>
_______________________________________________<br class="">
Libav-user mailing list<br class="">
<a href="mailto:Libav-user@ffmpeg.org" class="">Libav-user@ffmpeg.org</a><br class="">
http://ffmpeg.org/mailman/listinfo/libav-user<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>