worker_processes auto; pid /home/ian/nginx.pid; include /etc/nginx/modules-enabled/*.conf; error_log /home/ian/nginx-error.log; events { worker_connections 768; # multi_accept on; } http{ access_log off; error_log /home/ian/nginx-error.log; server { listen 9999; location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } } } rtmp { server { access_log off; listen 1977; # Listen on standard RTMP port chunk_size 4096; # Sample RTMP Application application live { live on; # Enable listening for live streams to this application record all; # Do not record the stream meta copy; # Copy the incoming metadata for the outgoing metadata record_path /home/ian/git/testbench/webapp/streams; record_unique on; record_interval 60m; hls on; hls_continuous on; hls_path /home/ian/git/testbench/webapp/streams; hls_fragment 10s; hls_playlist_length 60m; hls_cleanup off; # dash on; # dash_path /tmp/dash; } application src { live on; record off; # Do not record the stream hls_continuous on; meta copy; # Copy the incoming metadata for the outgoing metadata on_publish http://localhost:8080/oneliveweb/streaming/streamstart.html; on_publish_done http://localhost:8080/oneliveweb/streaming/streamend.html; hls_type live; exec ffmpeg -i rtmp://localhost/src/$name -c:a copy -c:v libx264 -b:v 128K -f flv rtmp://localhost/hls/$name_low -c:a copy -c:v libx264 -b:v 256k -f flv rtmp://localhost/hls/$name_mid -c:a copy -c:v libx264 -b:v 512K -f flv rtmp://localhost/hls/$name_hi; } application hls { live on; hls on; hls_path /home/ian/git/testbench/webapp/streams; hls_nested on; hls_continuous on; hls_variant _low BANDWIDTH=160000; hls_variant _mid BANDWIDTH=320000; hls_variant _hi BANDWIDTH=640000; hls_cleanup off; hls_type event; hls_playlist_length 24h; } # This application is for splitting the stream into HLS fragments application show { live on; # Allows live input from above hls on; # Enable HTTP Live Streaming hls_cleanup off; # Save this for later, EM can cleanup # Pointing this to an SSD is better as this involves lots of IO hls_path /mnt/hls/; hls_continuous on; # Instruct clients to adjust resolution according to bandwidth hls_variant _low BANDWIDTH=288000; # Low bitrate, sub-SD resolution hls_variant _mid BANDWIDTH=448000; # Medium bitrate, SD resolution hls_variant _high BANDWIDTH=1152000; # High bitrate, higher-than-SD resolution hls_variant _hd720 BANDWIDTH=2048000; # High bitrate, HD 720p resolution hls_variant _src BANDWIDTH=4096000; # Source bitrate, source resolution } } } #https://smartshitter.com/musings/2017/12/nginx-rtmp-streaming-with-simple-authentication/