Replacing subtitles in video at run-time with custom text

Sebastian Dröge sebastian at centricular.com
Mon Oct 28 09:20:36 CET 2013


On So, 2013-10-27 at 21:34 -0400, Dece Bel wrote:
> I want to develop an application with gstreamer to play videos with custom
> subtitles that replaces original subtitles with my custom text at run-time
> of the video. For example, if a video has english subtitles, I want to
> replace the original subtitle with additional comments as the video plays.
> 
> I have been playing with the various gstreamer C tutorials to get a basic
> understanding of the pipeline and make myself familiar with the necessary
> APIs/techniques. One of the examples shows selecting & switching sub-titles
> from multiple languages in the sample video stream.
> 
> However, I could not find any example or gstreamer element that can be to
> added into the pipeline to extract the subtitle text or add back some
> custom subtitle in the pipeline.
> 
> I was hoping to put together a quick gstreamer pipeline to do the same with
> my text replacement module added to the pipeline to do the custom subtitle
> replacement.
> 
> The design I have in mind is to build a pipeline with an element that
> extracts subtitles as the video plays, then pass it through a custom
> element that analyses the text and add some comments and put the comments
> back to the video stream.
> 
> Alternatively, I was wondering if there is a callback available that can be
> registered to the gstreamer message-bus that gets called whenever a
> subtitle text is about to be displayed, and some capability to edit the
> original text.
> 
> I do not have experience with gstreamer or other multimedia frameworks but
> descent experience with C/C++ development.

Hi,

if you're using playbin the easiest way to do this would be a custom
GstElement that you set as text-selector on it. This would get all
subtitles of all subtitle streams passed, and must follow the properties
and behaviour of the input-selector element.
Alternatively you could get the playsink element from inside playbin and
add a pad probe (gst_pad_add_probe()) on the subtitle sinkpad to get a
callback called for every subtitle buffer.

Outside playbin you could just do it with pad probe on a pad through
which the subtitles travel.

-- 
Sebastian Dröge <sebastian at centricular.com>
Centricular Ltd - http://www.centricular.com
Expertise, Straight from the Source
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 966 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131028/b2518bf3/attachment-0001.pgp>


More information about the gstreamer-devel mailing list