音视频入门系列-服务器篇(SRS 的部署)

本篇文章,我们详细介绍下使用SRS来部署一套流媒体服务器,并用FFmpeg来推流,VLC来拉流。

 1.下载srs源码

https://github.com/ossrs/srs/releases

2.解压压缩包

$tar xvf srs-3.0-r8.tar.gz

3.创建build目录

$cd srs-3.0-r8/trunk/
$mkdir build

4.config & make & make install

$./configure --prefix=/home/fly/work/srs/srs-3.0-r8/trunk/build --full
$make
$make install

5.make过程中出现错误及解决方法

In file included from ../../../objs/gtest/include/gtest/internal/gtest-port.h:197:0,
                 from ../../../objs/gtest/include/gtest/internal/gtest-internal.h:40,
                 from ../../../objs/gtest/include/gtest/gtest.h:57,
                 from ../../../src/utest/srs_utest.hpp:36,
                 from ../../../src/utest/srs_utest.cpp:24:
/usr/include/c++/7/sstream:300:7: error: ‘struct std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>::__xfer_bufptrs’ redeclared with different access struct __xfer_bufptrs
$./configure --prefix=/home/fly/work/srs/srs-3.0-r8/trunk/build --full --without-utest
$make
$make install

6.增加配置文件:/home/fly/work/srs/srs-3.0-r8/trunk/build/conf/my_hls.conf

listen              1935;
max_connections     1000;
daemon              on;
srs_log_tank        file;
srs_log_level        error;
srs_log_file        ./objs/srs.log;

http_server {
    enabled         on;
    listen          8081;
    dir             ./objs/nginx/html;
}

vhost __defaultVhost__ {
    hls {
        enabled         on;
        hls_fragment    10;
        hls_window      60;
        hls_path        ./objs/nginx/html;
        hls_m3u8_file   [app]/[stream].m3u8;
        hls_ts_file     [app]/[stream]-[seq].ts;
        hls_cleanup     on;
        hls_dispose     30;
        hls_on_error    continue;
        hls_storage     disk;
        hls_wait_keyframe       on;
        hls_acodec      aac;
        hls_vcodec      h264;
    }
}

7.启动 srs

~/home/fly/work/srs/srs-3.0-r8/trunk/build$sudo ./objs/srs -c ./conf/my_hls.conf

8.ffmpeg推流

ffmpeg -i test.mp4 -vcodec libx264 -acodec aac -f flv rtmp://192.168.2.128:1935/live/index


9.生成的 m3u8 和 ts 文件路径

~/work/srs/srs-3.0-r8/trunk/build/objs/nginx/html/live


10.VLC拉流(rtmp、http)

rtmp://192.168.2.128:1935/live/index
http://192.168.2.128:8081/live/index.m3u8

 音视频入门系列文章已同步在微信公众号(可扫下方二维码关注):八小时码字员

音视频入门系列,同步录制了学习视频,已上传至bilibili(八小时码字员):音视频入门系列(图像、音频、字幕、视频封装格式,FFmpeg、ffplay源码分析,解码、编码、转码,流媒体协议,服务器部署)_哔哩哔哩_bilibili

音视频学习交流QQ群:693316541

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值