I work for a small government entity that wants to provide live streams of board meetings for the public. We use OBS to do our encoding and it has never given us any problems, but lately we have had a lot of complaints that our live stream loses connection or simply never loads on our web end.
We are using an NGINX RTMP/HLS streaming server that was built over 5 years ago to provide this stream, and recently I updated it to the latest version of Ubuntu Server and to keep it as up to date as possible, I even reinstalled NGINX and updated a few things here and there, but generally kept our old configuration. Now that I have been testing that, however, I've noticed troublesome performance that may be browser based, but I wanted to ask here first to be sure that our server is playing by the rules.
Our nginx.conf is as follows:
load_module "modules/ngx_rtmp_module.so";
user www-data;
worker_processes auto;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#If you want to enable gzip, uncomment the following:
#gzip on;
#gzip_disable "msie6";
server{
listen 80;
server_name localhost;
add_header Access-Control-Allow-Origin *;
#rtmp stat
location /stat{
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
#This moves stat.xsl to a different location
root /usr/src/nginx-rtmp-module;
}
location /control {
rtmp_control all;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#client (VLC, etc) can access HLS here.
location /hls {
root /tmp;
add_header 'Cache-Control' 'no-cache';
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';
if ($request_method = 'OPTIONS'){
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
}
types {
application/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
}
}
rtmp {
server{
listen 8081;
chunk_size 8192;
ping 30s;
notify_method get;
allow play all;
#allow publish all;
application live {
# We're going to split the stream into different bitrates here for adaptive streaming.
live on;
exec ffmpeg -i rtmp://localhost:8081/live/$name -async 1 -vsync -1 -c:v libx264 -c:a libfdk_aac -b:v 256k -b:a 32k -vf "scale=480:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost:8081/hls/$name_low -c:v libx264 -c:a libfdk_aac -b:v 768k -b:a 96k -vf "scale=720:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost:8081/hls/$name_mid -c:v libx264 -c:a libfdk_aac -b:v 1024k -b:a 128k -vf "scale=960:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost:8081/hls/$name_high -c:v libx264 -c:a libfdk_aac -b:v 1920k -b:a 128k -vf "scale=1280:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost:8081/hls/$name_hd720 -c copy -f flv rtmp://localhost:8081/hls/$name_src;
}
#You should be sending x.264/aac RTMP stream via ffmpeg to this application
application hls {
allow play all;
#allow publish all;
live on;
hls on;
hls_path /tmp/hls;
hls_playlist_length 60s;
hls_fragment 1s;
hls_variant _low BANDWIDTH=288000,RESOLUTION=426x240;
hls_variant _mid BANDWIDTH=448000,RESOLUTION=640x360;
hls_variant _high BANDWIDTH=1152000,RESOLUTION=854x480;
hls_variant _hd720 BANDWIDTH=2048000,RESOLUTION=1280x720;
hls_variant _src BANDWIDTH=4096000,RESOLUTION=1920x1080;
}
}
}
As mentioned, we use Video.js to provide the stream to our users on our website. Configuration about that may be outside of the scope of this board, but for the sake of complete information, this stream plays without a problem on Firefox and Chrome (both on desktop) as well as Brave Browser (mobile), but does not want to work on Brave Browser (on desktop), or Chrome (on Mobile)
Is there anything about this nginx.conf that may be causing that kind of functionality (or lack thereof?) or would that be completely on the web portion of this?