121 lines
2.7 KiB
Nginx Configuration File
121 lines
2.7 KiB
Nginx Configuration File
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;
|
|
|
|
application stream {
|
|
live on;
|
|
|
|
on_publish http://localhost:${{PORT}}/auth;
|
|
}
|
|
|
|
application youtube {
|
|
live on;
|
|
|
|
exec ffmpeg -i rtmp://localhost:1935/youtube/$name -c:a copy -c:v copy -f flv rtmp://a.rtmp.youtube.com/live2/$name;
|
|
}
|
|
|
|
application streamhls {
|
|
live on;
|
|
|
|
#relays the incoming video to low quality streams on this server, audio-only version and to a different server
|
|
exec ffmpeg -i rtmp://localhost:1935/streamhls/$name
|
|
-c:a copy -c:v copy -f flv rtmp://localhost/hls/$name_hi;
|
|
exec ffmpeg -i rtmp://localhost: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://localhost/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_block {
|
|
require("lapis").serve("app")
|
|
}
|
|
}
|
|
|
|
location /favicon.ico {
|
|
alias static/favicon.ico;
|
|
}
|
|
}
|
|
}
|