When live streaming in outdoor with weak network conditions, there are some devices to aggregate networks like MPTCP router. But packet loss in MPTCP, will cause the live streaming problem, like stream interruption.
So if publish multiple live streams to server, it's much robust than single stream. My question is: How to switch between streams, if some stream has problem, without reconnect for player?
For example, publish two streams:
streamA
rtmp://xxx/app/streamAstreamB
rtmp://xxx/app/streamB
Play the stream, whatever which stream is selected:
stream
rtmp://xxx/app/stream
If streamA is poor quality or interrupted, administrator could switch to streamB, and player still play stream without reconnection.
In addition, there is no need to refresh the playback end, stream will not interrupt, video content will not repeat or jump frame.
To support multiple streams fault tolerance, there are some solutions:
Client Solution
It's the most simple solution, for example, let's say publish two streams:
streamA
rtmp://xxx/app/streamAstreamB
rtmp://xxx/app/streamBPlayer get the playlist from your backend server:
streamA
rtmp://xxx/app/streamAstreamB
rtmp://xxx/app/streamBIf
serverA
is unavailable, user will switch tostreamB
. Highly recommend this solution, because it's simple and robust, and no change need to be made for the streaming system.Server solution: Multiple URLs
If publish multiple streams, each with its URL, like this:
streamA
rtmp://xxx/app/streamAstreamB
rtmp://xxx/app/streamBThe media server will
merge
these URLs to one URL, for switching automatically if stream is unavailable, to enable the player always use one URL to play the stream:stream
rtmp://xxx/app/streamFor SRS, this feature is named Alias for Stream, which is not supported right now(at 2022.01), but there is a workaround, use FFmpeg to covert
streamA
tostream
:If
streamA
is unavailable, administrator should switch tostreamB
by start a new FFmpeg cli, after killed the previous FFmpeg process:This solution is much simple, nothing need to be done for the streaming system and player, it should works perfect.
Server solution: One URL
If publish multiple streams with the same URL:
streamA
rtmp://xxx/app/streamstreamB
rtmp://xxx/app/streamIt requires the media server or cluster support this feature. SRS has no plan for this, because it's not simple enough than previous solutions.
However, some video cloud platforms already support this feature, like Tencent Cloud Streaming Services.
Other Issues
If switch between streams, there always be some issues, like content repeating, or lagging. Think about the first solution, player play a playlist with two streams, if switch to another one, it's impossible to play the same timestamp because it's live streaming.
You could try HLS, to switch between streams, and play from the next ts file of another stream, but I'm not sure whether it works.
I think when stream switching, it means some big problems like network fail or device corrupts, it seems OK unless the stream is unavailable.