服务器:SRS(Simple RTMP Server,⽀持RTMP、HTTP-FLV,HLS)
推流端:ffmpeg + OBS
拉流端:ffplay +VLC + srs播放器
安装和测试srs流媒体服务器
srs官⽹:https://github.com/ossrs/srs
码云的源速度快:https://gitee.com/winlinvip/srs.oschina.git
github的源速度慢:https://github.com/ossrs/srs.git
第⼀步,获取SRS。详细参考GIT获取代码
git clone https://gitee.com/winlinvip/srs.oschina.git
Cloning into 'srs.oschina'...
remote: Enumerating objects: 14042, done.
remote: Counting objects: 100% (14042/14042), done.
remote: Compressing objects: 100% (5642/5642), done.
remote: Total 60993 (delta 9696), reused 12445 (delta 8313), pack-reused 46951
Receiving objects: 100% (60993/60993), 225.07 MiB | 5.27 MiB/s, done.
Resolving deltas: 100% (46970/46970), done.
Checking out files: 100% (3992/3992), done.
#使⽤当前最新的3.0版本
cd srs.oschina
git checkout -b 3.0 remotes/origin/3.0release
第⼆步,编译SRS。详细参考Build
cd trunk
./configure
ser config: --x86-x64
Detail config: --prefix=/usr/local/srs --with-hls --with-hds --with-dvr --with-ssl --with-transcode --with-ingest --with-stat --with-http-callback --with-http-server --with-stream-caster --with-http-api --with-librtmp --without-research --without-utest --without-gperf --without-gmc --without-gmd --without-gmp --without-gcp --without-gprof --log-trace --cc=gcc --cxx=g++ --ar=ar --ld=ld --randlib=randlib
SRS_WORKDIR: ., SRS_OBJS_DIR: objs, SRS_OBJS: ./objs, SRS_PLATFORM: Platform-Linux-3.10.0-SRS3
Fast cleanup, if need to do full cleanup, please use: make clean
make -j 4
The build summary:
+------------------------------------------------------------------------------------
For SRS benchmark, gperf, gprof and valgrind, please read:
http://blog.csdn.net/win_lin/article/details/53503869
+------------------------------------------------------------------------------------
|The main server usage: ./objs/srs -c conf/srs.conf, start the srs server
| About HLS, please read https://github.com/ossrs/srs/wiki/v2_CN_DeliveryHLS
| About DVR, please read https://github.com/ossrs/srs/wiki/v3_CN_DVR
| About SSL, please read https://github.com/ossrs/srs/wiki/v1_CN_RTMPHandshake
| About transcoding, please read https://github.com/ossrs/srs/wiki/v3_CN_FFMPEG
| About ingester, please read https://github.com/ossrs/srs/wiki/v1_CN_Ingest
| About http-callback, please read https://github.com/ossrs/srs/wiki/v3_CN_HTTPCallback
| Aoubt http-server, please read https://github.com/ossrs/srs/wiki/v2_CN_HTTPServer
| About http-api, please read https://github.com/ossrs/srs/wiki/v3_CN_HTTPApi
| About stream-caster, please read https://github.com/ossrs/srs/wiki/v2_CN_Streamer
| (Disabled) About VALGRIND, please read https://github.com/ossrs/state-threads/issues/2
+------------------------------------------------------------------------------------
binaries, please read https://github.com/ossrs/srs/wiki/v2_CN_Build
You can:
./objs/srs -c conf/srs.conf
to start the srs server, with config conf/srs.conf.
make[1]: Leaving directory `/vagrant/srs.oschina/trunk'
第三步,编写SRS配置⽂件。详细参考RTMP分发
将以下内容保存为⽂件,譬如 conf/rtmp.conf ,服务器启动时指定该配置⽂件(srs的conf⽂件夹有该⽂件)。
# the config for srs to delivery RTMP
# @see https://github.com/ossrs/srs/wiki/v1_CN_SampleRTMP
# @see full.conf for detail config.
listen 1935;
max_connections 1000;
vhost __defaultVhost__ {
}
第四步,启动SRS。详细参考RTMP分发
./objs/srs -c conf/rtmp.conf
lsof -i :1935
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
srs 14770 root 8u IPv4 23216 0t0 TCP *:macromedia-fcs (LISTEN)
测试srs流媒体服务器
启动推流编码器。详细参考RTMP分发
ffmpeg -re -i test.mp4 -vcodec copy -acodec copy -f flv -y rtmp://192.168.10.224/live/livestream
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 180 fps= 25 q=-1.0 size= 448kB time=00:00:07.10 bitrate= 516.6kbits/s speed= 1x
观看RTMP流。详细参考RTMP分发
ffplay rtmp://192.168.10.224/live/livestream
Duration: N/A, start: 0.010000, bitrate: 777 kb/s
Stream #0:0: Audio: aac (HE-AAC), 44100 Hz, stereo, fltp, 95 kb/s
Stream #0:1: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1920x1080, 681 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
: SRS/3.0.156(OuXuli) 0 aq= 16KB vq= 15KB sq= 0B f=0/2
server_version : 3.0.156
Duration: N/A, start: 0.010000, bitrate: 777 kb/s
Stream #0:0: Audio: aac (HE-AAC), 44100 Hz, stereo, fltp, 95 kb/s
Stream #0:1: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1920x1080, 681 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
17.94 A-V: -0.022 fd= 0 aq= 17KB vq= 16KB sq= 0B f=0/2 3.31 A-V: -0.022 fd= 0 aq= 16KB vq= 15KB sq= 0B f=0/2
备注:请将所有实例的IP地址192.168.10.224
都换成部署的服务器IP地址。
使⽤srs播放器拉流
http://ossrs.net/srs.release/trunk/research/players/srs_player.html