赞
踩
目前互联网上的视频直播有两种,一种是基于RTMP协议的直播,这种直播方式上行推流使用RTMP协议,下行播放使用RTMP,HTTP+FLV或者HLS,直播延时一般大于3秒,广泛应用秀场、游戏、赛事和事件直播,满足了对交互要求不高的场景;另一种是WebRTC协议的直播,这种直播方式使用UDP的协议进行流媒体的分发,直播延时小于1秒,同时连接数一般小于10个,主要应用在视频通话、秀场连麦等应用场景。
除了上述两种场景外,还有一种视频直播的场景,就是同时要求低延时和大并发的场景,比如赛事直播、股票信息同步、大班教育等。SRT可以很好地满足上述场景的要求。
SRT:Secure Reliable Transport (SRT) 是一个开源的传输协议架构,基于UDT(可靠UDP协议)实现,主要是优化在不可靠网络上的传输性能。
SRT源代码:https://github.com/Haivision/srt
SRT提供了简单的使用Demo,可以方便使用者进行简单的测试和延时验证。
如果要使用SRT进行大规模并发直播,可以参考 srt-live-serve,这是基于SRT协议的直播服务器处理架构。
srt-live-server 源代码:https://github.com/Edward-Wu/srt-live-server
ReadMe:
srt live server based on srt(Secure, Reliable, Transport)
Introduction
srt-live-server(SLS) is an open source live streaming server for low latency based on Secure Reliable Tranport(SRT). Normally, the latency of transport by SLS is less than 1 second in internet.
Requirements
please install the SRT first, refer to SRT(https://github.com/Haivision/srt) for system enviroment. SLS can only run on OS based on linux, such as mac, centos or ubuntu etc.
Complie
$ sudo make bin file is generated in subdir of 'bin'.
Usage
$ cd bin
1.help information $ ./sls -h
2.run with default config file $ ./sls -c ../sls.conf
Test
SLS only supports the MPEG-TS format streaming. you can push camera live stream by FFMPEG.Please download ffmpeg sourcecode from https://github.com/FFmpeg/FFmpeg, then compile FFMPEG with --enable-libsrt.
1.use ffmpeg to push camera stream with SRT(on my mac):
$ ./ffmpeg -f avfoundation -framerate 30 -i "0:0" -vcodec libx264 -preset ultrafast -tune zerolatency -flags2 local_header -acodec libmp3lame -g 30 -pkt_size 1316 -flush_packets 0 -f mpegts "srt://[your.sls.ip]:8080?streamid=uplive.sls.com/uplive/test"
2.play the SRT stream with ffplay:
./ffplay -fflag nobuffer -i "srt://[your.sls.ip]:8080?streamid=live.sls.com/live/test"
Note:
1.SLS refer to the RTMP url format(domain/app/stream_name), example: www.sls.com/live/test. The url of SLS must be set in streamid parameter of SRT, which will be the unique identification a stream. 2.How to distinguish the publisher and player of the same stream? In conf file, you can set parameters of domain_player/domain_publisher and app_player/app_publisher to resolve it. Importantly, the two combination strings of domain_publisher/app_publisher and domain_player/app_player must not be equal in the same server block.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。