buffer probe data out of sync for subtitle text pad
Dece Bel
decebel at gmail.com
Tue Nov 12 04:36:18 PST 2013
I am trying to read subtitle from a video and want to record the timestamp
of the subtitled text in the gstreamer pipeline.
One approach that I have been trying is with the getting the action signal
on playbin for "get-text-pad"
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.
However, I notice that the subtitle on the final rendered video and the one
dumped from the probe callback are out of sync.
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.
Gracias
Dece
below is some relevant stripped code that uses the playbin element (using
gstreamer 1.0)
main() {
// creating the playbin element and setting flags to also play sub-titles
...
...
..
...
g_signal_emit_by_name (data->playbin, "get-text-pad", 0, &txt_pad);
if(txt_pad) {
printf("\nwe have a text pad");
*c**a_pad_data(txt_pad);*
}
}
///////////////////////////////////////
// When text pad is added, the below function will attach a probe
*void cb_pad_added(GstPad* pd) {*
* gchar *name;*
* GstCaps *caps = NULL;*
* name = gst_pad_get_name (pd);*
* g_print ("\nA new pad %s was created\n", name);*
* g_free (name);*
* gst_pad_add_probe (pd, GST_PAD_PROBE_TYPE_BUFFER, (GstPadProbeCallback)
cb_have_data, NULL, NULL);*
* gst_object_unref (pd);*
*}*
///////////////////////////////////////////////
// probe call back. Read the buffer an size and then print the buffer text
to screen.
*static GstPadProbeReturn*
*cb_have_data (GstPad *pad,*
* GstPadProbeInfo *info,*
* gpointer user_data) {*
* GstBuffer *buffer;*
* char text_msg[128];*
* gint sz, sz2;*
* memset(text_msg, 0, sizeof(text_msg));*
* buffer = GST_PAD_PROBE_INFO_BUFFER (info);*
* sz = gst_buffer_get_size(buffer);*
* sz2 = gst_buffer_extract(buffer, 0, text_msg, sz);*
* g_print ("\nBuffer Size is %d, read %d, data: %s", sz, sz2, text_msg);*
* return GST_PAD_PROBE_OK;*
*}*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131112/9268a936/attachment.html>
More information about the gstreamer-devel
mailing list