HLS

HTTP Live Streaming (HLS) is a modern streaming protocol designed to improve playback stability for listeners on mobile devices and Wi-Fi networks. In addition to traditional Icecast/SHOUTcast-style HTTP streaming, RSAS can convert and serve your stream as HLS, providing broadcasters with an easy upgrade path to adopt HLS audio streaming.

The main advantage of HLS audio streaming is that it provides a mechanism for players to seamlessly reconnect and download missed audio, so that a short loss of connectivity or bandwidth will not disrupt playback. A second key advantage is that by downloading audio in short bursts, HLS reduces power consumption and improves battery life on mobile devices by allowing cellular and Wi-Fi modems to sleep for more time during playback.

A limitation of HLS is that has increased latency during playback, which is mandated by the protocol specification. The exact latency will depend on the player, but is typically about 15-30 seconds.

HLS streaming with RSAS works with your existing MP3 or AAC encoder and is compatible with most of the major features in RSAS, including access logging, listener counts, and listener authentication. See Feature Compatibility below for more information.

HLS support is available for MP3 and AAC streams only.

Enabling HLS

To enable HLS in RSAS:

  1. Set the <hostname> in your RSAS configuration.

  2. Enable HLS globally (all mounts) or on individual mounts, following the example below:

    <icecast>
        <hostname>streams.example.com</hostname>
        <hls>
            <!-- Enable HLS for all MP3 and AAC mounts -->
            <enabled>1</enabled>
        </hls>
        <mount>
            <mount-name>/mount</mount-name>
            <username>source</username>
            <password>hackme</password>
            <hls>1</hls> <!-- Enable HLS for an individual mount -->
        </mount>    
    </icecast>
    

After enabling HLS, you will be able to listen to your stream in HLS at http://hostname/mount/hls.m3u8.

HLS Playback

HLS-enabled streams will be playable in an HLS-compatible player using the URL /mount/hls.m3u8.

HLS playback is tested with the following players:

  • VLC 3.0.17.4
  • HLS.js 1.2.4
  • Chrome on Android
  • Firefox on Android
  • Safari on iOS
  • Safari on macOS
  • Roku Streaming Stick+
  • exoPlayer (Android SDK)

Note that desktop Chrome, Edge, and Firefox do not natively play HLS, but their mobile equivalents do.

Heads up! Startup delay - When an encoder first starts broadcasting on a stream, HLS playback will not be possible until the first few HLS segments have been generated, which is typically after 12-36 seconds.

Feature Compatibility

Feature Supported with HLS Notes
Codec Compatibility MP3 and AAC Works with existing Icecast-compatible encoders.
Access Logging ✅ Yes Pseudo-sessions for Icecast log compatibility, playlist log, and segment files.
Relaying ✅ Yes Can convert traditional relays into HLS or relay an existing HLS stream from another RSAS server. See HLS Relay below.
Fallbacks ❌ No HLS provides a mechanism for client-side fallbacks, which should be used instead.
Listener Authentication Webhook ✅ Yes
Listener Removal Webhook ✅ Yes
Preroll and Postroll ad insertion ❌ No Planned for a future release.
Midroll ad insertion ❌ No Planned for a future release.

HLS Relays

RSAS supports two different modes of operation for HLS on relays.

In Segmentation Mode, RSAS relays a traditional HTTP stream and then converts it to HLS.

If a relayed stream is available in HLS on an upstream RSAS instance, then HLS Relay Mode will allow RSAS to mirror and cache the HLS playlist and segments from the upstream server. This mode is desirable when load balancing between multiple servers, so that each server presents the same consistent view of the HLS segments and playlist. (In this mode, RSAS essentially operates as a reverse caching proxy for HLS.) HLS Relay Mode is only compatible with upstream RSAS instances.

To summarize:

  • Segmentation Mode: RSAS will convert an existing relay to HLS, if HLS is enabled on the mount.
  • HLS Relay Mode: RSAS will mirror an upstream HLS stream from another RSAS server.

To configure HLS relay, see the example below:

<icecast>
    <hostname>streams.example.com</hostname>
    <mount>
        <mount-name>/relay</mount-name>
        <hls>1</hls>
    </mount>    
    <relay>
        <url>https://example.com/disco</url>
        <local-mount>/relay</local-mount>
    </relay>
</icecast>
<icecast>
    <hostname>streams.example.com</hostname>
    <mount>
        <mount-name>/relay</mount-name>
    </mount>
    <relay>
        <url>https://example.com/disco</url>
        <local-mount>/relay</local-mount>
        <hls-relay>1</hls-relay>
    </relay>
</icecast>

Logging

For compatibility with existing log analysers that are used to generate listener statistics, RSAS logs HLS listener sessions to the access.log as if they were regular HTTP listener sessions. These pseudo-sessions are logged in addition to the real HTTP requests by HLS listeners, which are the M3U8 playlist and segment files.

Technical Details

  • Supported audio format: AAC (ADTS) and MP3
  • Supported Media Segment Formats: RSAS will segment your stream into Packed Audio segments, with either MP3 framing or ADTS (AAC).
  • Metadata: ID3 metadata is embedded into each segment and will appear on players that support it.
  • Target duration and segment size: As of 1.0.0, RSAS has a target segment size of 96 KB per segment and the target duration is derived from this.
  • Playlists: The HLS M3U8 playlist will contain up to 5 segments and up to 10 past segments are kept on disk.

RSAS does not implement support for adaptive bitrate HLS streaming, as there is no practical benefit to doing so at the low bitrates that AAC/MP3 streams use.