【网络通信 -- 直播】SRS -- SRS 部署与直播效果测试
发布日期:2021-05-07 20:53:18 浏览次数:34 分类:精选文章

本文共 3291 字,大约阅读时间需要 10 分钟。

【网络通信 -- 直播】SRS -- SRS 部署与直播效果测试

【1】SRS(Simple Realtime Server) 部署

SRS 代码下载

git clone https://gitee.com/winlinvip/srs.oschina.git srs &&cd srs/trunk && git remote set-url origin https://github.com/ossrs/srs.git && git pull# webrtc需要srs的最低版本:SRS4.0.14,所以我们部署的srs的时候版本需要大于SRS4.0.14# 查看分支git branch -v# 若是不是 *4.0release ,需要切换分支git checkout 4.0release#再次查看当前所处分支git branch -v

SRS 代码配置与编译

配置./configure --with-hls --with-ssl --with-http-server --with-http-callback --with-http-api --with-ingest --with-stream-caster编译make

【2】SRS 配置与启动

SRS 配置文件示例

# the config for srs to delivery RTMP# @see https://github.com/ossrs/srs/wiki/v1_CN_SampleRTMP# @see full.conf for detail config.listen              1935;max_connections     1000;srs_log_tank        console;srs_log_file        ./objs/srs.log;daemon              off;http_server {    enabled         on;    listen          8080;    dir             ./objs/nginx/html;}http_api {    enabled         on;    listen          1985;}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/issues/307#issuecomment-599028124    candidate       $CANDIDATE;}vhost __defaultVhost__ {    # 0延迟,默认就是0延迟    min_latency     on;    tcp_nodelay     on;    play {        gop_cache       off;        queue_length    10;        mw_latency      100;        mw_msgs         0;    }     # 开启 flv 播放    http_remux {        enabled     on;        mount       [vhost]/[app]/[stream].flv;    }    # 开启 m3u8 播放     hls {         enabled         on;         hls_path        ./objs/nginx/html;         hls_fragment    10;         hls_window      60;     }     # 保存视频     dvr {        enabled      on;        # 这个里的都保存        dvr_apply       all;        dvr_path     ./objs/nginx/dvr/[app]/[stream]/[timestamp].mp4;        dvr_plan     session;        time_jitter             full;    }    #vhost打开启用rtc    rtc {        enabled     on;        bframe      discard;    }}vhost nosave {    # 0延迟,默认就是0延迟    # min_latency     on;    # play {    #     mw_latency      0;    #     mw_msgs         0;    # }    # 开启 flv 播放    http_remux {        enabled     on;        mount       [vhost]/[app]/[stream].flv;    }    # 开启 m3u8 播放     hls {         enabled         on;         hls_path        ./objs/nginx/html;         hls_fragment    10;         hls_window      60;     }    #vhost打开启用rtc    rtc {        enabled     on;        bframe      discard;    }}

SRS 启停命令

启动 SRS./objs/srs -c 配置文件路径(一般位于 conf 文件夹下)查看 SRS 状态./etc/init.d/srs status停止 SRS./etc/init.d/srs stop

【3】SRS 服务器相关说明

【3.1】SRS 自带播放器网址

SRS 自带播放器网址,

【3.2】SRS 控制台配置

下载 ossrs/srs-docker 项目,将其中的 srs-docker/srs-console/trunk/research/ 中的 console 文件夹复制到 srs 服务的 srs/trunk/objs/nginx/html/ 文件夹中,此时控制台访问网址即为 http://IP:1985/console/ng_index.html#/connect;

【4】推流端软件简介

【4.1】Open Broadcaster Software,OBS

官方网址,

主界面图示

推流设置

【5】直播效果展示

实验环境

SRS 服务器(部署在单台台式机);推流工具 OBS,推送 RTMP 流;拉流工具 VLC,拉取 RTMP,HTTP-FLV;SRS 自带 RTC 播放器,WebRTC 拉流;

推流直播效果对比

RTMP 推流 + RTMP 拉流

RTMP 推流 + HTTP-FLV 拉流

RTMP 推流 + WebRTC 拉流

参考与致谢

本博客为博主的学习实践总结,并参考了众多博主的博文,在此表示感谢,博主若有不足之处,请批评指正。

【1】

【2】

【3】

【4】

【5】

上一篇:【C/C++基础进阶系列】C/C++ 对象模型 -- 类基础知识总结(三)
下一篇:【网络通信 -- 直播】开源流媒体服务器对比与 SRS 直播效果测试

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2025年04月08日 20时19分28秒