2021年4月4日星期日

How to duplicate and delay a live stream in GStreamer?

I am trying to duplicate a live stream and delay one of the duplicates by some time duration. I am validating this by displaying the two streams side by side. Here is my pipeline:

rtspsrc protocols=tcp location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov    ! tee name=t  t. ! queue name=live_queue max-size-time=0 max-size-buffers=0 max-size-bytes=0     ! decodebin ! videoconvert     ! compositor name=mix          sink_0::alpha=1          sink_0::width=400          sink_0::height=400          sink_1::xpos=400          sink_1::width=400          sink_1::height=400          sink_1::alpha=1      ! videoconvert ! autovideosink      t. ! queue name=delayed_queue min-threshold-time=6000000000 max-size-time=0 max-size-buffers=0 max-size-bytes=0     ! decodebin ! videoconvert     ! mix.sink_1  

What I expect: The left stream will begin playing immediately, while on the right, nothing plays for 6 seconds and then starts playing the stream from the beginning. Afterward, both streams play side by side, with the left being 6 seconds ahead of the right.

What actually happens: Both streams are stopped for 6 seconds, then play in sync.

I read some forums posts that led me to suspect that all the streams are paused until all of the sinks are prerolled. So I attempted to use input-selector to run videotestsrc into the right sink, but now videotestsrc is just frozen on the right for 6 seconds before both streams start to play.

rtspsrc protocols=tcp location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov    ! tee name=t  t. ! queue name=live_queue max-size-time=0 max-size-buffers=0 max-size-bytes=0     ! decodebin ! videoconvert     ! compositor name=mix          sink_0::alpha=1          sink_0::width=400          sink_0::height=400          sink_1::xpos=400          sink_1::width=400          sink_1::height=400          sink_1::alpha=1      ! videoconvert ! autovideosink      input-selector name=inp    ! mix.sink_1    videotestsrc ! inp.    t. ! queue name=delayed_queue min-threshold-time=6000000000 max-size-time=0 max-size-buffers=0 max-size-bytes=0     ! decodebin ! videoconvert     ! inp.  

I had assumed tee would copy buffers to let each queue process them independently but it appears that both outputs of the tee are dependent on each other. What am I missing? How do I duplicate and delay a single source?

https://stackoverflow.com/questions/66947184/how-to-duplicate-and-delay-a-live-stream-in-gstreamer April 05, 2021 at 09:04AM

没有评论:

发表评论