SRS流媒体服务器搭建+ffmpeg推流VLC取流观看

£神魔★判官ぃ 2022-05-18 10:18 377阅读 0赞

SRS流媒体服务器搭建+ffmpeg推流VLC取流观看

2015年12月22日 09:50:25

阅读数:22630

一、编译SRS
https://github.com/winlinvip/simple-rtmp-server
目前有1.0-release、2.0、3.0等版本
2.0官方文档地址:https://github.com/winlinvip/simple-rtmp-server/wiki/v2_CN_Home

1.如果是新系统,先安装git

  1. CentOSyum -y install git
  • 1

2.源码下载:

  1. git clone https://code.csdn.net/winlinvip/srs-csdn.git
  • 1

3.git操作

a.改变SRS分支

  1. 切换到1.0分支
  2. git pull && git checkout 1.0release
  3. 切换到2.0分支
  4. git pull && git checkout 2.0release
  • 1
  • 2
  • 3
  • 4

我把源码下载到了/mnt目录,然后我们cd /mnt

b.查看当前分支

  1. cd /mnt/srs-csdn;git branch
  • 1

c.改变到2.0分支

  1. git pull && git checkout 2.0release
  • 1

4.编译安装

  1. cd /mnt/srs-csdn/trunk
  • 1

./configure -h #查看编译时的帮助,里面有一些指定的参数是情况加减,官方文档

开始编译:

  1. ./configure --prefix=/usr/local/srs --with-ssl --with-hls --with-hds --with-dvr --with-nginx --with-http-callback --with-http-server --with-stream-caster --with-http-api --with-ffmpeg --with-transcode --with-ingest --with-stat --with-librtmp --with-research --with-utest --with-gperf --with-gprof
  2. make;make install
  • 1
  • 2
  • 3

第三方应用启动:

  1. sudo ./objs/nginx/sbin/nginx --- 启动nginx for hls
  2. ./objs/ffmpeg/bin/ffmpeg ---ffmpeg
  3. python ./research/api-server/server.py 8085 ---to start the api-server
  • 1
  • 2
  • 3

SRS启动

  1. cd /mnt/srs-csdn/trunk
  2. ./objs/srs -c conf/srs.conf
  3. ps -ef | grep srs
  4. ./srs -v
  • 1
  • 2
  • 3
  • 4

到此为止,SRS已编译安装完成!

二、配置RTMP
1.RTMP URL解释:

  1. rtmp://HOST:PORT/app/stream_name
  2. rtmp: 协议头
  3. HOST:注意的IP地址或域名
  4. app: 应用名称
  5. stream_name:流名称
  • 1
  • 2
  • 3
  • 4
  • 5

2.SRS中RTMP配置信息
文件目录:/mnt/srs-csdn/trunk/conf/rtmp.conf
配置内容:

  1. listen 1935;
  2. pid ./objs/srs.pid;
  3. chunk_size 60000;
  4. ff_log_dir ./objs;
  5. srs_log_tank file;
  6. #配置日志答应到文件,需要和srs_log_level配合使用
  7. srs_log_level trace;
  8. #制定配置文件的级别,默认级别是trace
  9. srs_log_file ./objs/srs.log;
  10. #制定日志文件的位置。
  11. max_connections 1000;
  12. #最大连接数
  13. daemon on;
  14. #以daemon的方式启动,如果要启动在console,那么需要配置daemon off;并且,需要配置srs_log_tank console;
  15. utc_time off;
  16. #是否使用utc时间。如果该值为off则使用本地时间,如果开始使用utc时间。
  17. vhost __defaultVhost__ {
  18. #默认的vhost,在没有指明vhost的情况,默认使用这个vhost。
  19. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

3.ffmpeg推流 VLC播放
ffmpeg可执行程序目录:/mnt/srs-csdn/trunk/objs/ffmpeg/bin/ffmpeg

推流:

  1. cd /mnt/srs-csdn/trunk/objs/ffmpeg/bin
  2. ./ffmpeg -i "abc.avi" -vcodec libx264 -vprofile baseline -level 30 -g 60 -vb 800k -strict experimental -acodec aac -ab 96000 -ar 48000 -ac 2 -f flv rtmp://192.168.1.62:1935/live/zb
  • 1
  • 2

VLC取流:

  1. rtmp://192.168.1.62:1935/live/zb
  • 1

这里写图片描述

参考文献:

https://blog.csdn.net/Henry_wk/article/details/50377881

发表评论

表情:
评论列表 (有 0 条评论,377人围观)

还没有评论,来说两句吧...

相关阅读

    相关 SRSWebRTC媒体服务器

    WebRTC经过这么多年的发展,目前已经比较成熟的协议之一,播放也比较稳定,协议也已经成为了RFC,相应的开源项目也越来越多,但是基于WebRTC协议的部署简单,性能强悍,功能

    相关 centos SRS 媒体服务

    目的: 最近公司有一个流媒体项目交给我负责,其中包括一项直播功能,原本使用的是ffmpeg进行推流、拉流操作。但是在服务端频繁启动命令很麻烦。查阅资料发现目前主流技术包括re