搭建流媒体服务 SRS

下载包
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值