trunk/3rdparty/srs-docs/doc/sample.md
一般来讲,SRS的应用方式有以下几类:
趣直播,一个知识直播平台,目前直播技术为主。
主要流程:
BEGINHO STREAMING PROJECT
I needed solution for pushing streams from origin server to edge server. On origin server all streams are avaliable in multicast (prepared with ffmpeg, h264 in mpegts container). But routing multicast through GRE tunnel to the edge server was very buggy. Any networks hickups in origin-edge route were affecting streams in bad way (freezeing, pixelation and such)... So, I found SRS project and after some reading of docs, I decided to give it a try. Most intereseting feature of SRS to me was a "forward" option. It allows to push all streams you have avaliable on local server (SRS origin) to remote server (SRS edge) with a single line in config file. https://ossrs.net/lts/zh-cn/docs/v4/doc/sample-forward
SRS2 config on origin server:
vhost __defaultVhost__ {
forward xxx:19350;
}
I "told" to ffmpegs on transcoder to publish stream to rtmp, instead of multicast (and yes, I used multicast group as rtmp stream name):
ffmpeg -i udp://xxx:1234 -vcodec libx264 -acodec libfdk_aac \
-metadata service_name="Channel 1" -metadata service_provider="PBS" \
-f flv rtmp://xxx:1935/live/xxx:1234
Tested stream with ffprobe:
[root@encoder1 ~]# ffprobe rtmp://xxx:1935/live/xxx:1234
Input #0, flv, from 'rtmp://xxx:1935/live/xxx:1234':
Metadata:
service_name : Channel 1
service_provider: PBS
encoder : Lavf57.24.100
server : SRS/2.0.209(ZhouGuowen)
srs_primary : SRS/1.0release
srs_authors : winlin,wenjie.zhao
server_version : 2.0.209
Duration: N/A, start: 0.010000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s
Stream #0:1: Video: h264 (High), yuvj420p(pc, bt709), 720x576 [SAR 16:11 DAR 20:11], 24 fps, 24 tbr, 1k tbn
On edge server (example IP xxx), there is a streaming software wich accepts only mpegts as source. So, after receiving rtmp streams from origin server, I needed all streams back to mpegts. SRS have support for several types for output (hls, hds, rtmp, http-flv...) but not mpegts, and i need udp mpegts. Then I asked Winlin for help and he suggested to use SRS3 on edge server, as SRS3 have an feature that SRS2 dont, and thats "exec" option. In SRS3 config, you can use exec option, to call ffmpeg for every incoming stream and convert it to whatever you like. I compiled SRS3 with "--with-ffmpeg" switch (yes, source tree comes with ffmpeg in it) on edge server and...
SRS3 config on edge:
listen 19350;
max_connections 1024;
srs_log_tank file;
srs_log_file ./objs/srs.slave.log;
srs_log_level error;
vhost __defaultVhost__ {
exec {
enabled on;
publish ./objs/ffmpeg/bin/ffmpeg -v quiet -re -i rtmp://127.0.0.1:1935/[app]?vhost=[vhost]/[stream] -c copy -vbsf h264_mp4toannexb -f mpegts "udp://[stream]?localaddr=127.0.0.1&pkt_size=1316";
}
}
FFmpeg will convert all incoming streams to udp mpegts, binding them to lo (127.0.0.1) interface (you dont want multicast to leak all around). SRS3 will use [stream] for udp address, thats why rtmp stream have name by its multicast group on origin server ;) When converting from rtmp to mpegts, "-vbsf h264_mp4toannexb" option is needed! After starting SRS3 with this config, i checked is stream forwarded from master server properly. So, ffprobe again, now on edge server:
[root@edge ~]# ffprobe udp://xxx:1234?localaddr=127.0.0.1
Input #0, mpegts, from 'udp://xxx:5002?localaddr=127.0.0.1':
Duration: N/A, start: 29981.146500, bitrate: 130 kb/s
Program 1
Metadata:
service_name : Channel 1
service_provider: PBS
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuvj420p(pc, bt709), 720x576 [SAR 16:11 DAR 20:11], 24 fps, 24 tbr, 90k tbn, 180k tbc
Stream #0:1[0x101]: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 130 kb/s
I keep adding new streams with ffmpeg at origin server and they are avaliable on slave server after second or two. Its almost a year when I started this origin and edge SRS instances and they are still working without single restart ;)
Many thanks to Winlin!
丽江热线,丽江广播电视台。
2015,又拍云直播部分,在SRS3基础上深度定制的版本。
2015,观止云直播服务器,在SRS3基础上深度定制的版本。
2014.11,高升CDN直播部分,在SRS1的基础上深度定制的版本。
2014.10.10 by 谁变 63110982
verycdn 开始用SRS。
2014.9.13 by 1163202026 11:19:35
目前SRS在测试中,没用过别的,直接上的srs,目前测试下来比较OK,没什么大问题。
2014.7.23 by 阿才(1426953942) 11:04:01
我接触srs才几个月,不敢发表什么意见,只是通过这段时间的学习,觉得这个项目做得相当棒,作者及项目团队工作相当出色,精神非常值得赞赏,目前还在学习中。
2014.7.23 by 随想曲(156530446) 11:04:48
我作为使用者来说,就是这玩意完全当成正规高大上的产品用啦!
2014.7.23 by 湖中鱼(283946467) 11:06:23
me没怎么去具体分析srs只是觉得作者文档写得比较流畅不乏幽默感。但是目前我用到的功能只有rtmp推送直播,及hls这些nginx-rtmp都有,所以还是选择了用老外的东西
2014.7.23 by 我是蝈蝈(383854294) 11:11:59
为什么用SRS?轻便,省资源,有中文说明。SRS那些一站式的脚本与演示demo就能看出来作者是很用心的
2014.7 by 刘重驰
我们目前正在调研 准备用到web秀场 和 移动端流媒体服务上
2014.7 by 大腰怪
2014.7 by 韧
我们的分发服务器用的就是srs,简单易用,稳定性好
我们以前也用过几个分发软件,都没有srs好用,真心的
2014.7 chnvideo编码器内置SRS提供RTMP和HLS拉服务。
2014.4 by 斗破苍穷(154554381)
某工厂的监控系统主要组成:
主要流程包括:
2014.4 by camer(2504296471)
网络摄像机使用hi3518芯片,如何用网页无插件直接观看网络摄像机的流呢?
目前有应用方式如下:
2014.3 by 独孤不孤独(378668966)
一般监控摄像头只支持输出RTMP/RTSP,或者支持RTSP方式读取流。如果想在IOS譬如IPad上看监控的流,怎么办?先部署一套rtmp服务器譬如nginx-rtmp/crtmpd/wowza/red5之类,然后用ffmpeg把rtsp流转成rtmp(或者摄像头直接推流到rtmp服务器),然后让服务器切片成hls输出,在IOS上观看。想想都觉得比较麻烦额,如果摄像头比较多怎么办?一个服务器还扛不住,部署集群?
最简单的方式是什么?摄像头自己支持输出HLS流不就好了?也就是摄像头有个内网ip作为服务器,摄像头给出一个hls的播放地址,IOS客户端譬如IPad可以播放这个HLS地址。
SRS最适合做这个事情,依赖很少,提供arm编译脚本,只需要改下configure的交叉编译工具就可以编译了。
主要流程:
2014.2 by youngcow(5706022)
清华大学每周都会有活动,譬如名家演讲等,使用SRS支持,少量的机器即可满足高并发。
主要流程:
主要的活动包括:
2014.1 by 孙悟空
农场中摄像头支持RTSP访问,FFMPEG将RTSP转换成RTMP推送到SRS,flash客户端播放RTMP流。同时flash客户端可以和控制服务器通信,控制农场的浇水和施肥。
截图:农场的植物开花了,据说种的是萝卜。。。
Winlin 2014.2