Generic DMABUF to vaapi h264 encoding

Volker Vogelhuber v.vogelhuber at digitalendoscopy.de
Thu Jul 23 08:03:11 PDT 2015



On 23.07.2015 15:59, Nicolas Dufresne wrote:
> Le jeudi 23 juillet 2015 à 10:34 +0200, Volker Vogelhuber a écrit :
>> Thanks for your reply. I thought that gstreamer's V4L2 plugins
>> require the source for handling DMABUFs to be a V4L2 device, because
>> I seem to remember that I saw ioctl calls somewhere in the
>> gstreamer's code handling V4L2 sources. Is there also the possibility
>> to use v4l2src with DMABUF file descriptors coming from somewhere
>> else (intel GPU driver).
> It's supported, but not required.
>
>> Regarding your other suggestion, you were right, that the format was
>> wrong. I already got vaapipostproc in my pipeline, but the input
>> format accepted seems to be GST_VIDEO_FORMAT_RGBx instead of
>> GST_VIDEO_FORMAT_xRGB.
>>
>> I can see during debugging that it now continues to run until
>> somewhere else a internal data flow error occurs. I'm trying to find
>> out where it stops.
>>
>> Basically what I want to do is to render into a texture in another
>> application. This texture is exported using a DMABUF file descriptor
>> and passed to my video recording process. There I want to encode it
>> using the VAAPI h264 encoder and after buffer has been processed I
>> can reuse the buffer within the rendering application.
>> Therefore it would be also nice if gstreamer can tell me when it is
>> not using the pushed buffer anymore. Is there any callback one could
>> add to maybe the vaapiencode_h264 or vaapipostproc element, that
>> notifies me, when the buffer pushed via appsrc isn't used anymore by
>> the pipeline?
> You need to track the memory, not the Buffer itself. If you only care
> about rendering it, then just make you dmabuf read only. Otherwise, you
> could use gst_mini_object_weak_ref() to get notified when the memory
> has been discarded (GstMemory derives from GstMiniObject).
>
> General notice about DMABUF, two driver may not be compatible. Which means the dmabuf from one driver, may not work inside another driver. As Sree mention, he never test the importation path in vaapiencode, that might also be completly broken.
>
> Nicolas
Thanks for your help it's actually working already. I accidentally 
decreased the reference count of the DMABUF buffer in the need-data 
callback, although I wanted to reuse the buffer later on. That was the 
reason why I got a data flow error after the first round trip of my 
buffers. I have to clean-up things and add the gst_mini_object_weak_ref 
callback for proper buffer management.  But I'm confident that I will 
get that done now that it's basically already working. Thanks again!

Regards,
    Volker


More information about the gstreamer-devel mailing list