Set alignment for textoverlay

I have C code that does

g_object_set (clockoverlay, “halignment”, “left”, “valignment”, “top”, “draw-outline”, TRUE, “font-desc”, “Sans, 12”, “time-format”, “%d %b %Y %H:%M:%S”, NULL);

g_object_set (textoverlay1, “text”, “This is Line 1”, “deltay”, 50, “halignment”, “left”, “valignment”, “top”, “font-desc”, “Sans, 10”, “draw-outline”, TRUE, NULL);

but when I run I get

(dvrPR:46850): GLib-GObject-CRITICAL **: 06:24:41.960: value “((GstBaseTextOverlayHAlign) -780639777)” of type ‘GstBaseTextOverlayHAlign’ is invalid or out of range for property ‘halignment’ of type ‘GstBaseTextOverlayHAlign’

(dvrPR:46850): GLib-GObject-CRITICAL **: 06:24:41.960: value “((GstBaseTextOverlayVAlign) -780639792)” of type ‘GstBaseTextOverlayVAlign’ is invalid or out of range for property ‘valignment’ of type ‘GstBaseTextOverlayVAlign’

(dvrPR:46850): GLib-GObject-CRITICAL **: 06:24:41.961: value “((GstBaseTextOverlayHAlign) -780639777)” of type ‘GstBaseTextOverlayHAlign’ is invalid or out of range for property ‘halignment’ of type ‘GstBaseTextOverlayHAlign’

(dvrPR:46850): GLib-GObject-CRITICAL **: 06:24:41.961: value “((GstBaseTextOverlayVAlign) -780639792)” of type ‘GstBaseTextOverlayVAlign’ is invalid or out of range for property ‘valignment’ of type ‘GstBaseTextOverlayVAlign’

Can anyone enlighten me please
James

In C you need to use the integer values you see in gst-inspect-1.0 for enums/flags, e.g.: 0 for left:

  halignment          : Horizontal alignment of the text
                        flags: readable, writable
                        Enum "GstBaseTextOverlayHAlign" Default: 1, "center"
                           (0): left             - left
                           (1): center           - center
                           (2): right            - right
                           (4): Absolute position clamped to canvas - position
                           (5): Absolute position - absolute

Alternatively you can use: gst_util_set_object_arg()

gst_util_set_object_arg(G_OBJECT (textoverlay), "halignment", "left");

which will do the same string nickname to enum conversion as gst-launch does

Duh that’s obvious, there is so much to learn that overwhelmed moi is asking silly questions. But the hand holding is a great help, thankyou.

1 Like