sintoniza/nginx-rtmp.conf

58 lines
2.0 KiB
Plaintext
Raw Normal View History

2023-05-06 22:32:09 +02:00
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
2023-05-18 23:57:46 +02:00
#hls on;
#hls_path /var/www/html/canal/;
2023-05-06 22:32:09 +02:00
# ajustes de hls
2023-05-18 23:57:46 +02:00
#hls_fragment 5;
#hls_playlist_length 1m;
2023-05-06 22:32:09 +02:00
# 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;
2023-05-18 23:57:46 +02:00
#idle_streams off;
#hls_cleanup on;
2023-05-18 23:49:16 +02:00
## Transcode video for low latencies
2023-05-19 17:03:16 +02:00
exec ffmpeg -i rtmp://localhost/entrada/$name
-c:v libx264 -x264opts keyint=60:no-scenecut -b:v 125k -c:a copy -s 426x240 -r 30 -sws_flags bilinear -tune zerolatency -preset veryfast -f flv rtmp://localhost/show/$name_sd
-c:v libx264 -x264opts keyint=60:no-scenecut -c:a copy -r 30 -tune zerolatency -preset veryfast -f flv rtmp://localhost/show/$name_hd;
2023-05-06 22:32:09 +02:00
}
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;
2023-05-18 23:57:46 +02:00
idle_streams off;
hls_cleanup on;
# Pointing this to an SSD is better as this involves lots of IO
# hls_path /tmp/hls/;
2023-05-18 23:57:46 +02:00
hls_path /var/www/html/canal/;
# Instruct clients to adjust resolution according to bandwidth
2023-05-19 17:03:16 +02:00
hls_variant _sd BANDWIDTH=400000;
hls_variant _hd BANDWIDTH=5000000;
}
2023-05-06 22:32:09 +02:00
}
}