[gst-devel] Text rendering

Gergely Nagy gergely.nagy at neteyes.hu
Wed Feb 16 07:48:19 CET 2005


A few months ago, in last December, David Schleef wrote about the future
of textoverlay
(http://article.gmane.org/gmane.comp.video.gstreamer.devel/12264), which
got me thinking.

What I need (and what I have a crude hack for) is to be able to render
arbitrary text, and color it the way I want, then position it the way I
want, or move it around, and things like that. I need to be able to have
rainbow-coloured text, for example.

Now, the plan David outlined makes this quite hard and - imho - not
really elegant.

First of all, why blit the text onto an image, when we have an element
that can do that just fine? Even better, in bugzilla, there is another
(http://bugzilla.gnome.org/show_bug.cgi?id=166783) that can blend in
different modes (including color-only blending)! Then, there is an
element - also in bugzilla
(http://bugzilla.gnome.org/show_bug.cgi?id=166785) -, that scrolls
arbitrary buffers around.

My idea is an element that renders the text into an AYUV buffer, and
does nothing else. (Whether that text comes from a property or is
streamed from the elements sinkpad is irrelevant here)

One can color the text by creating an image with the same size of the
text, filled with the coloring one wants, and mix the two together using
color-only blending. Then, this can be cached (eg, using the freeze
plugin, also in bugzilla), and scrolled around using the scroller
element, connected to an image mixer.

There, you have text coloring, scrolling and almost everything you want
done the proper way - one elment doing one simple thing, and leaving the
rest to the others.

For the sake of usability, one could write a bin that renders the text,
creates a coloring buffer, mixes the two together, and outputs the
result in its srcpad.

As mentioned before, I have a crude hack that does something like this.
It's a chopped down version of textoverlay. You can see it in work at
http://neteyes.hu/~algernon/ogg/oggs/bouncy.ogg (along with the rest of
the plugins mentioned here).

This would also make ascii-art rendering in media players easier: one
renders the fonts, makes the video blocky (like 48x48 blocks for a 48
pixel font, or something), blends the latter to the former, and you have
nice, colored ascii video. Though, this might not be optimal... I guess
this'd be downwright dog-slow.

Anyway, for fancy effects (think not only in colors, but textures too),
the approach outlined here will work fine, I guess.

Comments appreciated!

Gergely Nagy <gergely.nagy at neteyes.hu>
NetEyes Kft.

More information about the gstreamer-devel mailing list