Flussonic Media Server Documentation

Source Failover

For various reasons, a video source may temporarily disappear or even become offline. To avoid a situation where consumers do not have any video, it is necessary to prepare alternative stream sources in order to broadcast them in the absence of the main source until it is restored. Flussonic provides seamles sautomatic source switching.

On this page:

Redundant sources

To maximize service uptime for your subscribers, you can use the Source Failover feature. By specifying multiple sources, you instruct Flussonic to automatically failover to the secondary data sources if the primary source becomes unavailable. Flussonic supports using video streams and files as secondary sources.

Source switching happens when the stream becomes disconnected, or when there are no incoming frames from the source for more than 60 seconds (and 180 seconds for hls://, playlist://, timeshift:// sources).

How source failover works

After Flussonic Media Server switches to a secondary source, it will periodically check if the first source is up. When the first source comes back online, Flussonic will fall back to it.

Note. Flussonic waits for a keyframe from a reappeared source and only then switches to that source. In this way, we provide seamless switching without delays. This is essential for video with a large GOP, for example, video via HLS — Flussonic provides high-quality switching even for such video.

Example

The stream example_stream has two sources. If no frames come from the first source for 60 seconds, then Flussonic will change to the second source.

stream example_stream {
  url udp://239.0.0.1:1234 source_timeout=20;
  url tshttp://localhost:8080/clock2/mpegts;
}
stream clock1 {
 url fake://fake;
 push udp://239.0.0.1:1234 multicast_loop;
}
stream clock2 {
 url fake://fake;
}

Failover conditions

Flussonic monitors only the time since last frame was received from the source, and switches to another source if there were no incoming frames received within a certain timeframe.

Flussonic doesn't monitor conditions like video or audio loss or increased volume of MPEG-TS CC errors.

Options for configuring source failover

source_timeout

The source_timeout option specifies the period of time, in seconds, for which Flussonic will wait for new frames until it considers the source as lost. The default timeout is 60 seconds (180 seconds for hls://, playlist://, timeshift:// sources).

You can specify source_timeout for both the entire stream and for each of the video sources. The source_timeout option of a video source has priority over the source_timeout option of its parent stream. Example:

stream backup_timeout { 
    url publish:// source_timeout=10;
    url fake://fake source_timeout=5;
    source_timeout 20;
}

If you think that switching occurs too often, you can increase the source_timeout so that there are no "jumps" from one source to another. On the other hand, in order not to wait for a long time until Flussonic switches to another source, you can reduce the timeout.

The timeout is not taken into account when you switch sources manually.

priority

Sources can be assigned priority values. By default, the first source in the list has the highest priority and the last source in the list has the lowest priority. If priority is not specified for some sources, then the default order is applied.

Flussonic checks priorities only after it determines all sources that are active.

If the priority of an unavailable (offline) source is equal to the priority of the currently played source, then Flussonic will not try to fall back to the source that has become unavailable.

stream example_stream {
  url tshttp://10.0.4.5:9000/channel/5 priority=1 source_timeout=60;
  url tshttp://10.2.4.5:9000/channel/5 priority=2 source_timeout=30;
}

The rules of switching sources according to their priority and state (whether a source is available or not) apply to published sources as well as any other ones.

Changing sources manually

Flussonic supports manual source switching.

If you disable a source manually (in the UI click Disable), then Flussonic will instantly switch to another source, and source_timeout is ignored in this case.

To change the source of a stream manually, without waiting for the timeout:

  • In the stream settings, change the order of sources. Use this if priority was not specified. For example, move the second source up, and Flussonic will switch to it.
  • In the stream settings, edit the priority of sources For example, set priority=2 instead of priority=1 and priority=2 instead of priority=1, and Flussonic will switch to the source with the highest priority.
  • Enable another source via the API.

One more way is to disable a source. If you disable a source manually , then Flussonic will instantly switch to another source, and source_timeout is not taken into account.

To disable a source:

In the UI click the stream, go to Input and click Disable next to the source from which you want to switch to another one.

Recording to an archive

If a DVR location is configured, Flussonic will start archiving video from the active source.

The system makes no distinction between live sources and local video files. If Flussonic has switched to a file source, the contents of this file will be written to archive.

It is possible to use a static video as a failover data source.

stream example_stream {
  url udp://239.1.2.3:1234;
  url file://vod/backup.mp4;
  dvr /storage;
}

In the example above, the fallback video file would be written to the DVR archive. To avoid writing a fallback video file to the archive when all of the sources are down, you should use the backup directive instead of a static video URL. See also further on this page.

Using a file as a redundant source

You can use static video (video files) as a failover data source.

Files can be specified in two different ways, each leading to a certain behavior of Flussonic at source failover.

  • Using the url file:// schema to list a file as a one of the sources:

    stream example_stream {
      url tshttp://10.0.4.5:9000/channel/5;
      url file://vod/backup.mp4;
    }
    

    Flussonic supports MP4 and MPEG-TS files (.ts).

    See also:

  • Setting a file as a failover data source for the main stream, by using the backup option. Flussonic shows this file without actually switching sources. This is useful in certain cases. Learn more

    stream example_stream {
      url tshttp://10.0.4.5:9000/channel/5;
      backup vod/backup.mp4;
    }
    

How 'backup' is different from 'url file://'

Unlike source switching with the source url file://<VOD location>, when a fallback file is used, Flussonic technically does not switch to another source. This is especially useful for published streams to prevent numerous closings of a socket with a publishing client.

The fallback file specified in backup <VOD location> is not transcoded and not written to DVR, unless you configure otherwise. The file source url file://<VOD location> is always written to DVR.

When use backup instead of url file://:

  • In case of poor connection with the client that publishes video, Flussonic continues to receive frames without interrupting the connection with the client. This allows the client to continue the publishing session without having to start it over each time the source was switched. When the published stream disappears, viewers see the fallback file and understand that the broadcast is not over yet.

  • When all sources are unstable and Flussonic switches between them too often, it is better to show a fallback file. If you use a file as one of the sources, viewers will see any video only after timeouts pass for each of the troubled sources.

  • If you write the main stream to DVR and do not want to write the file too in order to prevent the file from appearing in the archived video.

  • Using options like timeout for the main stream and the fallback file, you can manage which source to show during a publication session.