Issue seeking with appsrc
Matt Zawojski
matt.zawojski at exacom.com
Thu Apr 16 07:55:25 PDT 2015
Hi everyone,
I am using the Windows build of Gstreamer 1.4.5 to add media player capabilities to an application. I am using an appsrc in my pipeline to take in audio data from my application. I am using the appsrc in push mode with the "need-data", "enough-data" and "seek-data" signals.
The issue I am currently experiencing happens when the pipeline is playing and I try to seek to a certain time. When the seek completes and playback resumes, the pipeline will be playing audio from several seconds past the timestamp that I told the pipeline to seek to.
I am using the following call to initiate the seek on the pipeline:
gboolean seek_result = gst_element_seek(m_Pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, gst_util_uint64_scale_int(time, GST_SECOND, FILETIME_SECOND), GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
After this I see the following happen:
The appsrc emits the "seek-data" signal and triggers my callback.
The pipeline goes to the PAUSED state.
I see a "reset-time" message posted to the bus.
The appsrc emits the "need-data" signal and triggers my callback.
Once the "need-data" callback has been triggered I begin pushing data in from the new time that I tried to seek to.
I am pushing the data in 1 second chunks as that is how I receive it in my application.
After pushing in about 8 seconds worth of data I see an "async-done" message posted to the bus.
The pipeline then goes to the PLAYING state and I can hear audio being played back.
The problem is that when playback resumes the audio that is being played starts from that last 8th second that was pushed in. However, the playback time reported back to me by :
gst_element_query_position(m_Pipeline, fmt, ¤t);
shows the timestamp that I tried to seek to.
For example, to put some numbers with it. I am playing a file and at the 4 second mark I tell it to seek ahead by 5 seconds to the 9 second mark. The above series of events happen and I can see the audio chunks for the 9, 10, 11, 12, 13, 14, 15 and 16 second marks being pushed into the appsrc. When the pipeline goes back to the playing state, it reports that it is playing back from the 9 second mark, but I am hearing the audio from the 16 second mark.
Thinking that perhaps the data is somehow being discarded while the pipeline is in the middle of seeking, I have tried holding off on pushing data to the appsrc until after I receive the "async-done" message on the bus, but if I do not push any data to the appsrc I never receive that message and never enter a PLAYING state. (Which I suppose makes sense since it has no data to play.)
For the record my pipeline looks like the following:
A bin containing (appsrc ! decodebin ! queue) ! audiomixer ! audioconvert ! audioresample ! autoaudiosink
The purpose of the bin containing the (appsrc ! decodebin ! queue) is so that if I have multiple audio channels I can create several of these bins and input them into the audiomixer. However, for the purposes of debugging this seeking issue I am only using a single audio source and therefore a single bin.
If anyone can provide any insight into why I am seeing the behavior that I am it would be greatly appreciated.
Thank you,
Matt Zawojski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150416/0096a583/attachment-0001.html>
More information about the gstreamer-devel
mailing list