Skip to main content

Introduction

Low-latency HLS (LL-HLS) playback feature has been introduced in Ant Media Server version 2.11 and above. It allows you to stream with minimal latency (around 2-5 seconds), making it ideal for near real-time streaming applications.

What is LL-HLS?

Low Latency HLS (LL-HLS) is a streaming protocol designed to minimize latency in live streaming. Traditional HLS can have latency ranging from 20-30 seconds, while LL-HLS reduces this to around 2-5 seconds.

LL-HLS achieves this by using smaller video segments (called "parts") that allow the video player to start playback before an entire segment is completed.

Key Differences: HLS vs. LL-HLS

Standard HLSLow Latency HLS (LL-HLS)
Latency: ~20-30 secsLatency: ~2-5 secs
Segment-basedPart-based (smaller chunks)
Larger file sizesSmaller, more frequent parts

How to Enable LL-HLS in Ant Media Server

LL-HLS is a paid plugin offered by the Ant Media Server. So before using LL-HLS, you need to purchase and install the plugin on your Ant Media Server. For more information about plugin structure in Ant Media Server, take a look at the Ant Media Server Plugins

Step 1: Purchase and Install the LL-HLS Plugin

  1. Purchase the Plugin
  1. Install the Plugin
  • Upload/copy the plugin file to your instance running the Ant Media Server.
  • Run the following commands to install:
unzip low-latency-hls-plugin.zip
cd low-latency-hls-plugin
sudo ./install_low-latency-hls-plugin.sh
sudo service antmedia restart

Step 2: Publish a Stream

Ant Media Server provides LL-HLS endpoints for all ingested streams. You can check the publish live streams section to learn how to publish streams using different protocols with Ant Media Server. For this example, let's publish with WebRTC.

  1. Access the WebRTC Publish Page Open the following URL in your browser:

https://yourserver.com:5443/live/?streamId=stream1

  • Replace yourserver.com with your Ant Media server's domain.
  • You can use stream1 or any custom stream ID.
  1. Start Publishing the Stream

Click the Start Publishing button on the page.

Screenshot 2024-09-23 130823

Step 3: Play the Stream with LL-HLS

  1. Open a Video Player

Use a player that supports LL-HLS, like THEOPlayer, Safari, or others.

  1. Enter the LL-HLS URL

In the player, enter the following URL to play the stream:

https://yourserver.com:5443/live/streams/ll-hls/stream1/stream1__master.m3u8

Screenshot 2024-09-23 131202

  • Ensure two underscores (__) exist between the stream ID and master.m3u8.
  • The URL pattern: https://{YOUR_SERVER}:{PORT}/{APP}/streams/ll-hls/{STREAM_ID}/{STREAM_ID}__master.m3u8

Customizing LL-HLS

You can fine-tune LL-HLS settings in the Advanced section of the application settings of the Ant Media Server web panel. These settings allow you to adjust the behavior of LL-HLS to meet specific needs, like controlling segment durations or playlist updates.

Customization Parameters

  1. partTargetDurationMs

The maximum duration of partial segments in milliseconds (recommended: 1002 ms).

"partTargetDurationMs": 1002
  1. targetDuration

Target duration for media files (default: 10 seconds). Lower values provide faster response times but increase server load.

"targetDuration": 10
  1. slidingWindowEntries

Number of media segments retained in the playlist (default: 5). Increasing this value can improve stability but may consume more resources.

"slidingWindowEntries": 5
  1. deleteFiles

Determines whether old media files are deleted after being removed from the playlist (default: true). It is set to false if you want to keep old segments.

"deleteFiles": true
  1. program

Indicates if a VOD-style program is being captured, which means all segments are retained in the playlist (default: false).

"program": false
  1. addDateTime

Controls whether the date and time are added to media file names (default: true)

"addDateTime": true
  1. receiveDataTimeout

Timeout duration in seconds after which the segmenter pauses if no data is received (default: 0, meaning no timeout).

"receiveDataTimeout": 0
  1. exitOnReceiveDataTimeout

If set to true, the segmenter will exit when the receiveDataTimeout is reached. Otherwise, it will just pause (default: false).

"exitOnReceiveDataTimeout": false
  1. fileCompleteCommand

Command executed when a media or index file is completed. You can use %P for the full path and %F for the file name.

"fileCompleteCommand": "/path/to/script %P %F"
  1. fileDeleteCommand

Command executed when a media or index file is deleted after being removed from the playlist.

"fileDeleteCommand": "/path/to/delete_script %P %F"
  1. quiet

If set to true, only error messages will be displayed in the logs (default: false).

"quiet": false

Applying Customization

To apply the above settings, add them under the customSettings section in the Ant Media Server application advanced settings:

"customSettings": {
"plugin.ll-hls": {
"partTargetDurationMs": 1002,
"targetDuration": 10,
"slidingWindowEntries": 5,
"deleteFiles": true,
"program": false,
"addDateTime": true,
"receiveDataTimeout": 0,
"exitOnReceiveDataTimeout": false,
"fileCompleteCommand": "/path/to/script %P %F",
"fileDeleteCommand": "/path/to/delete_script %P %F",
"quiet": false
}
}
  • You can easily enable Low-Latency HLS (LL-HLS) on Ant Media Server with this guide. For a more detailed explanation of the LL-HLS and its related properties, check the Low-latency HLS blogpost.