worker_processes ${{NUM_WORKERS}}; error_log stderr notice; daemon off; pid logs/nginx.pid; events { worker_connections 1024; } rtmp { server { listen 1935; chunk_size 4000; # recommended directives: https://github.com/savonet/liquidsoap/issues/1389#issuecomment-1095096246 idle_streams off; wait_key on; wait_video on; application stream { live on; on_publish http://127.0.0.1:${{PORT}}/auth; } application youtube { live on; allow publish 127.0.0.1; #exec ffmpeg -i rtmp://127.0.0.1:1935/youtube/$name -c:a copy -c:v copy -f flv rtmp://a.rtmp.youtube.com/live2/$name; #exec ffmpeg -i rtmp://127.0.0.1:1935/youtube/$name -c:a copy -c:v copy -f flv rtmp://${arg_url}.rtmp.youtube.com/live1/$name; exec ffmpeg -i rtmp://127.0.0.1:1935/youtube/$name -c:a copy -c:v copy -f flv rtmp://x.rtmp.youtube.com/live2/hj5m-x8ff-pqyv-rtu0-26fk; #exec ffmpeg -i rtmp://127.0.0.1:1935/youtube/$name -c:a copy -c:v copy -f flv rtmp://a.rtmp.youtube.com/live2/m5wk-h9xr-70g1-uzr7-dwgf; exec ffmpeg -i rtmp://127.0.0.1:1935/youtube/$name -c:a copy -c:v copy -f flv rtmp://a.rtmp.youtube.com/live2/m0a5-r1rq-9qjf-pjk9-9kke; #exec ffmpeg -i rtmp://127.0.0.1:1935/youtube/$name -c:a copy -c:v copy -f flv rtmp://$name; } application streamhls { live on; allow publish 127.0.0.1; #relays the incoming video to low quality streams on this server, audio-only version and to a different server exec ffmpeg -i rtmp://127.0.0.1:1935/streamhls/$name -c:a copy -c:v copy -f flv rtmp://127.0.0.1/hls/$name_hi; exec ffmpeg -i rtmp://127.0.0.1:1935/streamhls/$name -max_muxing_queue_size 1024 -c:a copy -c:v libx264 -b:v 128K -preset superfast -profile:v baseline -f flv rtmp://127.0.0.1/hls/$name_low; # 2>/mnt/radio/logs/ffmpeg-$name_low.log; } application hls { live on; hls on; hls_fragment_naming system; hls_fragment 3; hls_playlist_length 60; hls_path /opt/data/hls; hls_nested on; hls_variant _hi BANDWIDTH=640000; hls_variant _low BANDWIDTH=160000; } } } http { include mime.types; # init_by_lua_block { # require("socket") # require("lpeg") # math.randomseed(os.time()+ngx.worker.id()) # } server { listen ${{PORT}}; lua_code_cache ${{CODE_CACHE}}; # nginx-rtmp hls and status endpoints location /hls { types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root /opt/data; add_header Access-Control-Allow-Origin *; } location /live { alias /opt/data/hls; types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } add_header Access-Control-Allow-Origin *; } location /stat { rtmp_stat all; rtmp_stat_stylesheet static/stat.xsl; } location /static { alias static; } location = /crossdomain.xml { root static; default_type text/xml; expires 24h; } # lapis endpoints location /data/ { root /mnt; } location / { default_type text/html; content_by_lua ' require("lapis").serve("app") '; } location /favicon.ico { alias static/favicon.ico; } } }