Overlay peak value on video

Tim Müller tim at centricular.com
Fri Mar 6 05:21:03 PST 2015


On Fri, 2015-03-06 at 11:30 +0000, Paul Barber wrote:

Hey Paul,

> What do you think would be the best way to write an element that makes 
> some measurement on the video buffer (say the peak RGB values) and then 
> overlays that measurement onto the video itself?
> 
> Making the measurement is no problem. I have used the template filter 
> plugin, access the buffer and detect the peak values in the video chain 
> function.
> I am also aware of the textoverlay element which will overlay static 
> text or via the text sink .
> Can I make an element that will act as a text src for the textoverlay 
> text sink?
> Can I push text out on a text src pad from within the video chain function?
> Or is there a better way?

Perhaps something like this:

 - make a bin, and into the bin you put your measurement element into
that bin

 - add a sink ghostpad to the bin and point it to the sink pad of your
element

 - add a textoverlay element to the bin and link it with your
measurement element (put it after your measurement element)

 - add a src ghostpad to the bin and point it to the src pad of the
textoverlay element

Then what you need is a mechanism for your measurement element to put
the result as "text" property on the textoverlay. In the simplest case
the element just knows about the bin and the textoverlay and can just
set the property directly. Alternatively you could subclass GstBin,
override the handle_message vfunc, and have the measurement element post
a message with the measurement, and then intercept that in the bin and
set the right string on textoverlay (which will be done just before the
buffer is pushed to it).

Cheers
 -Tim

-- 
Tim Müller, Centricular Ltd - http://www.centricular.com



More information about the gstreamer-devel mailing list