Introduction to ENC series encoder SRT protocol for three modes (Listener, Caller, Rendezvous)

What is SRT?

SRT, short for Secure Reliable Transport, is a video delivery protocol that delivers live video and audio over challenging networks.

SRT is an open source low latency video transmission protocol, which has three characteristics: security, reliability and low latency. In terms of security, the SRT supports AES encryption to ensure end-to-end video transmission security. In terms of reliability, SRT ensures transmission stability through forward correction technology (FEC). In terms of low latency, SRT is based on the improved UDT protocol, which solves the problem of high transmission delay of UDT protocol and the complex transmission timing problem of UDP network communication, and can support real-time transmission of high-throughput files and ultra hd videos.

In the eyes of the general public, RTMP is the de facto standard for live Internet video streaming. But the RTMP protocol hasn’t been updated for a long time, and the standard was abandoned after its last update in 2012. The RTMP standard does not support new COdecs such as HEVC or AV1, resulting in a war between manufacturers that cannot communicate with each other. This is why common players such as VLC cannot play H.265 RTMP live streams. The SRT alliance now has more than 250 enterprises and organizations supported by VLC, GSTREAMER, FFMPEG, OBS, VIMX, and others, and it is foreseeable that SRT will replace RTMP.

See https://github.com/Haivision/srt for SRT open source code

Three handshake modes for SRT

Introduction to Handshake Mode.

To establish communication flows, the SRT employs a handshake mechanism in which each device identifies itself as a caller or listener. In some cases, both devices can simultaneously negotiate SRT sessions in what is called Rendezvous mode. If you are configuring SRT streams, you should be aware of these handshake modes:

SRT model What can it do
Caller

Set the source or target device as the initiator of the SRT stream session.

Caller devices must know the IP address of the listener and the port number of its listener. ( The Caller device needs a URL address)

Listener

Set up the device to wait for a request to start an SRT stream session.

The listener device only needs to know that it should listen for the SRT stream on a particular port. (We can simply understand the Listener device to provide a pull flow address.)

Rendezvous

Allows two devices to start SRT sessions on the same port,

Both source and target must be rendezvous mode. (We can simply understand it as the transmission from point A to point B)

As shown in figure 1, when the video encoder is set to listener mode, the receiver (or decoder) is allowed to receive the SRT stream.

As shown in Figure 2, when the video encoder is set to caller mode, the encoder can only send SRT streams to one receiver (or decoder).

As shown in Figure 3, when the video encoder is Rendezvous mode, the encoder can only send SRT streams to one receiver (or decoder).

This mode is designed to perform NAT traversal without port mapping, requiring that both encoder and decoder use the same port. And both must be rendezvous mode; The Rendezvous model was designed to allow two encoders and decoders to communicate in different NAs without the intervention of the NETWORK administrator of the NAT/ firewall. Especially in China, all kinds of NAT are nested, and the routers we use to connect to the Internet basically have no real public IP addresses, but almost all of them are Intranet IP addresses of each carrier, so the basic conditions for Intranet penetration cannot be met.

Listener model

A. Video encoder is set to “listener” mode  

As shown in the picture below, log in the encoder background and select “Stream”-> “SRT Config”->”SRT listener parameter”->”Save”.

Mode: Select “Listener”.

IP: 127.0.0.1(Local IP address)

Port: SRT listener mode listening port, which tells the receiver/decoder (9001 in this example).

Latency: Control buffer parameter, in milliseconds. Default is 50.

B. VMix Sets “caller” mode to receive SRT live streams from encoders  

After the encoder is set by pressing A, we can use vMix to receive data. Assume that the IP address of the encoder is 192.168.1.217. The configuration of vMix is as follows:

Set the SRT parameter table in the red box at step 2 in the upper right corner:

Stream Type: SRT (Caller), Because the encoder is set to listener mode, So vMix must be set to “Caller” mode.

Hostname: Enter the IP address of the encoder. In this example, the IP address of the encoder is 192.168.1.217. Enter 192.168.1.217 in the input box.

Port: enter the SRT listener Port configured for the encoder. In this example, the Port is 9001.

Latency: SRT buffer, in milliseconds, can be different from the encoder’s SRT delay parameter.

C. The OBS is configured as caller mode to receive SRT streams from the encoder

After the encoder is set by pressing A, we can use OBS to receive data. Assume that the IP address of the encoder is 192.168.1.217, and the configuration of OBS is as follows:

OBS is different from vMix. The URL format is srt://Encoder IP:port?mode=caller&latency=ms,According to the configuration of encoder A, the URL we need to enter is srt://192.168.1.217:9001?mode=caller&latency=50.  

Caller model

A. The encoder is configured in Caller mode

As shown in the picture below, log in the encoder background and select “Stream” -> SRT config ->Enter the SRT listener parameter -> Save.

Mode: “Caller”.

IP:IP address of the receiver/decoder. In this example, the receiver IP address is 192.168.1.195,Therefore enter 192.168.1.195.  

Port: SRT listener mode listening port, which tells the receiver/decoder (9001 in this example).

Latency: Control buffer parameter, in milliseconds. Default is 50.

B.VMix is configured as the “listener” mode to receive the Caller mode of the encoder

After the encoder is set according to step A, we can use vMix to receive. At this time, we should first close the previous OBS software, and the configuration of vMix is shown as the figure below:

Enter SRT parameters in step 2 in the upper right corner of the image:

Stream type: SRT (listener); Because the encoder is set to caller mode, vMix must be set to Listener mode.

Port: Specifies the Port that the SRT listener listens to. The Port must be the same as the caller Port of the encoder.

C.OBS configures the “listener” mode as the receiver of the encoder

After the encoder is set according to step A, we can use OBS to receive. If the previous vMix software has been started, we need to stop vMix first. The configuration of OBS is as follows:

Different from vMix,OBS can only receive SRT streams from the encoder using the URL”SRT ://127.0.0.1:port?Mode=listener&latency=ms“; According to the encoder configuration in step A, the URL we need to enter is “SRT ://127.0.0.1:9001?Mode=listener&latency=50“.

Rendezvous model

A. The encoder is configured in “rendezvous” mode

As shown in the picture below, log in the encoder background and select “Stream” -> SRT config ->Enter the SRT rendezvous parameter -> Save.

Mode: “rendezvous”.

IP:NAT public IP address of the receiver/decoder,This example is 121.8.34.9.

Port: SRT Rendezvous port, which must be the same as the SRT rendezvous port on the receiving/decoding side, in this case 9001.

Latency: Control buffer parameter, in milliseconds. Default is 50.

B.VMix is configured as the “rendezvous” mode to receive the “rendezvous” mode of the encoder

After the video encoder is set according to step A, we can use vMix to receive. If we have started OBS, please close OBS first. Assume that the NAT Internet IP address of the encoder is 113.119.199.52, and the configuration of vMix is as follows:

Enter SRT parameters in step 2 in the upper right corner of the image:

Stream type:SRT (Rendezvous), because the encoder is “rendezvous” mode, so vMix must be “rendezvous” mode.

Hostname:Enter the VIDEO encoder NAT Internet IP address. Assume that the ENcoder IP address is 113.119.199.52, enter 113.119.199.52 in the input box.

Port: SRT Rendezvous port, which must be the same as the encoder’s SRT Rendezvous port, in this case 9001.

C.OBS configures the “rendezvous” mode as the receiver of the encoder

After the encoder is set up according to step A, we can use OBS to receive. If vMix has been enabled, disable it first. Assume that the NAT Internet IP address of the encoder is 113.119.199.52, and the configuration of OBS is as follows:

Different from vMix,OBS can only receive SRT streams from the encoder using the URL”srt :// encoder NAT Internet IP:port? mode=rendezvous&latency=ms“; According to the encoder configuration in step A, the URL we need to enter is “srt://113.119.199.52:9001?mode=rendezvous&latency=50“.

How to push LIVE video stream from video encoder to SRT LIVE SERVER(SLS)

A. Introduction of SLS

Srt-live-server (SLS) is a low latency open source real-time streaming server based on Secure and Reliable Transport (SRT). Usually SLS is transmitted over the Internet with a delay of less than 1 second. The source code, see “https://github.com/Edward-Wu/srt-live-server”. Compiling SLS is relatively easy, just follow the instructions, but it is important to note that SLS relies on SRT, so compile SRT first, and then SLS. When compiled and run, the following interface should appear.

B.ENC video codec sets SRT protocol to push live stream to SLS method

ENC series video codec has two modes of pushing stream, one is “Multiple push”, the other is channel output setting “push url”. In the following, we use the multi-platform streaming mode. The SLS streaming address format is “srt://[your.sls.ip]:8080?streamid=uplive.sls.com/live/test “. For example, if the IP address of the SLS server is 192.168.1.122, the IP address of the push flow is “srt://192.168.1.122:8080?streamid=uplive.sls.com/live/test “. As shown in the figure below.

Note: The “Streamid” used for push flow is different from the “Streamid” used for playback. For details, see the “sls.conf” instructions.  

C.The encoder pushes the stream to the SLS in a second way

Set the push-stream mode through channel output. The following is the output setting method. The URL of the push-stream is described in B, as shown in the figure below:  

D.How to play the stream address pushed by the encoder to SLS

a.VMix play 

VMix plays SLS streams in caller mode. Assume that the IP address of the SLS server is 192.168.1.122 and port number is 8080. The configuration of vMix is as follows:

Note: The “Streamid” used for push flow is different from the “Streamid” used for playback. For details, see the “sls.conf” instructions.  

b.OBS play

The OBS plays SLS streams in caller mode. Assume that the IP address of the SLS server is 192.168.1.122 and the port number is 8080.URL is “srt://192.168.1.122:8080?streamid=live.sls.com/live/test&mode=caller“,The configuation of the OBS is as follows:

Note: The “Streamid” used for push flow is different from the “Streamid” used for playback. For details, see the “sls.conf” instructions.