hls_max_audio_delay
The `hls_max_audio_delay` directive sets the maximum allowed audio delay when streaming HLS content using the NGINX RTMP module.
Description
The hls_max_audio_delay directive is used to control the maximum allowable delay for audio streams in HTTP Live Streaming (HLS) scenarios. This directive helps mitigate audio sync issues by ensuring that audio data does not exceed a certain delay in relation to the video stream. When this maximum delay is reached, the server will adjust the stream to align audio more closely with the video, which is particularly important in live broadcasting contexts where latency is a critical factor.
The parameter for this directive is a numeric value representing the delay in milliseconds. Setting an appropriate hls_max_audio_delay value involves balancing the need for audio quality with the requirement for low latency. A value that is too low may result in interrupted audio or stuttering playback if the server can't keep up. Conversely, a value that is too high can lead to a noticeable lag between audio and video, detracting from the viewing experience.
This directive is particularly relevant in live streaming situations where real-time interaction is essential, such as live sports or concerts. By configuring this directive, users can enhance the user experience by reducing the likelihood of audio and video being out of sync, which can detract from the overall quality of the broadcast.
Config Example
application live {
live on;
hls on;
hls_max_audio_delay 200;
}Be mindful of setting the delay too low, as it may result in audio disruptions during high-load scenarios.
Test various delays to find the best balance for your specific streaming environment; a one-size-fits-all value may not yield optimal results.