How to consume VAAPI VASurface in appsink

Víctor Jáquez vjaquez at igalia.com
Thu Aug 9 16:46:47 UTC 2018


On Thu, 09 Aug 2018 at 15:56, Galoppo, Nico wrote:
> Thanks!
> 
> However, the vaapipostproc doesn't seem to support
> "video/x-raw(memory:DMABuf)" on its source pad. I tried it out as follows:
> 
> gst-launch-1.0 -v souphttpsrc
> location=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm
> ! matroskademux ! vaapidecodebin ! vaapipostproc !
> "video/x-raw(memory:DMABuf)" ! fakesink

At least the pipeline works for me. Btw, you could remove the vaapipostproc
since vaapidecodebin already contains it.


> Is there something I’m missing?
> 
> Also, if I do find a way to use gst_dmabuf_memory_get_fd(), how do I make sure
> to keep a reference to the memory so that it doesn't get reused after
> returning from the 'new-sample' callback? Is simply mapping the buffer
> sufficient?

You won't map it.

While you hold a reference of the GstBuffer structure, hopefully, it won't be
reused.

You extract the GstMemory from the GstBuffer and then get the fd from it.

You can learn how it is done in glupload:

https://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/gst-libs/gst/gl/gstglupload.c#n586

> 
> Thanks, 
> 
> Nico
> 
> 
> 
> -----Original Message-----
> From: gstreamer-devel <gstreamer-devel-bounces at lists.freedesktop.org> On Behalf Of Víctor Jáquez
> Sent: Thursday, August 09, 2018 8:07 AM
> To: gstreamer-devel at lists.freedesktop.org
> Subject: Re: How to consume VAAPI VASurface in appsink
> 
> On Wed, 08 Aug 2018 at 23:41, Galoppo, Nico wrote:
> > I have constructed a pipeline for decoding compressed video, with an 
> > appsink element at the end. The decoding pipeline is using GPU 
> > hardware decoding through libva/gst-vaapi. I am pulling samples in the appsink "new-sample"
> > signal callback, and have confirmed that the caps include 
> > "video/x-raw(VASurface)".
> 
> -> "video/x-raw(memory:VASurface)"
> 
> > 
> > My intent is to display (and potentially process) the framebuffer 
> > contained by the VASurface. Can I somehow get access to the VASurface 
> > through the GstBuffer contained in the GstSample? If so, then I could 
> > get to a DRM prime handle for GL/CL interop.
> 
> The VASurface is in a buffer's meta. But the meta's structure is not available. You might look at the element's source and copy the structure and extract it.
> 
> Nonetheless, if you want the DRM prime handle, I guess there's a direct way to do it, after the vaapipostproc set the caps feature "video/x-raw(memory:DMABuf)", then you get the dmabuf fd with
> gst_dmabuf_memory_get_fd()
> 
> https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-dmabuf.html
> 
> vmjl
> 
> > 
> > Thanks,
> > 
> > Nico
> > 
> 
> > _______________________________________________
> > gstreamer-devel mailing list
> > gstreamer-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


More information about the gstreamer-devel mailing list