SRT server 2:sls (srt live server)

        The SRS server mentioned earlier was unstable when actually testing SRT, so it was switched to sls (srt live server). The actual test is relatively stable, and the code structure is simple, making it very convenient for function expansion and maintenance.

        There are currently two types of live video broadcasts on the Internet. One is live broadcast based on the RTMP protocol. This live broadcast method is used for upstream streaming. RTMP protocol. Downstream playback uses RTMP, HTTP+FLV or HLS. The live broadcast delay is generally greater than 3 seconds. It is widely used in shows, games, competitions and event live broadcasts, meeting scenarios with low interaction requirements; the other is the WebRTC protocol. Live broadcast. This live broadcast method uses the UDP protocol to distribute streaming media. The live broadcast delay is less than 1 second, and the number of simultaneous connections is generally less than 10. It is mainly used in application scenarios such as video calls and live broadcasts.

        In addition to the above two scenarios, there is also a video live broadcast scenario, which is a scenario that requires both low latency and large concurrency, such as event live broadcast, stock information synchronization, large class education, etc. SRT can well meet the requirements of the above scenarios.

SRT:Secure Reliable Transport (SRT) is an open source transmission protocol architecture based on UDT (reliable UDP protocol). It mainly optimizes transmission performance on unreliable networks. .


srt-live-server source code:
srt-live-server: developed based on SLS V1.4.9. 1. Chineseize the document; 2. Support SRT encrypted transmission;icon-default.png?t=N7T8https://gitee.com/smartavs_01/srt-live-server

1 Introduction

  • SRT-live-server (SLS) is a low-latency open source live streaming server based on Secure and Reliable Transport (SRT). Typically, transport latency over Internet SLS is less than 1 second
  • SLS only supports MPEG-TS format streams.
  • SLS draws on the URL format of RTMP (domain/app/stream_name), for example: msos.push/live/test
  • How to distinguish whether the same stream is push or pull? In the conf file, resolve by setting the domain_player/domain_publisher and app_player/app_publisher parameters. Importantly, the two combined strings of domain_publisher/app_publisher and domain_player/app_player cannot be equal in the same server block
  • SLS can only run on Linux-based operating systems, such as mac, centos or ubuntu, etc.

2. Dependence

        Please install SRT first. For system environment, please refer to SRT (https://github.com/Haivision/srt). SLS can only run on Linux-based operating systems, such as mac, centos or ubuntu, etc.

3.Compile

$ sudo make

Bin files are generated in the subdirectory of 'Bin'.

4.Documentation

For configuration files, see the wiki

5. Instructions for use

5.1. Help information

sls -h

5.2. Run by specifying the configuration file

sls -c sls.conf

6. Test

6.1. Test using ffmpeg

Push command

./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]:8100?streamid=msos.push/live/test"

play command

./ffplay -fflags nobuffer -i "srt://[your.sls.ip]:8100?streamid=msos.pull/live/test"

NOTE: You can push live streams via FFMPEG. When compiling FFMPEG source code, you need to enable SRT (--enable-libsrt)

6.2. Test using srt-live-client

There is a testing tool in SLS that can be used for performance testing. Because it has no codec overhead, mainly main network overhead. SLC can save SRT streams as TS files, and can also push TS files to SRT streams.

TS file as input, push SRT stream

./slc -r srt://[your.sls.ip]:8080?streamid=msos.push/live/test -i [TS文件]

SRT stream as input, saved as TS file

./slc -r srt://[your.sls.ip]:8080?streamid=msos.pull/live/test -o [TS文件]

7. Release information

v1.2

  1. Update memory model. In v1.1 the publisher copies the data to each player, in v1.2 each publisher puts the data into an array and all players read the data from that array.
  2. Update publisher and player relationships. The player is not a member of the publisher. The only relationship between them is array data.
  3. Add push and pull functionality. Supports push for all and hash modes, supports loop and hash pull. In cluster mode, you can push a stream to a hash node and pull the stream from the same hash node.
  4. Support hostname:port/app upstream of pull and push

v1.3

  1. Supports reloading.
  2. Add idle_streams_timeout attribute to relays.
  3. Change the license type from GPL to MIT.

v1.4.x

  1. Add HTTP statistics.
  2. Add HTTP event notification, on_connect, on_close.
  3. Add player function to slc (srt-live-client) tool for stress testing.
  4. Add publishing function to slc (srt-live-client) tool, which can push TS files based on DTS.
  5. Modify the HTTP bug when the host is unavailable.
  6. Add remote_ip and remote_port to on_event_url, which can be used as a unique identifier for the player or publisher.
  7. In order to be compatible with MAC systems, TCP monitoring is changed from epoll mode to select mode.
  8. Modify HTTP check for duplicate errors to reopen.
  9. is compatible with OBS stream. OBS supports srt protocol and the version is v25.0 or above. (https://obsproject.com/forum/threads/obs-studio-25-0-release-candidate.116067/)
  10. Add hls recording function.
  11. Update the pid file path from "~/" to "/opt/soft/sls/"
  12. Updated pid file path from "/opt/soft/sls/" to "/tmp/sls" to avoid using root permissions in some cases.
  13. Compatible with SRT v1.4.1, add the set latency method before the set method
  14. Compatible with raspberrypi.

01.05.01

  1. Chinese culture the document;

  2. Support SRT encrypted transmission;

01.05.02

  1. In order to ensure the long-term operation of the program, a watchdog function is added;

Guess you like

Origin blog.csdn.net/weixin_35804181/article/details/133580302