From 75321cb769f26e6a30f9db90d01ea54993b9c7ec Mon Sep 17 00:00:00 2001 From: BluemediaGER Date: Fri, 4 Jun 2021 21:38:26 +0200 Subject: [PATCH] Make HLS playlist and fragment lengh changeable --- Dockerfile | 2 ++ README.md | 2 ++ config/nginx-ssl.conf.skel | 4 ++-- config/nginx.conf.skel | 4 ++-- entrypoint | 2 ++ 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 21de4e2..2f94d17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,8 @@ LABEL maintainer="oliver@traber-info.de" ENV DEBIAN_FRONTEND noninteractive ENV RTMP_PORT 1935 ENV HTTP_PORT 8080 +ENV HLS_FRAGMENT_LENGTH 3 +ENV HLS_PLAYLIST_LENGTH 20 # Update and install packages RUN apt update -y && \ diff --git a/README.md b/README.md index c9619b4..6c19902 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ If you want to make the web player and the HLS files available via HTTPS, you ca - `TLS_CERT` - File name of the TLS certificate file in the /cert directory inside the container. If set, encrypted ingest will be enabled on the RTMP port. - `TLS_KEY` - File name of the private key that belongs to the TLS certificate. - `STREAM_KEY` - Stream key, which is needed to ingest stream data. If the variable is not set, the key is randomly generated at container startup. +- `HLS_FRAGMENT_LENGTH` - Length of one HLS fragment in seconds. Defaults to `3`. +- `HLS_PLAYLIST_LENGTH` - Length of the HLS playlist in seconds. Defaults to `20`. ## Built with - [NGINX](https://www.nginx.com/) High Performance Load Balancer, Web Server, & Reverse Proxy diff --git a/config/nginx-ssl.conf.skel b/config/nginx-ssl.conf.skel index d78aba1..34a1c86 100644 --- a/config/nginx-ssl.conf.skel +++ b/config/nginx-ssl.conf.skel @@ -73,8 +73,8 @@ rtmp { # Turn on HLS hls on; hls_path /var/www/html/hls/; - hls_fragment 3; - hls_playlist_length 20; + hls_fragment {HLS_FRAGMENT_LENGTH}; + hls_playlist_length {HLS_PLAYLIST_LENGTH}; } } } diff --git a/config/nginx.conf.skel b/config/nginx.conf.skel index de7cb88..359dcbe 100644 --- a/config/nginx.conf.skel +++ b/config/nginx.conf.skel @@ -60,8 +60,8 @@ rtmp { # Turn on HLS hls on; hls_path /var/www/html/hls/; - hls_fragment 3; - hls_playlist_length 20; + hls_fragment {HLS_FRAGMENT_LENGTH}; + hls_playlist_length {HLS_PLAYLIST_LENGTH}; } } } diff --git a/entrypoint b/entrypoint index 121765a..7500433 100644 --- a/entrypoint +++ b/entrypoint @@ -26,6 +26,8 @@ if [ ! -f /setup.lock ]; then sed -i "s/{RTMP_PORT}/$RTMP_PORT/g" /etc/nginx/nginx.conf sed -i "s/{STREAM_KEY}/$VALID_STREAM_KEY/g" /etc/nginx/nginx.conf sed -i "s/{HTTP_PORT}/$HTTP_PORT/g" /etc/nginx/nginx.conf + sed -i "s/{HLS_FRAGMENT_LENGTH}/$HLS_FRAGMENT_LENGTH/g" /etc/nginx/nginx.conf + sed -i "s/{HLS_PLAYLIST_LENGTH}/$HLS_PLAYLIST_LENGTH/g" /etc/nginx/nginx.conf # Touch setup lock touch /setup.lock