下载包
git clone https://github.com/ossrs/srs
解压
cd srs/trunk
./configure
make
两种方式运行
1 sudo ./etc/init.d/srs start
2 ./objs/srs -c conf/srs.conf
判断是否运行
./etc/init.d/srs status
或者
ps -ef | grep srs
查看日志
tail -f ./objs/srs.log
配置文件
cat trunk/conf/srs.conf
内容如下
# main config for srs.
# @see full.conf for detail config.
listen 1935;
max_connections 1000;
#srs_log_tank file;
#srs_log_file ./objs/srs.log;
daemon on;
http_api {
enabled on;
listen 1985;
}
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
}
rtc_server {
enabled on;
listen 8000; # UDP port
# @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
candidate $CANDIDATE;
}
vhost __defaultVhost__ {
hls {
enabled on;
}
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
}
rtc {
enabled on;
# @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
rtmp_to_rtc off;
# @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
rtc_to_rtmp off;
}
play{
gop_cache_max_frames 2500;
}
}
推流使用 1935端口
Web Console 页面 8080
拉流端口 8080
Web端连接服务器 端口1985
优化
根据官方文档,可以更改配置文件,低延迟配置,在vhost __ defaultVhost __ 添加以下配置。具体原理可以参考官方文档。
tcp_nodelay on;
min_latency on;
play {
gop_cache off;
queue_length 10;
mw_latency 100;
}
publish {
mr off;
}
使rtmp的延迟优化在3秒左右
修改后重新加载配置
./etc/init.d/srs reload