2004-08-11 21:06:48 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* Copyright (C) <2003> David Schleef <ds@schleef.org>
|
2006-02-19 12:41:03 +00:00
|
|
|
* Copyright (C) <2006> Julien Moutte <julien@moutte.net>
|
2009-03-26 09:36:27 +00:00
|
|
|
* Copyright (C) <2006> Zeeshan Ali <zeeshan.ali@nokia.com>
|
2008-06-02 18:37:02 +00:00
|
|
|
* Copyright (C) <2006-2008> Tim-Philipp Müller <tim centricular net>
|
2009-08-04 09:35:10 +00:00
|
|
|
* Copyright (C) <2009> Young-Ho Cha <ganadist@gmail.com>
|
2011-04-16 13:56:55 +00:00
|
|
|
* Copyright (C) <2011> Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
2004-08-11 21:06:48 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2004-08-11 21:06:48 +00:00
|
|
|
*/
|
2003-07-17 06:29:48 +00:00
|
|
|
|
2005-12-02 16:52:54 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-textoverlay
|
2011-04-16 13:56:55 +00:00
|
|
|
* @see_also: #GstTextRender, #GstTextOverlay, #GstTimeOverlay, #GstSubParse
|
2005-12-02 16:52:54 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2011-03-04 12:52:01 +00:00
|
|
|
*
|
2005-12-02 16:52:54 +00:00
|
|
|
* The text can contain newline characters and text wrapping is enabled by
|
|
|
|
* default.
|
2008-07-10 21:06:06 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* <title>Example launch lines</title>
|
|
|
|
* |[
|
2015-05-09 21:33:26 +00:00
|
|
|
* gst-launch-1.0 -v gst-launch-1.0 videotestsrc ! textoverlay text="Room A" valignment=top halignment=left font-desc="Sans, 72" ! autovideosink
|
2008-07-10 21:06:06 +00:00
|
|
|
* ]| Here is a simple pipeline that displays a static text in the top left
|
2011-03-04 12:52:01 +00:00
|
|
|
* corner of the video picture
|
2008-07-10 21:06:06 +00:00
|
|
|
* |[
|
2015-05-09 21:33:26 +00:00
|
|
|
* gst-launch-1.0 -v filesrc location=subtitles.srt ! subparse ! txt. videotestsrc ! timeoverlay ! textoverlay name=txt shaded-background=yes ! autovideosink
|
2008-07-10 21:06:06 +00:00
|
|
|
* ]| Here is another pipeline that displays subtitles from an .srt subtitle
|
2005-12-02 16:52:54 +00:00
|
|
|
* file, centered at the bottom of the picture and with a rectangular shading
|
|
|
|
* around the text in the background:
|
2008-07-10 21:06:06 +00:00
|
|
|
* <para>
|
2005-12-15 10:15:10 +00:00
|
|
|
* If you do not have such a subtitle file, create one looking like this
|
2005-12-02 16:52:54 +00:00
|
|
|
* in a text editor:
|
2008-07-10 21:06:06 +00:00
|
|
|
* |[
|
2006-03-24 10:42:11 +00:00
|
|
|
* 1
|
|
|
|
* 00:00:03,000 --> 00:00:05,000
|
|
|
|
* Hello? (3-5s)
|
2011-03-04 12:52:01 +00:00
|
|
|
*
|
2006-03-24 10:42:11 +00:00
|
|
|
* 2
|
|
|
|
* 00:00:08,000 --> 00:00:13,000
|
2005-12-02 16:52:54 +00:00
|
|
|
* Yes, this is a subtitle. Don't
|
2006-03-24 10:42:11 +00:00
|
|
|
* you like it? (8-13s)
|
2011-03-04 12:52:01 +00:00
|
|
|
*
|
2006-03-24 10:42:11 +00:00
|
|
|
* 3
|
|
|
|
* 00:00:18,826 --> 00:01:02,886
|
|
|
|
* Uh? What are you talking about?
|
2005-12-02 16:52:54 +00:00
|
|
|
* I don't understand (18-62s)
|
2008-07-10 21:06:06 +00:00
|
|
|
* ]|
|
2005-12-02 16:52:54 +00:00
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
2003-07-17 06:29:48 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2011-04-16 13:56:55 +00:00
|
|
|
#include "config.h"
|
2009-08-04 10:22:14 +00:00
|
|
|
#endif
|
|
|
|
|
2011-04-16 13:56:55 +00:00
|
|
|
#include <gsttextoverlay.h>
|
2003-12-22 01:47:09 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate text_sink_template_factory =
|
2012-09-02 01:41:34 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("text_sink",
|
2003-12-22 01:47:09 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-09-02 01:41:34 +00:00
|
|
|
GST_STATIC_CAPS ("text/x-raw, format = { pango-markup, utf8 }")
|
2004-03-14 22:34:34 +00:00
|
|
|
);
|
|
|
|
|
2011-04-16 13:56:55 +00:00
|
|
|
G_DEFINE_TYPE (GstTextOverlay, gst_text_overlay, GST_TYPE_BASE_TEXT_OVERLAY);
|
2006-03-01 16:24:37 +00:00
|
|
|
|
2009-08-04 09:42:28 +00:00
|
|
|
static void
|
2011-04-16 13:56:55 +00:00
|
|
|
gst_text_overlay_class_init (GstTextOverlayClass * klass)
|
2003-11-02 01:21:38 +00:00
|
|
|
{
|
2011-04-16 13:56:55 +00:00
|
|
|
GstElementClass *element_class = (GstElementClass *) klass;
|
2003-11-02 01:21:38 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2011-04-16 13:56:55 +00:00
|
|
|
gst_static_pad_template_get (&text_sink_template_factory));
|
Port pango-based textoverlay, timeoverlay and textrender to 0.9 and add background shading and text wrapping modes. M...
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/pango/Makefile.am:
* ext/pango/gstclockoverlay.c: (gst_clock_overlay_base_init),
(gst_clock_overlay_render_time), (gst_clock_overlay_get_text),
(gst_clock_overlay_class_init), (gst_clock_overlay_init):
* ext/pango/gstclockoverlay.h:
* ext/pango/gsttextoverlay.c: (gst_text_overlay_base_init),
(gst_text_overlay_get_text), (gst_text_overlay_class_init),
(gst_text_overlay_finalize), (gst_text_overlay_init),
(gst_text_overlay_update_wrap_mode), (gst_text_overlay_setcaps),
(gst_text_overlay_text_pad_linked),
(gst_text_overlay_text_pad_unlinked),
(gst_text_overlay_set_property), (gst_text_overlay_getcaps),
(gst_text_overlay_shade_y), (gst_text_overlay_blit_yuv420),
(gst_text_overlay_resize_bitmap), (gst_text_overlay_render_text),
(gst_text_overlay_push_frame), (gst_text_overlay_pop_video),
(gst_text_overlay_pop_text), (gst_text_overlay_collected),
(gst_text_overlay_change_state), (plugin_init):
* ext/pango/gsttextoverlay.h:
* ext/pango/gsttimeoverlay.c: (gst_time_overlay_base_init),
(gst_time_overlay_render_time), (gst_time_overlay_get_text),
(gst_time_overlay_class_init), (gst_time_overlay_init):
* ext/pango/gsttimeoverlay.h:
Port pango-based textoverlay, timeoverlay and textrender to 0.9
and add background shading and text wrapping modes. Make
timoverlay derive from textoverlay. Also add new clockoverlay
element.
2005-11-30 13:20:57 +00:00
|
|
|
|
2012-04-09 23:45:16 +00:00
|
|
|
gst_element_class_set_static_metadata (element_class, "Text overlay",
|
2009-08-04 09:42:28 +00:00
|
|
|
"Filter/Editor/Video",
|
|
|
|
"Adds text strings on top of a video buffer",
|
|
|
|
"David Schleef <ds@schleef.org>, " "Zeeshan Ali <zeeshan.ali@nokia.com>");
|
Port pango-based textoverlay, timeoverlay and textrender to 0.9 and add background shading and text wrapping modes. M...
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/pango/Makefile.am:
* ext/pango/gstclockoverlay.c: (gst_clock_overlay_base_init),
(gst_clock_overlay_render_time), (gst_clock_overlay_get_text),
(gst_clock_overlay_class_init), (gst_clock_overlay_init):
* ext/pango/gstclockoverlay.h:
* ext/pango/gsttextoverlay.c: (gst_text_overlay_base_init),
(gst_text_overlay_get_text), (gst_text_overlay_class_init),
(gst_text_overlay_finalize), (gst_text_overlay_init),
(gst_text_overlay_update_wrap_mode), (gst_text_overlay_setcaps),
(gst_text_overlay_text_pad_linked),
(gst_text_overlay_text_pad_unlinked),
(gst_text_overlay_set_property), (gst_text_overlay_getcaps),
(gst_text_overlay_shade_y), (gst_text_overlay_blit_yuv420),
(gst_text_overlay_resize_bitmap), (gst_text_overlay_render_text),
(gst_text_overlay_push_frame), (gst_text_overlay_pop_video),
(gst_text_overlay_pop_text), (gst_text_overlay_collected),
(gst_text_overlay_change_state), (plugin_init):
* ext/pango/gsttextoverlay.h:
* ext/pango/gsttimeoverlay.c: (gst_time_overlay_base_init),
(gst_time_overlay_render_time), (gst_time_overlay_get_text),
(gst_time_overlay_class_init), (gst_time_overlay_init):
* ext/pango/gsttimeoverlay.h:
Port pango-based textoverlay, timeoverlay and textrender to 0.9
and add background shading and text wrapping modes. Make
timoverlay derive from textoverlay. Also add new clockoverlay
element.
2005-11-30 13:20:57 +00:00
|
|
|
}
|
|
|
|
|
2003-07-17 06:29:48 +00:00
|
|
|
static void
|
2011-04-16 13:56:55 +00:00
|
|
|
gst_text_overlay_init (GstTextOverlay * overlay)
|
2003-07-17 06:29:48 +00:00
|
|
|
{
|
Port pango-based textoverlay, timeoverlay and textrender to 0.9 and add background shading and text wrapping modes. M...
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/pango/Makefile.am:
* ext/pango/gstclockoverlay.c: (gst_clock_overlay_base_init),
(gst_clock_overlay_render_time), (gst_clock_overlay_get_text),
(gst_clock_overlay_class_init), (gst_clock_overlay_init):
* ext/pango/gstclockoverlay.h:
* ext/pango/gsttextoverlay.c: (gst_text_overlay_base_init),
(gst_text_overlay_get_text), (gst_text_overlay_class_init),
(gst_text_overlay_finalize), (gst_text_overlay_init),
(gst_text_overlay_update_wrap_mode), (gst_text_overlay_setcaps),
(gst_text_overlay_text_pad_linked),
(gst_text_overlay_text_pad_unlinked),
(gst_text_overlay_set_property), (gst_text_overlay_getcaps),
(gst_text_overlay_shade_y), (gst_text_overlay_blit_yuv420),
(gst_text_overlay_resize_bitmap), (gst_text_overlay_render_text),
(gst_text_overlay_push_frame), (gst_text_overlay_pop_video),
(gst_text_overlay_pop_text), (gst_text_overlay_collected),
(gst_text_overlay_change_state), (plugin_init):
* ext/pango/gsttextoverlay.h:
* ext/pango/gsttimeoverlay.c: (gst_time_overlay_base_init),
(gst_time_overlay_render_time), (gst_time_overlay_get_text),
(gst_time_overlay_class_init), (gst_time_overlay_init):
* ext/pango/gsttimeoverlay.h:
Port pango-based textoverlay, timeoverlay and textrender to 0.9
and add background shading and text wrapping modes. Make
timoverlay derive from textoverlay. Also add new clockoverlay
element.
2005-11-30 13:20:57 +00:00
|
|
|
}
|