cairooverlay: Generic Cairo overlay element for GStreamer

I wrote the initial version of this in late January, and after some interations it was merged yesterday to gst-plugins-good, and will be in gst-plugins-good 0.10.33. This solves the feature request I filed in 2009, one of my oldest bugreports in!

What does it do?

cairooverlay allows you to draw arbitrary things on top of a video stream in GStreamer using Cairo. Previously you had to create a custom GStreamer element for that (in C/Vala), but now you can just hook up to some signals, using any programming language with GStreamer/Cairo bindings.

To draw an overlay using this element, you use the “caps-updated” signal to get information about the video stream (like width and height) and the “draw” signal to do the actual drawing. In addition to the Cairo context, the draw signal passes you the timestamp and duration of the buffer, so you can also do animations.

For more info see the included example application or the documentation (should be updated soon). Here is the obligatory screenshot showing the example application drawing a heart onto a test videostream:

GStreamer + Cairo = <3

The heart is actually animated, so I guess I should have had a video. But you’ll just have to trust me that it is very cute, or grab the code yourself!

Flattr this!

11 thoughts on “cairooverlay: Generic Cairo overlay element for GStreamer

  1. I would like to use your overlay element from Vala, but I am not able to figure out, how it is possible to connect to the “caps_changed” signal from with Vala. Could you explain that more detailed? I would be happy to rewrite your example in Vala.

  2. Hi Jon, this is amazing. Except I can’t get it to compile! What system did you develop this on? I’m running ubuntu, I have libcairo2-dev installed. But whenever I try to compile I get the error message that cairo-gobject.h is not found. I’ve looked through the debian packages to see if I can find the package that would have this header file. But it seems to not be included. Do you have any suggestions for me to get your example to run?


  3. Hey. What are you trying to compile? GStreamer master? or 0.10? And which Ubuntu version are you on?
    The necessary header should be in libcairo2-dev, unless you are on lucid (10.04) or earlier.

  4. Hi Jon,

    I am using lucid because I’m doing embedded development. And the hardware I chose specifically calls for lucid 10.04. Does this mean that I will not be able to enjoy the functionality of cairooverlay?

  5. Hi John,
    I’m just trying to run your sample code. I know I have gstreamer working, because I have another example xoverlay.cpp running.

    I’m using lucid. I’m doing embedded development, and the hardware I chose is only guaranteed to work with ubuntu version 10.04. Does this mean that I will not be use your nifty cairooverlay functionality? Do you have any advice on how to get it to run? Should I just download cairo_gobject.h and plop it into my include folder?

    thanks for your help!

  6. _How_ are you trying to build the example application code? Inside a gstreamer-plugins-good git master tree, or did you just take the code and try to build against the GStreamer you have in your system?

    The cairo-gobject dependency is optional (its used mostly for bindings). In the example application, you can try to remove the include of cairo-gobject.h.

    Note that gstreamer-plugins-good in 10.04 will probably be to old to include the cairooverlay element, so you will need to build and install it yourself for the example to work.

  7. Hi Jon, I believe I’m just trying to build it agains tthe gstreamer in my system. I’m running this command from the terminal window: cc -o overlay `pkg-config –cflags –libs QtGui gstreamer-0.10 gstreamer-interfaces-0.10 gtk+-2.0 cairo` cairo_overlay.c

    I will see if I can install a more recent version of gstreamer. Thanks for your help!

  8. Hi, Jon!
    I tried to build application your example aplication in yocto/frescale linux.
    I have not definitions for GstVideoInfo. And search in Google wasn’t helpfully Could you help me to find it?
    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *