Combining live streams

Questions involving a Windows version of FFmpeg.
Post Reply
Posts: 1
Joined: Fri Oct 18, 2019 1:45 pm

Combining live streams

Post by JasonXtreme » Fri Oct 18, 2019 1:52 pm

Hello everyone,

I am trying to find a way to combine several unstable live streams into one output. The streams are broadcasted via rtp_mpegts on several ports. What I've attempted is here:

ffmpeg -i rtp:// -i rtp:// -filter_complex "nullsrc=size=1280x720[base];[0:v]scale=640x380[vid1];[1:v]scale=640x380[vid2];[base][vid1]overlay[tmp1];[tmp1][vid2]overlay=x=640[output]" -map "[output]" -an -f mpegts udp://

What I do here is capture two streams and combine them on a nullsrc canvas. This works fine, as does using hstack and vstack for the same purpose. The problem is, not all of the streams are available all the time, some drop in and out. If a stream on port 1003 is unavailable at startup, per-se, ffmpeg awaits an initial connection until the stream is available. In other words, my udp broadcast only starts once all the streams have appeared in some point in time since I ran the command.

The question: is there some way to not wait for all streams and only display the ones available, the others remaining black or at the last frame meanwhile?

Best regards,

Posts: 255
Joined: Mon Feb 24, 2014 1:46 pm

Re: Combining live streams

Post by pandy » Tue Oct 22, 2019 4:22 pm

i have this idea (not tested)
but firstly: not sure how fast is null source, perhaps using picture and repeating picture in loop will be faster

try to re-arange signal flow - use two independent null sources, overlay on top of each null source your rtp source, combine both - as such there will be always video even if rtp source is not present so process should progress smoothly
I believe there are option to loop last frame in case of source ending prematurely - please check:

overlay filter should support it accordingly to documentation:

Post Reply