开始编译安装
git clone -b 4.0release https://gitee.com/ossrs/srs.git
cd srs/trunk
./configure && make
vi ./conf/srs.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;
}
stats {
network 0;
}
rtc_server {
enabled on;
# Listen at udp://8000
listen 8000;
#
# The $CANDIDATE means fetch from env, if not configed, use * as default.
#
# The * means retrieving server IP automatically, from all network interfaces,
# @see https://github.com/ossrs/srs/wiki/v4_CN_RTCWiki#config-candidate
candidate $CANDIDATE;
}
vhost __defaultVhost__ {
rtc {
enabled on;
rtc_to_rtmp on;
bframe discard;
stun_timeout 30;
stun_strict_check on;
dtls_role passive;
dtls_version auto;
drop_for_pt 0;
}
hls {
enabled on;
}
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
hstrs on;
}
tcp_nodelay on
min_latency on;
play {
gop_cache off;
queue_length 10;
mw_latency 0;
mw_msgs 1;
}
publish {
mr off;
}
http_hooks {
enabled on;
on_connect http://127.0.0.1:8085/callback/srsCallback/onConnect;
on_close http://127.0.0.1:8085/callback/srsCallback/onClose;
on_publish http://127.0.0.1:8085/callback/srsCallback/onPublish;
on_unpublish http://127.0.0.1:8085/callback/srsCallback/onUnpublish;
on_play http://127.0.0.1:8085/callback/srsCallback/onPlay;
on_stop http://127.0.0.1:8085/callback/srsCallback/onStop;
on_dvr http://127.0.0.1:8085/callback/srsCallback/onDvr;
}
dvr {
enabled on;
dvr_apply all;
dvr_path ./objs/nginx/html/[app]/[2006]/[01]/[02]/[stream].[15][04][05].[999].flv;
dvr_duration 30;
dvr_wait_keyframe on;
time_jitter full;
}
}
保存退出,之后启动srs,要记得放行对应的端口 ,可看https://www.cnblogs.com/ubiquitousShare/p/13135747.html
./objs/srs -c conf/srs.conf
srs常用命令
在/srs/trunk下执行
./etc/init.d/srs start
#启动srs
./etc/init.d/srs restart
#重启srs
./etc/init.d/srs stop
#关闭srs
./etc/init.d/srs status
#查看srs状态
tail -f ./objs/srs.log
#查看srs日志
推流地址
WebRTC推流:
webrtc://192.168.88.115/live/livestream
或
rtmp推流:rtmp://192.168.88.115/live/livestream
拉流对应地址
VLC(RTMP):
rtmp://192.168.88.115/live/livestream
H5(HTTP-FLV):http://192.168.88.115:8080/live/livestream.flv
H5(HLS):http://192.168.88.115:8080/live/livestream.m3u8
H5(WebRTC):webrtc://192.168.88.115/live/livestream
也可以使用SRS进行推流拉流,浏览器访问
http://192.168.88.115:8080/
源码地址
Github:https://github.com/ossrs/srs
Gitee:https://gitee.com/ossrs/srs