hls_playlist_length
Sets the maximum length of the HLS playlist for streaming applications in the RTMP module.
Description
The hls_playlist_length directive in the NGINX RTMP module configures the maximum duration of the HLS playlist that is generated for live streams. This directive is particularly relevant for environments where live streaming with HLS (HTTP Live Streaming) is employed. It enables fine-tuning of how much content a client can fetch in the playlist. When a live stream is being broadcasted, a playlist is generated with a defined length, dictating how many fragments of the stream are included for viewers.
The argument for hls_playlist_length specifies the length in milliseconds. By explicitly setting this value, the server determines how many segments of the live stream to include within the .m3u8 playlist file it serves to clients. A shorter playlist length may lead to a more responsive user experience for live streaming, but it could also cause a loss of earlier parts of the stream that are discarded as new segments are being added. Conversely, a longer playlist can retain more of the stream history, beneficial for viewers connecting later in the broadcast.
In configurations where the dash feature is also used, this directive must be carefully aligned with the corresponding DASH settings to ensure compatibility and optimal performance. The value set may also impact how the playback buffer on the client side manages the stream data, potentially affecting playback continuity.
Config Example
rtmp {
server {
listen 1935;
application live {
live on;
hls on;
hls_playlist_length 60000; # 60 seconds
...
}
}
}Make sure that the playlist length is appropriate for your streaming audience; too short may lead to loss of stream history and too long may delay cache refresh on client devices.
Do not confuse this directive with other related directives such as dash_playlist_length, as they may require their own configurations.
Remember that changing the playlist length while a stream is live may not take effect until the next stream or restart. Avoid frequent changes to avoid confusion.