dynamically replacing elements in a playing gstreamer pipeline

marcin at saepia.net marcin at saepia.net
Sun Sep 2 04:49:42 PDT 2012


Hi Olivier,

I found your answer to the post on GStreamer mailing list.

Could you write something more about sending FLUSH_STOP?

I encounter a similar problem - I have video player and I dynamically
reconnect source to achieve seamless playback. I encounter strange A/V
sync problems, and if I understand logs correctly, they are related to
timestamping issues. I replace whole chain of source -> demuxer ->
audio/video parsers, and then connect them to audio/video decoders ->
playsink.

I've tried to send FLUSH_STOP to audio/video decoders while
reconnecting the source but it causes them to stop working.

Is there any source of information for such issues? Standard docs does
not provide any use cases, only theoretical description.

I will appreciate your help.

PS. I've noticed also that even the simplest pipeline with playbin2
dynamically switching URI on about-to-finish got the same problems.

m.


2012/8/24 Olivier Crête <olivier.crete at collabora.com>:
> Hi,
>
> On Fri, 2012-08-24 at 10:45 -0700, markymark wrote:
>> souphttpsrc location="http://localhost/local.ts" ! mpegtsdemux name=d !
>> queue ! mpeg2dec ! xvimagesink d. ! queue ! a52dec ! pulsesink
>>
>> During the middle of playback (i.e. GST_STATE_PLAYING is the pipeline state
>> and the user is happily watching video), I need to remove souphttpsrc from
>> the pipeline and create a new souphttpsrc, or even a new neonhttpsource, and
>> then immediately add that back into the pipeline and continue playback of
>> the same uri source stream at the same time position where playback was
>> before we performed this operation. The user might see a small delay and
>> that is fine.
>>
>> We've barely figured out how to remove and replace the source, and we need
>> more understanding. Here's our best attempt thus far:
>>
>> gst_element_unlink(source, demuxer);
>> gst_element_set_state(source, GST_STATE_NULL);
>> gst_bin_remove(GST_BIN(pipeline), source);
>> source = gst_element_factory_make("souphttpsrc", "src");
>> g_object_set(G_OBJECT(source), "location", url, NULL);
>> gst_bin_add(GST_BIN(pipeline), source);
>> gst_element_link(source, demuxer);
>> gst_element_sync_state_with_parent(source);
>>
>> This doesn't work perfectly because the source is playing back from the
>> beginning and the rest of the pipeline is waiting for the correct
>> timestamped buffers (I assume) because after several seconds, playback picks
>> back up. I tried seeking the source in multiple ways but nothing has worked.
>>
>> I need to know the correct way to do this. It would be nice to know a
>> general technique, if one exists, as well, in case we wanted to dynamically
>> replace the decoder or some other element.
>
> This is more or less the correct way, yes.
> In 0.10, you need to do one further trick for the timestamps problems:
> After removing the old source, but before linking the new source, send a
> FLUSH_STOP event down the demuxer., this should reset the timestamps,
> etc.
>
> --
> Olivier Crête
> olivier.crete at collabora.com
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>


More information about the gstreamer-devel mailing list