下载SRS4.0.85 :git clone -b v4.0.85 https://gitee.com/ossrs/srs.git
服务器配置参考链接:1-SRS 4.0开发环境搭建:包括推流、服务器配置、拉流测试 - 知乎
webRTC延迟基本在1s内,配置好webrtc文件后可用obs推流,见文Windows+nginx+rtmp+OBS中obs推流
另注:服务开启命令:./objs/srs -c conf/rtc.conf
将公网IP改到rtc.conf中的candidate 47.108.xx.xx;
按照配置文件说明开放端口(linux):
iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
#如国标平台接入需开udp-5060端口,否则获取不到画面
iptables -I INPUT -p udp --dport 5060 -j ACCEPT
#最后不要忘
iptables-save
nginx作Https代理
nginx配置文件如下,将nginx证书与密钥配置好即可。
先开启nginx服务再开启srs服务
如果nginx没有http2模块,运行以下命令
#安装http2模块
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module
#直接make不覆盖编译
make
#启动命令
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/srsnginx.conf
#nginx.conf配置文件
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
server {
listen 80;
listen 443 ssl http2;
server_name _;
ssl_certificate /usr/local/srs/conf/server.crt;
ssl_certificate_key /usr/local/srs/conf/server.key;
# For SRS homepage, console and players
# http://r.ossrs.net/console/
# http://r.ossrs.net/players/
location / {
proxy_pass http://127.0.0.1:8080/;
}
# For SRS streaming, for example:
# http://r.ossrs.net/live/livestream.flv
# http://r.ossrs.net/live/livestream.m3u8
location ~ /.+/.*\.(flv|m3u8|ts|aac|mp3)$ {
proxy_pass http://127.0.0.1:8080$request_uri;
}
# For SRS backend API for console.
location /api/ {
proxy_pass http://127.0.0.1:1985/api/;
}
# For SRS WebRTC publish/play API.
location /rtc/ {
proxy_pass http://127.0.0.1:1985/rtc/;
}
}
}