HLS Utils is a lightweight HTTP Live Streaming (HLS) management server that provides functionalities to manage streams, authenticate clients, and serve playlists generated by tools like ffmpeg with variant support. It supports authentication for the nginx-rtmp-module, enables monitoring of subscribers for each stream, and sending notifications when new streams start.
- Stream Management: Serve HLS playlists for multiple streams.
- Authentication: Securely authenticate clients using tokens.
- Variant Support: Serve different variants (e.g., audio tracks) of a stream.
- Statistics: Track the number of subscribers for each stream.
- Notifications: Send notifications to an external endpoint when a client authenticates.
To run the HLS Utils, ensure you have the following prerequisites:
- Go: Version 1.22 or higher is recommended.
- Open a command line interface on the target system.
- Clone this repository:
git clone <GIT_REPOSITORY>
- Navigate to the cloned directory:
cd hls-utils
- Build the executable:
go build -a -buildmode=exe -trimpath -ldflags="-s -w" -o hls-utils
- Configure the service using
config.yaml
. The service will automatically look for this file in/etc/hls-utils/config.yaml
or the current directory (./config.yaml
). Alternatively, specify a custom path using the--config <PATH>
option. - Start the server:
./hls-utils [--config <PATH>]
YAML Parameter | Description | Default |
---|---|---|
log_level | The logging level (debug , info , warning , error , fatal ) |
debug |
http_server.host | The host address to bind to. | 127.0.0.1 |
http_server.port | The port number to listen on. | 8080 |
http_server.base_path | Base path for the API endpoints. | (empty) |
http_server.cert_file | Path to SSL certificate file (for HTTPS). | (empty) |
http_server.key_file | Path to SSL key file (for HTTPS). | (empty) |
http_server.read_timeout | Timeout for reading requests. | 30s |
http_server.read_header_timeout | Timeout for reading request headers. | 10s |
live_dir | Directory where live HLS streams are stored. | /tmp |
record_dir | Directory where recorded streams are stored. | /tmp |
statistic_rotation_interval | Interval at which statistics are rotated. | 10s |
notification_endpoint | URL to send notifications when a client authenticates. | (empty) |
track_labels | map of labels for different tracks. | (empty) |
streams | Map of stream names to authentication tokens. | (empty) |
To integrate HLS Utils with nginx-rtmp-module
, you need to configure your nginx server as follows:
rtmp {
server {
application stream {
notify_method post;
on_publish http://127.0.0.1:8081/auth;
}
}
}