liunx下使用SRS搭建直播流媒体服务器

1 篇文章 0 订阅

开始编译安装

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

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值