Reputation: 184
how do i set multiple lines of text in the textoverlay pipe in gst-launch?
I want to set up a pipeline and want to have multiple lines of text both vertically and horizontally centered. I'm able to do 1 line.
I'm not sure how to specify a newline.
gst-launch-1.0 videotestsrc pattern=0 horizontal-speed=0 is-live=1 \
! textoverlay text="PLEASE <b>STAND</b> <span foreground=\"blue\" size=\"x-large\">\nBY</span>Next <u>under-line</u>" valignment=center halignment=center font-desc="Sans, 24" \ ... other pipes ...
I would like to basically have 2+ lines. both be vertically and horizontally aligned with respect to each other and the overall screen.
Upvotes: 1
Views: 1601
Reputation: 11
I don't know how to pass newline character inside a parameter in gst-launch
, but you can achieve the same thing using C code. Below is the example:
#include <glib.h>
#include <gst/gst.h>
int main(int argc, char* argv[])
{
GMainLoop* loop;
GstElement *pipeline, *source, *overlay, *sink;
gst_init(&argc, &argv);
loop = g_main_loop_new(NULL, FALSE);
// initialize elements
pipeline = gst_pipeline_new("audio-player");
source = gst_element_factory_make("videotestsrc", "source");
overlay = gst_element_factory_make("textoverlay", "overlay");
sink = gst_element_factory_make("autovideosink", "sink");
if (!pipeline || !source || !overlay || !sink) {
g_printerr("One element could not be created. Exiting.\n");
return -1;
}
g_object_set(G_OBJECT(overlay), "text", "blebleble\nble", NULL);
g_object_set(G_OBJECT(overlay), "font-desc", "Sans, 24", NULL);
g_object_set(G_OBJECT(overlay), "halignment", 1, NULL);
g_object_set(G_OBJECT(overlay), "valignment", 1, NULL);
// add elements to pipeline
gst_bin_add_many(GST_BIN(pipeline), source, overlay, sink, NULL);
// link elements
gst_element_link(source, overlay);
gst_element_link_many(overlay, sink, NULL);
gst_element_set_state(pipeline, GST_STATE_PLAYING);
g_main_loop_run(loop);
// cleanup
gst_element_set_state(pipeline, GST_STATE_NULL);
gst_object_unref(GST_OBJECT(pipeline));
g_main_loop_unref(loop);
return 0;
}
Upvotes: 1