轉載博客:srt-live-server:一款基於SRT的毫秒級低延時直播服務器

感謝武總:https://blog.csdn.net/wutong_login/article/details/90257697

目前互聯網上的視頻直播有兩種,一種是基於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
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.

 

如有錯誤請指正:

交流請加QQ羣:62054820
QQ:379969650.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章