<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>