Update: Nginx Config, Stats, SD variant on live stream

This commit is contained in:
Siroco 2023-05-18 16:29:30 -05:00
parent efcccab20f
commit 3d3064e73e
No known key found for this signature in database
GPG Key ID: 1324098302A514B0
4 changed files with 59 additions and 8 deletions

View File

@ -1,7 +1,8 @@
FROM registry.sindominio.net/nginx FROM registry.sindominio.net/nginx
RUN apt-get update -y && \ RUN apt-get update -y && \
apt-get install -y libnginx-mod-rtmp cron apt-get install -y libnginx-mod-rtmp cron \
ffmpeg wget
RUN rm -rf /var/www/html/* RUN rm -rf /var/www/html/*
@ -21,6 +22,9 @@ RUN mkdir -p /var/www/html/hls && \
# poner el index.html css y js # poner el index.html css y js
COPY index.html /var/www/html/ COPY index.html /var/www/html/
RUN mkdir /var/www/html/rtmp/ && \
wget https://raw.githubusercontent.com/arut/nginx-rtmp-module/master/stat.xsl -O /var/www/html/rtmp/stat.xsl
RUN mkdir -p /var/www/html/assets/ RUN mkdir -p /var/www/html/assets/
COPY assets/styles-sintoniza.css /var/www/html/assets/ COPY assets/styles-sintoniza.css /var/www/html/assets/
COPY assets/video-js.min.css /var/www/html/assets/video-js.min.css COPY assets/video-js.min.css /var/www/html/assets/video-js.min.css
@ -28,5 +32,5 @@ COPY assets/video.min.js /var/www/html/assets/video-js.min.js
COPY assets/jquery-3.6.1.slim.min.js /var/www/html/assets/jquery-slim.min.js COPY assets/jquery-3.6.1.slim.min.js /var/www/html/assets/jquery-slim.min.js
# copiar la configuración por defecto de nginx con nuestros cambios incluidos # copiar la configuración por defecto de nginx con nuestros cambios incluidos
COPY nginx-site-default.conf /etc/nginx/sites-available/default COPY nginx-site-default.conf /etc/nginx/sites-enabled/default

View File

@ -1,8 +1,10 @@
sintoniza: version: "3"
container_name: sintoniza services:
hostname: sintoniza sintoniza:
build: .
restart: always restart: always
image: registry.sindominio.net/sintoniza image: registry.sindominio.net/sintoniza
user: 111:65534 user: 111:65534
ports: ports:
- "0.0.0.0:8080:8080" - "0.0.0.0:8080:8080"
- "0.0.0.0:1935:1935"

View File

@ -18,6 +18,33 @@ rtmp {
# para bloquear el directo # para bloquear el directo
# quita el comentario de la línea siguiente # quita el comentario de la línea siguiente
# deny play all; # deny play all;
# TODO: Podemos usarlo para validar los accesos
#on_publish http://docker.for.mac.host.internal:5000/api/stream/start;
#on_publish_done http://docker.for.mac.host.internal:5000/api/stream/end;
## Transcode video for low latencies
exec ffmpeg -i rtmp://localhost/entrada/$name -c:v libx264 -x264opts keyint=60:no-scenecut -b:v 450k -c:a copy -s 854x480 -r 30 -sws_flags bilinear -tune zerolatency -preset veryfast -f flv rtmp://localhost/show/$name_sd;
} }
application show {
live on; # Allows live input from above
hls on; # Enable HTTP Live Streaming
hls_type live; # Either 'event' or 'live' (live means played from current live position)
deny play all; # Disable consuming the stream from nginx as rtmp
hls_fragment 2s;
hls_playlist_length 10s;
# Pointing this to an SSD is better as this involves lots of IO
# hls_path /tmp/hls/;
hls_path /var/www/html/canal/variant/;
# Instruct clients to adjust resolution according to bandwidth
#hls_variant _subsd BANDWIDTH=400000;
hls_variant _sd BANDWIDTH=1000000;
#hls_variant _hd BANDWIDTH=5000000;
}
} }
} }

View File

@ -12,17 +12,35 @@ server {
location / { location / {
try_files $uri $uri/ =404; try_files $uri $uri/ =404;
} }
location /control {
rtmp_control all;
}
# rtmp stat
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /var/www/html/rtmp;
}
location /canal { location /canal {
# Disable cache # Disable cache
add_header Cache-Control no-cache; add_header Cache-Control no-cache;
# CORS setup # CORS setup
add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Cache-Control' 'no-cache';
add_header 'Access-Control-Expose-Headers' 'Content-Length'; add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
add_header 'Access-Control-Allow-Headers' 'Range';
# allow CORS preflight requests # allow CORS preflight requests
if ($request_method = 'OPTIONS') { if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'Range';
add_header 'Access-Control-Max-Age' 1728000; add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0; add_header 'Content-Length' 0;