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

来源:互联网 发布:百度云总是网络不给力 编辑:程序博客网 时间:2024/05/21 03:28


http://lib.csdn.net/article/liveplay/37316


一、编译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

CentOS:yum -y install git
  • 1

2.源码下载:

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

3.git操作

a.改变SRS分支

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

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

b.查看当前分支

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

c.改变到2.0分支

git pull && git checkout 2.0release
  • 1

4.编译安装

cd /mnt/srs-csdn/trunk
  • 1

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

开始编译:

./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-gprofmake;make install
  • 1
  • 2
  • 3

第三方应用启动:

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

SRS启动

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

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

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

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

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

listen              1935;pid                 ./objs/srs.pid;chunk_size          60000;ff_log_dir          ./objs;srs_log_tank        file;  #配置日志答应到文件,需要和srs_log_level配合使用srs_log_level       trace; #制定配置文件的级别,默认级别是tracesrs_log_file        ./objs/srs.log;  #制定日志文件的位置。max_connections     1000; #最大连接数daemon              on; #以daemon的方式启动,如果要启动在console,那么需要配置daemon off;并且,需要配置srs_log_tank console;utc_time            off; #是否使用utc时间。如果该值为off则使用本地时间,如果开始使用utc时间。vhost __defaultVhost__ {   #默认的vhost,在没有指明vhost的情况,默认使用这个vhost。}
  • 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

推流:

cd /mnt/srs-csdn/trunk/objs/ffmpeg/bin./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取流:

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

这里写图片描述

查看原文>>





原创粉丝点击