April 9, 2017

Streams failover hot swap via Live Transcoder

Nimble Streamer Live Transcoder now supports hot swap capabilities for live streaming scenarios.

This covers use cases when there is some original (primary) stream active all the time and a substitute (secondary) stream to replace it on some occasions. Those include cases like emergency stream activation and an opposite one like streams failover which is described below.

During stream failover, the substitute stream is always active and once the original stream goes down, the data from substitute stream is taken. Once the original stream is online again, it replaces the substitute stream back.

This feature requires making the swap smoothly from viewers point of view, which means a player must not stop the playback. Nimble Streamer covers this properly.

The setup is similar to emergency stream hot swap with a few changes.

RTMP, RTSP and Icecast inputs can be used in the pipeline without changes. SRT, RIST, MPEG-TS over HTTP and HLS pull need to have instant inactivity disconnect enabled.

Pipeline overview

To make streams swap smoothly with no video or audio artifacts, the Live Transcoder needs to substitute the original content with new one. This can be done only during the decoding process where the encoded content is already "unfolded" but it hasn't yet been transformed by filters on further encoder. So the original stream cannot be passed through or just transmuxed.
The original stream which needs to be substituted, must always be decoded even if you encode it right after that without putting any filters on it. 
Second point is that original and substitution steams need to match in terms of viewer's perspective.
Both streams need to have equal video resolution and audio sample rate.

So you will need to prepare both original and substitute streams to make the swap properly.

Substitute stream setup

If your stream's source fails for some reason, you'll need to show something instead. Let's do it like you see on a TV - we'll show a tuning table with some simple audio. The table will be displayed from a static image while the sound will come from an MP4 file's audio track.

To prepare the stream you need to create transcoding scenario. Take a look at this sample one:

As you see from decoder block, the video track is created using an image file. The decoder settings would be as follows:

Then you need to scale it to the resolution of the original stream. So just create a scale filter with proper settings.

The audio can be taken from a file as well. The decoder is set like the following.

Audio should also be re-sampled to change the sample rate to the same value as in the original stream using "aformat" filter:

If two streams happen to have different audio sample rates, the sound will glitch at the moment of switching between them.

In addition to that, video and audio must be synchronized.

Set up sync mode for video and audio encoders

For more details on creating streams from files and syncing them, check this article.

Now the substitution stream is ready and you can use it in original stream.

Original stream setup

The original stream must have all input streams to be decoded. Even if you want the stream to be passed-through, you need to add a decoder and an encoder blocks.

In case you need some transcoding to be done, here's one typical example. Notice the decoding for audio streams. In normal use case they should have been passed through but here you see two sets of decoding and encoding with no filtering.

Now let's set up the hot swap itself.

Hot swap settings

Now go to transcoders main page and click on Hot swap settings button.

New page will have just a New hot swap setting button.

Click on it to see a dialog for defining streams.

Enter the original application and stream names, then Substitute application and stream names, and select Substitution type as Failover.

You must specify both original application and stream name to make it work as some streams may not be present at the start of the server and transcoder.

Notice that wildcard streams in transcoder will not work for this case.

Upon saving the setting, you will see it in the table and it will start working in a few seconds.

That's it. Now whenever the original stream becomes un-available, it will be replaced by the substitute stream. And once original stream is up again, its content will be transmitted.

Feel free to visit Live Transcoder webpage for other transcoding features description and contact us if you have any question.

Related documentation

No comments:

Post a Comment

If you face any specific issue or want to ask some question to our team,

This will give much faster and precise response.
Thank you.

Note: Only a member of this blog may post a comment.