[FFmpeg-user] Switching live streams without interruption?

Luke Davis l1 at newanswertech.com
Sat Oct 25 22:41:41 CEST 2014


On Sat, 25 Oct 2014, Felix E. Klee wrote:

> Thanks for the links, but: *Can't I do that from ffmpeg?*
>
> Thing is, I want to script switching of streams, and I want to have
> the option to later use another server for broadcasting.

Unless I am mistaken (I have only done this with audio, icecast, etc.), your 
problem is that any break in the stream will disconnect clients, or at least 
inconvenience them rather a bit.

Thus, the solution has to be server side, in which case you need a 
fallback stream to fill the gaps.  Even if only used briefly, if your server 
supports it, you fall back to a holding pattern stream (company logo looped or 
something), and then stream in your new content from the script.  Even that will 
make discontinuities, and I have no idea if Wowza or anything else supports it.
Unless your server supports holding client connections open during a disconnect-reconnect cycle of the source client, which is what will happen here.

One possible ffmpeg-only solution comes to mind.  This is a bit out there.

Feed your ffmpeg source client from a segmented MpegTS stream.  In other words, 
feed it from HLS generated locally.

Ffmpeg instance one generates a segmented stream for five minutes, then exits.

Meanwhile, ffmpeg two (source client) takes that stream and sends it to 
Wowza/whatever  server.

When ffmpeg one stops, with maybe eight seconds left in the last segment 
(assuming ffmpeg two is keeping up, and 10 second segments):
Ffmpeg three starts, generating segments with numbering starting where ffmpeg 
one left off (you'll likely need to `tail` the .m3u8 file to figure out where to 
start).

I believe that ffmpeg two, which is taking the segments and compiling them to 
send as a stream to the server, will not know the difference between one origin 
stream and another, since their all just segments as far as it's concerned.

Not having tried this, my only worry at the moment is catch-up.  Every time 
you do this, the source client (ffmpeg two in the above plan) will get a little 
closer to falling off the end of your segments.

Good luck.

The entirety of this email is speculative, and could be punctured with a dull pin.

Luke



More information about the ffmpeg-user mailing list