textoverlay

textoverlay

Properties

gint deltax Read / Write
gint deltay Read / Write
gchar * font-desc Write
gchar * halign Write
gboolean shaded-background Read / Write
gchar * text Read / Write
gchar * valign Write
GstTextOverlayWrapMode wrap-mode Read / Write
gint xpad Read / Write
gint ypad Read / Write
GstTextOverlayHAlign halignment Read / Write
GstTextOverlayVAlign valignment Read / Write
GstTextOverlayLineAlign line-alignment Read / Write
gboolean silent Read / Write
gboolean wait-text Read / Write
gboolean auto-resize Read / Write
gboolean vertical-render Read / Write
guint color Read / Write
gdouble xpos Read / Write
gdouble ypos Read / Write
guint outline-color Read / Write
gboolean shadow Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── GstObject
        ╰── GstElement
            ╰── GstTextOverlay
                ├── GstClockOverlay
                ╰── GstTimeOverlay

Description

This plugin renders text on top of a video stream. This can be either static text or text from buffers received on the text sink pad, e.g. as produced by the subparse element. If the text sink pad is not linked, the text set via the "text" property will be rendered. If the text sink pad is linked, text will be rendered as it is received on that pad, honouring and matching the buffer timestamps of both input streams.

The text can contain newline characters and text wrapping is enabled by default.

Example launch lines

1
gst-launch -v videotestsrc ! textoverlay text="Room A" valign=top halign=left ! xvimagesink
Here is a simple pipeline that displays a static text in the top left corner of the video picture
1
gst-launch -v filesrc location=subtitles.srt ! subparse ! txt.   videotestsrc ! timeoverlay ! textoverlay name=txt shaded-background=yes ! xvimagesink
Here is another pipeline that displays subtitles from an .srt subtitle file, centered at the bottom of the picture and with a rectangular shading around the text in the background:

If you do not have such a subtitle file, create one looking like this in a text editor:

1
2
3
4
5
6
7
8
9
10
11
12
13
1
00:00:03,000 --> 00:00:05,000
Hello? (3-5s)

2
00:00:08,000 --> 00:00:13,000
Yes, this is a subtitle. Don't
you like it? (8-13s)

3
00:00:18,826 --> 00:01:02,886
Uh? What are you talking about?
I don't understand  (18-62s)

One can also feed arbitrary live text into the element:

1
2
3
gst-launch fdsrc fd=0 ! text/plain ! txt. videotestsrc ! \
textoverlay  name=txt shaded-background=yes font-desc="Serif 40" wait-text=false ! \
xvimagesink

This shows new text as entered on the terminal (stdin). This is not suited for subtitles as the test overlay is not timed. Subtitles should use timestamped formats. For the above use case one can also read the text from the application as set the “text” property.

Functions

Types and Values

struct GstTextOverlay

struct GstTextOverlay;

Opaque textoverlay object structure


enum GstTextOverlayVAlign

Vertical alignment of the text.

Members

GST_TEXT_OVERLAY_VALIGN_BASELINE

draw text on the baseline

 

GST_TEXT_OVERLAY_VALIGN_BOTTOM

draw text on the bottom

 

GST_TEXT_OVERLAY_VALIGN_TOP

draw text on top

 

GST_TEXT_OVERLAY_VALIGN_POS

draw text according to the “ypos” property

 

GST_TEXT_OVERLAY_VALIGN_CENTER

draw text vertically centered

 

enum GstTextOverlayHAlign

Horizontal alignment of the text.

Members

GST_TEXT_OVERLAY_HALIGN_LEFT

align text left

 

GST_TEXT_OVERLAY_HALIGN_CENTER

align text center

 

GST_TEXT_OVERLAY_HALIGN_RIGHT

align text right

 

GST_TEXT_OVERLAY_HALIGN_UNUSED

   

GST_TEXT_OVERLAY_HALIGN_POS

position text according to the “xpos” property

 

enum GstTextOverlayWrapMode

Whether to wrap the text and if so how.

Members

GST_TEXT_OVERLAY_WRAP_MODE_NONE

no wrapping

 

GST_TEXT_OVERLAY_WRAP_MODE_WORD

do word wrapping

 

GST_TEXT_OVERLAY_WRAP_MODE_CHAR

do char wrapping

 

GST_TEXT_OVERLAY_WRAP_MODE_WORD_CHAR

do word and char wrapping

 

Property Details

The “deltax” property

  “deltax”                   gint

Shift X position to the left or to the right. Unit is pixels.

Flags: Read / Write

Default value: 0


The “deltay” property

  “deltay”                   gint

Shift Y position up or down. Unit is pixels.

Flags: Read / Write

Default value: 0


The “font-desc” property

  “font-desc”                gchar *

Pango font description of font to be used for rendering. See documentation of pango_font_description_from_string for syntax.

Flags: Write

Default value: ""


The “halign” property

  “halign”                   gchar *

Horizontal alignment of the text (deprecated; use halignment).

Flags: Write

Default value: "center"


The “shaded-background” property

  “shaded-background”        gboolean

Whether to shade the background under the text area.

Flags: Read / Write

Default value: FALSE


The “text” property

  “text”                     gchar *

Text to be display.

Flags: Read / Write

Default value: ""


The “valign” property

  “valign”                   gchar *

Vertical alignment of the text (deprecated; use valignment).

Flags: Write

Default value: "baseline"


The “wrap-mode” property

  “wrap-mode”                GstTextOverlayWrapMode

Whether to wrap the text and if so how.

Flags: Read / Write

Default value: wordchar


The “xpad” property

  “xpad”                     gint

Horizontal paddding when using left/right alignment.

Flags: Read / Write

Allowed values: >= 0

Default value: 25


The “ypad” property

  “ypad”                     gint

Vertical padding when using top/bottom alignment.

Flags: Read / Write

Allowed values: >= 0

Default value: 25


The “halignment” property

  “halignment”               GstTextOverlayHAlign

Horizontal alignment of the text.

Flags: Read / Write

Default value: center


The “valignment” property

  “valignment”               GstTextOverlayVAlign

Vertical alignment of the text.

Flags: Read / Write

Default value: baseline


The “line-alignment” property

  “line-alignment”           GstTextOverlayLineAlign

Alignment of text lines relative to each other (for multi-line text)

Flags: Read / Write

Default value: center

Since: 0.10.15


The “silent” property

  “silent”                   gboolean

If set, no text is rendered. Useful to switch off text rendering temporarily without removing the textoverlay element from the pipeline.

Flags: Read / Write

Default value: FALSE

Since: 0.10.15


The “wait-text” property

  “wait-text”                gboolean

If set, the video will block until a subtitle is received on the text pad. If video and subtitles are sent in sync, like from the same demuxer, this property should be set.

Flags: Read / Write

Default value: TRUE

Since: 0.10.20


The “auto-resize” property

  “auto-resize”              gboolean

Automatically adjust font size to screen-size.

Flags: Read / Write

Default value: TRUE


The “vertical-render” property

  “vertical-render”          gboolean

Vertical Render.

Flags: Read / Write

Default value: FALSE


The “color” property

  “color”                    guint

Color of the rendered text.

Flags: Read / Write

Default value: 4294967295

Since: 0.10.31


The “xpos” property

  “xpos”                     gdouble

Horizontal position of the rendered text when using positioned alignment.

Flags: Read / Write

Allowed values: [0,1]

Default value: 0.5

Since: 0.10.31


The “ypos” property

  “ypos”                     gdouble

Vertical position of the rendered text when using positioned alignment.

Flags: Read / Write

Allowed values: [0,1]

Default value: 0.5

Since: 0.10.31


The “outline-color” property

  “outline-color”            guint

Color of the outline of the rendered text.

Flags: Read / Write

Default value: 4278190080

Since: 0.10.36


The “shadow” property

  “shadow”                   gboolean

Whether to display a shadow of each letter under the text.

Flags: Read / Write

Default value: TRUE

Since: 0.10.36

See Also

GstTextRender, GstClockOverlay, GstTimeOverlay, GstSubParse