hls_base_url
The `hls_base_url` directive sets the base URL for HLS (HTTP Live Streaming) segments generated by the NGINX RTMP module.
Description
The hls_base_url directive is primarily used in the context of HTTP Live Streaming (HLS) to specify the base URL from which HLS clients can fetch the media segments. By configuring this directive, server admins can control the location of the HLS segments relative to the application that publishes the video stream. When a client requests the HLS playlist (M3U8 file), it uses this base URL to construct the full URLs for accessing the media segments, which are typically served as .ts files.
A typical scenario for using hls_base_url is when the segments are stored or accessible at a different path than the one where the playlist is served. This allows for customized access points, such as a CDN or external storage, effectively decoupling the stream management from the delivery location. For example, if segments are stored on a different server, setting an appropriate hls_base_url would ensure that clients can still access the stream without needing to know the underlying file structure.
Parameters include a single argument that specifies the base URL, which should end with a slash. Depending on the hosting setup (whether segments are served locally or from a remote server), the URL can be set to reflect the right access point. Misconfiguration can lead to clients being unable to access the media segments if the paths do not resolve correctly. It’s also worth noting that proper URL encoding may be required if the URL contains special characters, ensuring that HLS clients can correctly interpret it.
Config Example
application myapp {
live on;
hls on;
hls_base_url http://mycdn.domain.com/hls/;
}Ensure the base URL ends with a trailing slash, or clients may fail to resolve segment URLs correctly.
Using an incorrect URL can lead to 404 errors when clients attempt to access .ts segments.
Double-check for URL encoding issues if the base URL contains special characters.