sintoniza/nginx-rtmp.conf
2023-05-18 16:49:16 -05:00

55 lines
1.9 KiB
Plaintext

rtmp {
# abre nginx para escuchar por el puerto
server {
listen 1935;
chunk_size 4096;
# dale un nombre a tu aplicacion
#log_format combined '$remote_addr [$time_local] $command "$app" "$name" "$args" - $bytes_received $bytes_sent "$pageurl" "$flashver" ($session_readable_time)'
application entrada {
live on;
# enciende HLS
hls on;
hls_path /var/www/html/canal/;
# ajustes de hls
hls_fragment 5;
hls_playlist_length 1m;
# para bloquear el directo
# quita el comentario de la línea siguiente
# 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;
idle_streams off;
hls_cleanup on;
## 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;
}
}
}