hls

Enables MPEG-DASH support for live streaming in the NGINX RTMP module.

Syntaxhls on | off;
Defaultoff
Context
Arguments1

Description

The hls directive in the NGINX RTMP module is utilized to enable HTTP Live Streaming (HLS) for media content being streamed through NGINX. This directive facilitates the delivery of video content to clients using the HLS protocol, which is particularly beneficial for adaptive bitrate streaming. When the hls directive is set for an application, NGINX will segment the incoming media stream into fragments and make them available via an HLS playlist, allowing clients to play the stream smoothly by downloading these segments on-the-fly.

The HLS directive can be configured with different parameters, including the hls_fragment length specifying the duration of each segment and hls_playlist_length which determines the number of segments to include in the playlist. The resulting playlist, typically in M3U8 format, is served over HTTP and can be accessed by various media players that support HLS, providing broad compatibility across different devices and browsers. It is important to ensure that the underlying media format is supported and that the operational configuration accommodates the required file access permissions for the HLS segments and playlist.

In addition to basic HLS functionality, users should be aware of the implications of using this directive concerning resource management and streaming quality adjustments, as the settings might influence performance and bandwidth usage as well. This makes it essential to evaluate your streaming requirements and configure the HLS settings accordingly.

Config Example

application live {
    live on;
    hls on;
    hls_fragment 5s;
    hls_playlist_length 60s;
    hls_path /tmp/hls;
}

Ensure the hls_path directory has the correct permissions for writing files.

The hls directive should be set within the application block to function appropriately.

Misconfigured fragment lengths can lead to excessive resource usage or performance degradation.

← Back to all directives