Skip to content

Live streaming

Flussonic Media Server can retransmit streaming video into multiple output formats on the fly with just-in-time packaging. For example, you can ingest an MPEG-TS stream, deliver it simultaneously to thousands of subscribers in DASH or HLS format, and at the same time publish the stream via RTMP on YouTube.

Flussonic Media Server supports three types of streams:

  • static — streams that are being broadcasted all the time.
  • ondemand — streams that are requested by users (on-demand).
  • live — user-published streams. See Publishing for details.

Contents:

Static streams

Static streams are launched upon a start of the server. Flussonic continuously monitors static streams.

If for some reason (transcoder went off, antenna broke down) a data source goes down, Flussonic Media Server will constantly keep trying to reconnect to the stream until success or shutdown.

Usually, IPTV channels or IP camera feeds are being configured as a static stream.

Flussonic Media Server supports many types of data sources, which must be configured with URLs.

The format of a stream definition in the /etc/flussonic/flussonic.conf file is:

stream example_stream {
  input udp://239.0.0.1:1234;
}

In this example:

  • example is the name that must be used to request the stream from Flussonic Media Server.
  • udp://239.0.0.1:1234 is the data source URL.

Important. The name of a stream should contain only Latin characters, digits, dots (.), dashes (-), and underscores (_). If the name contains any other characters, DVR and live streams might work incorrectly.

To add a stream via the web interface:

Go to the Media tab and click Add next to Streams.

Flussonic add stream

Then enter the name of the stream and the data source URL. Click Create and Flussonic will add the stream to the list.

Note. By default, new streams are Static. To change the stream type to On demand, click Static next to the stream name.

After the stream is added, you can go to the stream settings page and check the ingest status:

streams-ready

On-demand streams

If the stream is not needed all the time but only upon user's request, you can configure Flussonic Media Server to turn it off when it is not being used and turn it back on when it is requested.

To specify this kind of behavior, change the stream type to ondemand:

ondemand ipcam {
  input rtsp://localhost:554/source;
}

Flussonic ondemand

Warning

If Media Server ingests the ondemand source stream using RTMP, RTSP, or HTTP MPEG-TS protocols, there will be some complications with outputting HLS streams. This is because those streaming protocols require 10-30 second buffering. The player will not start playback until its buffer is filled, so the first user who initiated playback would need to wait until the system is ready. The only data source that doesn't have this problem is another Flussonic server with HLS protocol. Flussonic Media Server uses its own extensions that allows for instant playback on iPhone.

You can specify the stream's lifetime after a client has disconnected:

ondemand ipcam1 {
  input rtsp://localhost:554/source;
  retry_limit 10;
  clients_timeout 20;
}

The config line above has the following meaning: make no more than 10 attempts to reconnect with a data source if the connection is lost; when the last client leaves, run keep fetching the stream for no longer than 20 seconds.

Streams playback

How to playback streams, learn in Video output.

Stream screenshots in JPEG

Flussonic Media Server can generate JPEG thumbnails of a streaming video. To use this feature, add the thumbnails option in the stream settings:

stream example {
  input fake://fake;
  thumbnails;
}

Alternatively, to reduce CPU usage, you can specify an URL where Flussonic Media Server can get JPEG thumbnails. Many IP cameras have a special URL with screenshots:

stream example {
  input rtsp://localhost:554/source;
  thumbnails url=http://examplehost:5000/snapshot;
}

You can find the screenshot URL in the documentation for you camera model.

Flussonic JPEG thumbnails

The latest screenshot of a stream is available at http://flussonic:80/example/preview.jpg

An MJPEG screenshot of a stream is available at http://flussonic:80/example/preview.mjpeg

See also:

Substituting a stream with a file

If a stream becomes unavailable, Flussonic can substitute it with a fallback video from a video file that you specify using backup <VOD location>. This works for any live streams, including published ones.

stream example {
  input tshttp://10.0.4.5:9000/channel/5;
  backup vod/bunny.mp4;
}

You need to specify the path to the fallback file relative to the VOD-location, for example vod/backup.mp4, where vod is the unique name of our VOD location. Do not use absolute paths for video files.

Note

If the original stream has no audio (for example, a stream from an IP camera), the substitute file must have no audio as well.

By default, the fallback file is not recorded to the archive and is not transcoded. However, you can configure it.

To learn more about different ways of using files as stream failover sources, see the section Source Failover.

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

Unlike source switching with the source input 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 input file://<VOD location> is always written to DVR.

When use backup instead of input 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.

Wildcards

Sometimes names of streams on a remote server are not known in advance, so you want to dynamically rewrite the source (input) URL based on the requested stream name. To do that, use the following template feature:

template nsk {
  prefix nsk;
  input rtsp://streamer:555/%s;
}
template ams {
  prefix ams;
  input hls://streamer:8081/%s/index.m3u8;
}

The template directive uses the %s pattern to replace a substring in the input URL. It means that the substring that succeeds the prefix specified in the template's prefix replaces the %s pattern in the source URL, i. e. a substring that goes prior to the prefix, including the prefix itself, is omitted and what is left applies to the input URL. Flussonic receives a request for one URL but requests a different URL from the streamer without a redirect.

For instance, if a client requests a stream over the following URL: http://FLUSSONIC-IP/ams/ort/index.m3u8, Flussonic delivers the stream from the source URL: hls://streamer:8081/ort/index.m3u8, so the http://FLUSSONIC-IP/ams/ substring is removed, and the ort/index.m3u8 substring is used in the source URL input.

How do I use it?

For instance, to broadcast the channels to various areas from different servers, i. e. one server for every area. It provides you with a quick and efficient way of content delivery to the viewer.

Recording video streams (DVR)

Flussonic Media Server has a built-in state-of-the-art stream recording system.

The stream archiver can record video, provide access to a particular video interval, export parts of the archive as MP4 files, clean up old archive files, and maintain ample free space on the storage disk.

To turn on the archiver, specify the dvr option in a stream settings:

stream foxlive {
  input tshttp://trancoder-5:9000/;
  dvr /storage 90% 5d;
}

For details, see archive management.

Time zone adjustment (Timeshift)

Flussonic Media Server can play the archive record of a stream with a fixed delay.

Warning

Flussonic Media Server maintains the exact delay, so if for some reason the archive has gaps, end users will be getting no video for the duration of a gap.

The timeshift feature has its own data source schema — timeshift://:

stream channel {
  input fake://fake;
  dvr /storage 90% 5d;
}
stream channel-2h {
  input timeshift://channel/7200;
}

The delay is specified in seconds.

Flussonic timeshift

Stream delivery over UDP multicast

Flussonic Media Server can rebroadcast a stream from a data source over the local network.

Flussonic Media Server demonstrates next-to-ideal jitter values when streaming multicast UDP over the network.

stream example_stream {
  input tshttp://localhost:80/origin/mpegts;
  push udp://239.0.4.4:1234;
}

Stream settings for IP surveillance cameras

It is possible to configure Flussonic Media Server to request a stream from camera via UDP only. This might be useful when dealing with cameras that have issues with streaming over TCP.

stream cam1 {
  input rtsp://localhost:553/bunny.mp4;
  rtp udp;
}

Warning

The HEVC (H.265) video codec is supported only in Chrome (version 107 and higher), Microsoft Edge (version 16 and higher), and Safari (version 11 and higher) on desktops, and in Chrome (version 107 and higher) and Safari for iOS (version 11.0 and higher) on mobile devices. All other browsers cannot play H.265 video streams. More on this in Playing H265.

If there is no need to retrieve audio from a camera (for example if the audio is encoded in G.726), you can configure Flussonic Media Server to ingest only one track. The number of the track must be specified in the stream settings:

stream cam1 {
  input rtsp://localhost:554/origin tracks=1;
}

In order to transcode an audio stream from G.711a or G.711u into the AAC codec, use the protocol rtsp2:

stream cam1 {
  input rtsp2://localhost:554/origin;
}

Turning on audio-only HLS

When approving apps for publishing in AppStore, Apple may require the stream to have an audio-only version. To satisfy this requirement, add add_audio_only directive to the configuration:

stream cam1 {
  input fake://fake;
  add_audio_only;
}

With this directive, if the stream contains both audio and video, Flussonic will generate multibitrate playlist with two profiles — one with audio only and another with audio and video tracks.

Capturing stream from another Flussonic Media Server

The details of transferring video between Flussonic Media Server servers are discussed in Flussonic video stream clusterization.

DRM in live streaming

The details are discussed in the DRM article.

Silence detection

Flussonic can detect low sound level (no sound) in sources of input streams and notify about it. See Silence detection for details.