Source to create transparent buffers for cairooverlay

In my pipeline I’m keeping the video processing on the GPU for performance. However, one of the steps is drawing overlays on the video using cairooverlay. That requires a glcolorconvert ! gldownload ! cairooverlay ! glupload ! glcolorconvert.

I figure it would be more efficient to do the drawing onto a transparent surface and then just feed that into the glvideomixer I already have for compositing. However, what I couldn’t quite figure out: how do I get transparent video buffers for drawing on? Using videotestsrc pattern=solid-color foreground-color=0x00000000 is-live=true ! ... would work, but it seems like an abuse of videotestsrc. Or maybe a compositor with no inputs? compositor force-live=true background=transparent. Maybe fakesrc?

Which would be the lowest overhead?

I would recommend using the overlaycomposition element. Then you can draw in any way you want from the callback, and e.g. use cairo to render to one or more transparent surfaces. That would get around the download/upload and would do the composition later directly in GL.

You can then also provide the same overlay for multiple frames (if it doesn’t change, obviously) and composition would be more efficient too as the same overlay would only be uploaded once to a GL texture.

There is an example in Rust doing something like this with cairo/pango. I was sure we also have an example in C somewhere but I can’t find it right now.

With gst-launch-1.0 -v gltestsrc ! overlaycomposition ! gloverlaycompositor ! glimagesink there won’t be the need for a download/upload as you can see from the caps.

Thanks, I’d never seen overlaycomposition and that sounds perfect :+1: