decodebin2
Tim-Philipp Müller
t.i.m at zen.co.uk
Fri Mar 9 02:27:03 PST 2012
On Fri, 2012-03-09 at 09:34 +0100, Steffen.Roeber at hella.com wrote:
> I'm usng a pipeline that contains a filesrc, a decodebin, an appsink
> and some other elements. What I want to get is the duration of the
> current element.
> For this I'm using
> GstQuery *frameDuration = gst_query_new_duration(GST_FORMAT_DEFAULT);
> gst_element_query(reinterpret_cast<GstElement *>(m_pipeline),
> frameDuration);
> sint64 temp = 0;
> gst_query_parse_duration(frameDuration, 0, &temp);
>
> I have two problems with this approach. First, this works only after I
> called
> GstBuffer *buffer = gst_app_sink_pull_buffer(m_appSink);
> which is very annoying.
> And the second problem is that it does not work at all if I change the
> filename of the filesrc:
> gst_element_set_state(reinterpret_cast<GstElement *>(m_pipeline),
> GST_STATE_NULL);
> setProperty(reinterpret_cast<GObject *>(aviSrc), "location",
> filename);
> ...
The duration should be available as soon as appsink (and all other
sinks) has queued a buffer internally and the pipeline is prerolled,
that is when you receive an ASYNC_DONE message on the bus (or a state
change message with new_state==PAUSED and message->src==pipeline).
There's no need to actually pull a buffer from appsink.
If you just want to read metadata, GstDiscoverer might also be of
interest.
As for changing filesrc - you should just set up a new filesrc +
decodebin2 (decodebin2 needs resetting as well) and remove the old
elements when no longer needed.
Cheers
-Tim
More information about the gstreamer-devel
mailing list