<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
The normal way to do this is to add an <a
href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-appsink.html">appsink</a>
as playbin's "text-sink".<br>
<br>
<div class="moz-cite-prefix">On 11/12/2013 06:34 AM, Dece Bel wrote:<br>
</div>
<blockquote
cite="mid:CAPqbHrgXwUGzWocBhDVdkea5tMhq5ns1TFd5MOn8OrZDBp4MQA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div><br>
</div>
<div>I am trying to read subtitle from a video and want to
record the timestamp of the subtitled text in the gstreamer
pipeline.</div>
<div>One approach that I have been trying is with the getting
the action signal on playbin for "get-text-pad"</div>
<div>and attaching a probe on the pad. Eventually when the
callback (cb_have_data) is called, I do see the text in the
buffer dumped on console.</div>
<div><br>
</div>
<div>However, I notice that the subtitle on the final rendered
video and the one dumped from the probe callback are out of
sync. </div>
<div>Can someone pls suggest how to get the timestamp of the
subtitled text from the stream or received a sync'ed stream or
any other approach.</div>
<div><br>
</div>
<div><br>
</div>
<div>Gracias</div>
<div>Dece</div>
<div>
<br>
</div>
<div>below is some relevant stripped code that uses the playbin
element (using gstreamer 1.0)</div>
<div><br>
</div>
<div>main() {</div>
<div><br>
</div>
<div>// creating the playbin element and setting flags to also
play sub-titles</div>
<div>...</div>
<div>...</div>
<div>.. </div>
<div>...</div>
<div><br>
</div>
<div>
<div>g_signal_emit_by_name (data->playbin, "get-text-pad",
0, &txt_pad);</div>
<div>if(txt_pad) {</div>
<div><span class="" style="white-space:pre"> </span>printf("\nwe
have a text pad");</div>
<div><span class="" style="white-space:pre"> <b>c</b></span><b>a_pad_data(txt_pad);</b></div>
<div><span class="" style="white-space:pre"> </span>}</div>
</div>
<div><br>
</div>
<div>}</div>
<div><br>
</div>
<div><br>
</div>
<div>
///////////////////////////////////////</div>
<div>// When text pad is added, the below function will attach a
probe</div>
<div><br>
</div>
<div><b><i>void cb_pad_added(GstPad* pd) {</i></b></div>
<div><b><i> gchar *name;</i></b></div>
<div><b><i> GstCaps *caps = NULL;</i></b></div>
<div><b><i><br>
</i></b></div>
<div><b><i> name = gst_pad_get_name (pd);</i></b></div>
<div><b><i> g_print ("\nA new pad %s was created\n", name);</i></b></div>
<div>
<b><i> g_free (name);</i></b></div>
<div><b><i><br>
</i></b></div>
<div><b><i><br>
</i></b></div>
<div><b><i> gst_pad_add_probe (pd, GST_PAD_PROBE_TYPE_BUFFER,
(GstPadProbeCallback) cb_have_data, NULL, NULL);</i></b></div>
<div>
<b><i><br>
</i></b></div>
<div><b><i> gst_object_unref (pd);</i></b></div>
<div><b><i><br>
</i></b></div>
<div><b><i>}</i></b></div>
<div><b><i><br>
</i></b></div>
<div><br>
</div>
<div>///////////////////////////////////////////////</div>
<div>// probe call back. Read the buffer an size and then print
the buffer text to screen.</div>
<div><br>
</div>
<div><b><i>static GstPadProbeReturn</i></b></div>
<div><b><i>cb_have_data (GstPad *pad,</i></b></div>
<div>
<b><i> GstPadProbeInfo *info,</i></b></div>
<div><b><i> gpointer user_data) {</i></b></div>
<div><b><i><br>
</i></b></div>
<div><b><i> GstBuffer *buffer;</i></b></div>
<div><b><i> char text_msg[128];</i></b></div>
<div><b><i><br>
</i></b></div>
<div><b><i> gint sz, sz2;</i></b></div>
<div><b><i> memset(text_msg, 0, sizeof(text_msg));</i></b></div>
<div><b><i> buffer = GST_PAD_PROBE_INFO_BUFFER (info);</i></b></div>
<div><b><i> sz = gst_buffer_get_size(buffer);</i></b></div>
<div><b><i> </i></b></div>
<div><b><i> sz2 = gst_buffer_extract(buffer, 0, text_msg, sz);</i></b></div>
<div><b><i> g_print ("\nBuffer Size is %d, read %d, data: %s",
sz, sz2, text_msg);</i></b></div>
<div><b><i> return GST_PAD_PROBE_OK;</i></b></div>
<div><b><i>}</i></b></div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
gstreamer-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>