user nginx; worker_processes 4; error_log /var/log/nginx/error.log info; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /usr/local/nginx/conf/mime.types; include /usr/local/nginx/conf/fastcgi.conf; include /usr/local/nginx/conf/upstream_phpcgi.conf; client_body_timeout 60; client_header_timeout 60; send_timeout 60; client_max_body_size 10m; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; keepalive_timeout 65; gzip on; gzip_disable "msie6"; gzip_buffers 16 8k; gzip_comp_level 1; gzip_http_version 1.1; gzip_min_length 10; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon application/vnd.ms-fontobject font/opentype application/ x-font-ttf; gzip_vary on; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; index index.html index.htm; server { listen 80; server_name localhost; root /var/www/html; location /hls/room1 { auth_basic off; types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root /tmp; add_header Cache-Control no-cache; } location /hls/room2 { auth_basic off; types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root /tmp; add_header Cache-Control no-cache; } } } rtmp { server { listen 1935; chunk_size 4096; meta off; application src2 { live on; record off; record_path /tmp/hls/src2; record_max_size 1k; record_unique on; wait_video on; wait_key on; # # Stream to Youtube live, channel 2 # Stream is received in YT compatible format and only copied to YT # exec_push ffmpeg -i rtmp://127.0.0.1/src2/$name -vcodec copy -acodec copy -threads 6 -bufsize 512k -f flv rtmp://a.rtmp.youtube.com/live2/; # # Stream to HLS # Stream will be converted to meet HLS requirements like size, quality and bandwidth. # OBS can send streams in higher or lower quality, ffmpeg will adjust them. # exec_push ffmpeg -i rtmp://127.0.0.1/src2/$name -s 640x480 -pix_fmt yuv420p -c:a aac -strict experimental -ac 2 -b:a 64k -ar 44100 -c:v libx264 -profile:v baseline -level 3.0 -f flv rtmp://localhost/hls/room2/$name; } application src { live on; record off; record_path /tmp/hls/av; record_max_size 1k; record_unique on; wait_video on; wait_key on; # # Stream to Youtube live, channel 1 # Stream is received in YT compatible format and only copied to YT # exec_push ffmpeg -i rtmp://127.0.0.1/src/$name -vcodec copy -acodec copy -threads 6 -bufsize 512k -f flv rtmp://a.rtmp.youtube.com/live2/; # # Stream to HLS # Stream will be converted to meet HLS requirements like size, quality and bandwidth. # OBS can send streams in higher or lower quality, ffmpeg will adjust them. # exec_push ffmpeg -i rtmp://127.0.0.1/src/$name -s 640x480 -pix_fmt yuv420p -c:a aac -strict experimental -ac 2 -b:a 64k -ar 44100 -c:v libx264 -profile:v baseline -level 3.0 -f flv rtmp://localhost/hls/room1/$name; } application hls/room1 { live on; hls on; hls_fragment 10; hls_fragment_naming sequential; hls_type live; hls_path /tmp/hls/room1; } application hls/room2 { live on; hls on; hls_fragment 10; hls_fragment_naming sequential; hls_type live; hls_path /tmp/hls/room2; } } }