<div dir="ltr"><div><br></div><div>Thank you Sebastian!!</div><div><br></div><div>I can now access the subtitle stream that is closely sync'ed up with the video. I am using <b>appsink </b>as suggested on the playbin2 <b>text-sink </b>property to pull the text buffer and computing the running time using base time and clock. </div>
<div><br></div><div>One issue that I now have is that subtitle is not displayed on the final video. Is this because of using <b>appsink </b>on the <b>text-sink </b>property instead of an actual text processing element. Any idea how I can fix this - get the subtitle text and timestamp in my console output and also display the same on the final video.</div>
<div><br></div><div>Gracias</div><div>Dece</div><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Tue, 12 Nov 2013 07:36:18 -0500<br>
From: Dece Bel <<a href="mailto:decebel@gmail.com">decebel@gmail.com</a>><br>
To: <a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
Subject: buffer probe data out of sync for subtitle text pad<br>
Message-ID:<br>
<CAPqbHrgBUaeE9KLzA=<a href="mailto:ib_dc-5pDayLJ20wOxazSSH7Xs6XJJbA@mail.gmail.com">ib_dc-5pDayLJ20wOxazSSH7Xs6XJJbA@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
I am trying to read subtitle from a video and want to record the timestamp<br>
of the subtitled text in the gstreamer pipeline.<br>
One approach that I have been trying is with the getting the action signal<br>
on playbin for "get-text-pad"<br>
and attaching a probe on the pad. Eventually when the callback<br>
(cb_have_data) is called, I do see the text in the buffer dumped on console.<br>
<br>
However, I notice that the subtitle on the final rendered video and the one<br>
dumped from the probe callback are out of sync.<br>
Can someone pls suggest how to get the timestamp of the subtitled text from<br>
the stream or received a sync'ed stream or any other approach.<br>
<br>
<br>
Gracias<br>
Dece<br>
<br>
below is some relevant stripped code that uses the playbin element (using<br>
gstreamer 1.0)<br>
<br>
main() {<br>
<br>
// creating the playbin element and setting flags to also play sub-titles<br>
...<br>
...<br>
..<br>
...<br>
<br>
g_signal_emit_by_name (data->playbin, "get-text-pad", 0, &txt_pad);<br>
if(txt_pad) {<br>
printf("\nwe have a text pad");<br>
*c**a_pad_data(txt_pad);*<br>
}<br>
<br>
}<br>
<br>
<br>
///////////////////////////////////////<br>
// When text pad is added, the below function will attach a probe<br>
<br>
*void cb_pad_added(GstPad* pd) {*<br>
* gchar *name;*<br>
* GstCaps *caps = NULL;*<br>
<br>
* name = gst_pad_get_name (pd);*<br>
* g_print ("\nA new pad %s was created\n", name);*<br>
* g_free (name);*<br>
<br>
<br>
* gst_pad_add_probe (pd, GST_PAD_PROBE_TYPE_BUFFER, (GstPadProbeCallback)<br>
cb_have_data, NULL, NULL);*<br>
<br>
* gst_object_unref (pd);*<br>
<br>
*}*<br>
<br>
<br>
///////////////////////////////////////////////<br>
// probe call back. Read the buffer an size and then print the buffer text<br>
to screen.<br>
<br>
*static GstPadProbeReturn*<br>
*cb_have_data (GstPad *pad,*<br>
* GstPadProbeInfo *info,*<br>
* gpointer user_data) {*<br>
<br>
* GstBuffer *buffer;*<br>
* char text_msg[128];*<br>
<br>
* gint sz, sz2;*<br>
* memset(text_msg, 0, sizeof(text_msg));*<br>
* buffer = GST_PAD_PROBE_INFO_BUFFER (info);*<br>
* sz = gst_buffer_get_size(buffer);*<br>
<br>
* sz2 = gst_buffer_extract(buffer, 0, text_msg, sz);*<br>
* g_print ("\nBuffer Size is %d, read %d, data: %s", sz, sz2, text_msg);*<br>
* return GST_PAD_PROBE_OK;*<br>
*}*<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131112/9268a936/attachment-0001.html" target="_blank">http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131112/9268a936/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Tue, 12 Nov 2013 13:44:36 +0100<br>
From: Sebastian Dr?ge <<a href="mailto:sebastian@centricular.com">sebastian@centricular.com</a>><br>
To: Discussion of the development of and with GStreamer<br>
<<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>><br>
Subject: Re: buffer probe data out of sync for subtitle text pad<br>
Message-ID: <1384260276.2586.6.camel@thor.lan><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
On Di, 2013-11-12 at 07:36 -0500, Dece Bel wrote:<br>
> I am trying to read subtitle from a video and want to record the timestamp<br>
> of the subtitled text in the gstreamer pipeline.<br>
> One approach that I have been trying is with the getting the action signal<br>
> on playbin for "get-text-pad"<br>
> and attaching a probe on the pad. Eventually when the callback<br>
> (cb_have_data) is called, I do see the text in the buffer dumped on console.<br>
><br>
> However, I notice that the subtitle on the final rendered video and the one<br>
> dumped from the probe callback are out of sync.<br>
> Can someone pls suggest how to get the timestamp of the subtitled text from<br>
> the stream or received a sync'ed stream or any other approach.<br>
<br>
You could also set a text-sink on playbin btw. But the problem stays the<br>
same wrt synchronization. You need to convert the buffer timestamps to<br>
running-time, and then check them against the current running time of<br>
the sink (clock_time - base_time). Usually you will get buffers much<br>
earlier and then need to wait a bit until they are to be displayed.<br>
<br>
--<br>
Sebastian Dr?ge <<a href="mailto:sebastian@centricular.com">sebastian@centricular.com</a>><br>
Centricular Ltd - <a href="http://www.centricular.com" target="_blank">http://www.centricular.com</a><br>
Expertise, Straight from the Source<br>
-------------- next part --------------<br>
A non-text attachment was scrubbed...<br>
Name: signature.asc<br>
Type: application/pgp-signature<br>
Size: 966 bytes<br>
Desc: This is a digitally signed message part<br>
URL: <<a href="http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131112/f7043ba5/attachment-0001.pgp" target="_blank">http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131112/f7043ba5/attachment-0001.pgp</a>><br>
</blockquote></div></div></div>