Glitchless switching of videos from rtspsrc

Philipp B philippb.ontour at gmail.com
Mon Oct 10 10:45:13 UTC 2022


One solution (and IMO the cleanest in case you want to be flexible in
switching) is to use appsink/appsrc.

There was a thread lately discussing that:
https://lists.freedesktop.org/archives/gstreamer-devel/2022-July/080211.html
https://lists.freedesktop.org/archives/gstreamer-devel/2022-July/080221.html

the example mentioned there:
https://github.com/GStreamer/gst-plugins-base/blob/master/tests/examples/app/appsink-src.c

I just refactored my own project based on that...

I guess, you will basically have a "consumer pipeline" like
appsrc -> waylandsink

and you have many "producer pipes" like:

source -> filter -> appsink

Then you have your own worker thread in the middle, reading from GstAppSink
(https://gstreamer.freedesktop.org/documentation/applib/gstappsink.html?gi-language=c),
and either discarding Samples (in case you really need the fakesink
behaviour), or feeding them into GstAppsrc.

You might need some considerations about where to sync to a clock
(e.g. not sync yourself in the worker thread and also have the
consumer do a clocksync)

Am Mo., 10. Okt. 2022 um 11:16 Uhr schrieb Vladan Jovanovic via
gstreamer-devel <gstreamer-devel at lists.freedesktop.org>:
>
> Still struggling with this topic, so let me rephrase the question.
>
> Documentation and examples I've seen so far discuss gstreamer
> pipelines in form of:
> source -> filter -> sink
>
> So typically a single source going to one or multiple sinks.
> Are there any special considerations when one GstPipeline has separate
> parallel paths that don't interact? So pipeline that contains:
> source1 -> filter1 -> sink1
> source2 -> filter2 -> sink2
>
> I see in my tests that a pipeline with one path (source1 -> filter1 ->
> sink1) works fine. But when I add second path (source2 -> filter2 ->
> sink2), all elements in the second path switch state to PLAYING except
> sink2 (which is fakesink in my case), for which graph diagram
> continues to show "[-] -> [>]".
>
> best regards,
> Vladan
>
>
>
> On Thu, Sep 15, 2022 at 3:41 PM Vladan Jovanovic
> <vladan.jovanovic at gmail.com> wrote:
> >
> > Hi
> >
> > I'm looking to perform glitchless on-the-fly switching of video
> > streams that are coming from RTSP servers through rtspsrc. Switching
> > works fine, but I always end up with 2sec video "freeze" that I
> > assumed was due to rtspsrc buffering, but it seems more and more to me
> > is caused by some clock/synchronization issues due to rtspsrc sources.
> >
> > Below are links to a few pipeline graphs to demonstrate what I'm
> > trying to achieve:
> > - s1r.png: stream1 is running (playing).
> > - s1r_s2c.png: in preparing for switching videos, a second stream was
> > added to pipeline and playing (to fakesink).
> > - s1s_s2r.png: stream1 is disconnected from sink and stream2 is now
> > playing to waylandsink.
> >
> > When I start the pipeline directly as in s1r_s2c.png from the start, I
> > get choppy playback on the first stream that is shown, so it seems to
> > indicate some clocking issue (but it seems that the video switch works
> > well then).
> >
> > Any suggestions as to what could be the problem in either of the two approaches?
> >
> > Best regards,
> > Vladan
> >
> > - s1r.png: https://www.dropbox.com/s/iu0n4t7sxdsq2px/s1r.png?dl=0
> > - s1r_s2c.png: https://www.dropbox.com/s/vc1xu9cxghpwrks/s1r_s2c.png?dl=0
> > - s1s_s2r.png: https://www.dropbox.com/s/zwmk88zylnv9ym7/s1s_s2r.png?dl=0


More information about the gstreamer-devel mailing list