<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-ligatures:standardcontextual;
        mso-fareast-language:EN-US;}
span.E-MailFormatvorlage17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-ligatures:standardcontextual;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link="#0563C1" vlink="#954F72" style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-GB>Hello,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>I want to encode a framebuffer I got via dmabuf into a video stream. I have a dmabuf file descriptor which contains the framebuffer.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>I got the filedescriptor from the intel i915 driver via ioctl VFIO_DEVICE_QUERY_GFX_PLANE. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>The dmabuf has the format BGRx and modifier is 0 respectively changes to I915_FORMAT_MOD_X_TILED.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Now I want to encode it per zero copy in gstreamer into a video stream (h264, h265 etc...). <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>I push the single frames per appsrc into the gstreamer pipline. Since I use intel hardware I thought it makes sense to use VAAPI.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>The problem is that the sink pads of vaapi only support video/x-raw and video/x-raw(memory:VASurface) and I have video/x-raw(memory:DMABuf).<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Is there any way to convert video/x-raw(memory:DMABuf) to video/x-raw(memory:VASurface) (zero copy) or import the DMABuf directly as video/x-raw(memory:VASurface)?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Alternatively is there a plugin which is better suited than vaapi?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>My code to push the frames into gstreamer currently looks like this:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>    GstMemory* mem = gst_dmabuf_allocator_alloc(vedpy->gdata.allocator, dmabuf->fd, dmabuf->width * dmabuf->height * (dmabuf->stride/1024));<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    vedpy->gdata.buffer = gst_buffer_new();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    gst_buffer_append_memory(vedpy->gdata.buffer, mem );<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    gsize offset[GST_VIDEO_MAX_PLANES] = {0, 0, 0, 0};<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    gint stride[GST_VIDEO_MAX_PLANES] = {dmabuf->stride, 0, 0, 0};<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    gst_buffer_add_video_meta_full( vedpy->gdata.buffer, GST_VIDEO_FRAME_FLAG_NONE,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>                                    GST_VIDEO_FORMAT_ENCODED,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>                                    dmabuf->width, dmabuf->height, 1, offset, stride);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    GstFlowReturn ret;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    vfio_encode_dpy *vedpy = container_of(dcl, vfio_encode_dpy, dcl);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    g_signal_emit_by_name (vedpy->gdata.source, "push-buffer", vedpy->gdata.buffer, &ret);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    ...<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>   <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>And my pipline:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>char launch_stream[]  = "appsrc name=source ! "<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    " video/x-raw(memory:DMABuf),width=1024,height=768,framerate=0/1,format={BGRx,BGRx:0x0100000000000001} ! "<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    " vaapipostproc !"<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    " vaapih265enc ! <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>    ...<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>which obviously does not work, because vaapipostproc cannot be linked with the filter.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Thanks in advance.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Best Regards,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>Michael<o:p></o:p></span></p></div></body></html>