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.
Please install the SRT library first, refer to SRT for system enviroment setup. SLS can only run on Unix-based operating systems.
git submodule update --init
mkdir build && cd build
cmake ../ -DCMAKE_BUILD_TYPE=Release
make -jBinaries are created in build/bin/ directory.
cd build
./srt_server -h./srt_server -c ../sls.confConfiguration directives are documented on the wiki page.
SRT Live Server supports both SRTLA (bonded cellular) and direct SRT connections on the same server using separate publisher ports:
server {
listen_player 4000; # All streams playable here
listen_publisher 4001; # Direct SRT (OBS, FFmpeg)
listen_publisher_srtla 4002; # SRTLA/bonded (via srtla_rec)
...
}
listen_publisher- For direct SRT connections (standard behavior)listen_publisher_srtla- For SRTLA/bonded connections (enables SRTLA patches automatically)listen_player- Single port for all playback (streams from both publisher types)
Why separate ports? SRTLA bonded connections require special SRT patches that disable dynamic reorder tolerance and periodic NAK reports. Using the wrong setting causes glitching:
- Direct SRT with SRTLA patches = dropped packets
- SRTLA without patches = spurious retransmissions
srt-live-server only supports the MPEG-TS format streaming.
You can push camera live stream using FFmpeg. FFmpeg must be compiled with --enable-libsrt flag - to obtain appropriate binaries, download FFmpeg sourcecode from https://github.com/FFmpeg/FFmpeg, then compile FFmpeg with --enable-libsrt.
srt library is installed in folder /usr/local/lib64.
If ERROR: srt >= 1.3.0 not found using pkg-config occurs during the compilation of FFmpeg, please check the ffbuild/config.log file and follow its instruction to resolve this issue. In most cases it can be resolved by executing the following command:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfigIf error while loading shared libraries: libsrt.so.1 occurs, please add srt library path to the runtime linker configuration file, /etc/ld.so.conf, then refresh the cache by running the comand /sbin/ldconfig as root.
./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/live/test"./ffplay -fflags nobuffer -i "srt://[your.sls.ip]:8080?streamid=live.sls/live/test"OBS supports SRT protocol to publish streams from version v25.0 onwards. To publish SRT stream from OBS to SRT Live Server you can use the following url:
srt://[your.sls.ip]:8080?streamid=uplive.sls/live/test
You can also add a SRT stream as an input source. To do this, add a Media source to OBS, enter mpegts as input format and set the following input URL:
srt://[your.sls.ip]:8080?streamid=live.sls/live/test
There is a test tool in SLS which can be used as a performance test - it has no codec overhead, only network overhead. The SRT Live Client can play a SRT stream to a TS file, or push a TS file to a SRT stream.
./srt_client -r srt://[your.sls.ip]:8080?streamid=uplive.sls/live/test -i [the full file name of exist ts file]./srt_client -r srt://[your.sls.ip]:8080?streamid=live.sls/live/test -o [the full file name of ts file to save]Please refer to: https://hub.docker.com/r/ravenium/srt-live-server
To build a debug build of the SRT Live Server, run the following commands:
git submodule update --init
mkdir build && cd build
cmake ../ -DCMAKE_BUILD_TYPE=Debug
make -j-
SLS refers to the RTMP url format (domain/app/stream_name), example: www.sls.com/live/test. The URL must be set in streamid parameter of SRT, which will be the unique identification a stream.
-
How to distinguish the publisher and player of the same stream? In the configuration file 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.
-
I supplied a simple android app for testing SLS, which can be downloaded from https://github.com/Edward-Wu/liteplayer-srt