SRT public network point-to-point transmission and establishment of SRT streaming media server

SRT is an open source transmission technology, which is based on the UDP protocol. Unlike RTMP, it has the transmission characteristics of high bit rate and low delay, which strengthens the transmission reliability in the complex and unstable network environment. It has no TCP redundancy. The aftereffect, the long-term push delay will not increase. It is not only suitable for LAN transmission like NDI, it is more suitable for signal transmission in the public network environment.

S stands for Secure, which means securely encrypted video streams, R stands for Reliable, which means it has the reliability to recover from severe data packet loss, and T stands for Transport, which means it dynamically adapts to changing network conditions.

During the transmission of audio and video data packets, SRT will detect and adapt to the real-time network conditions between the two transmission points, helping to compensate for jitter and bandwidth fluctuations caused by network congestion. Its error recovery mechanism maximizes Reduce the common data packet loss in Internet connection. SRT supports AES encryption for end-to-end security to ensure that your video stream will not be stolen.

At present, the commonly used VLC, OBS, vMix, larixbroadcaster all support SRT push-pull streaming. This article mainly introduces SRT-based public network point-to-point transmission and the establishment of SRT streaming media distribution server, but the premise is that both the sender and the receiver have a public network. Fixed IP, or the streaming media distribution server has a fixed IP on the public network.

1. SRT's public network point-to-point transmission

The test software adopts the vMix 23 version. vMix supports SRT's multi-channel signal push and pull, and can simply set the SRT parameters, including push-pull delay, password, push-stream encoding format, resolution, bit rate and so on. In order to test the delay, open a webpage showing Beijing time in vMix and compare the delay with Beijing time on the push end.
Insert picture description here
Because the push end has a public network IP, the type is selected as Listener, the port is arbitrarily filled in 4111, the delay is 120ms, no password, h264 encoding, 2M bit rate.
Insert picture description here
The streaming end is DHCP non-fixed IP, select Caller for the streaming type, fill in the IP, port, and delay of the streaming end, and click OK.

At the same time, open a real-time Beijing time webpage on this machine, and you can compare it with the Beijing time signal pushed from the push end to test the delay.
Insert picture description here
As shown in the figure, the left side is the signal transmitted back by the pull stream, and the right side is the web page opened by the machine. You can see that the delay is only 1 second, but because it is not accurate to the millisecond level, it is actually less than 1 second. It is 600-800ms. For RTMP streaming with the same 2M bit rate, the initial delay is about 3 seconds when the default is not optimized, and the long-term streaming will be 8 seconds or more. In the subsequent tests, the push delay of SRT 8M code rate is only 1 second, and the delay of long push stream will not increase stably, which fully reflects the advantages of SRT.

2. Build an SRT distribution server

Download the official source code compression package on the SRT official website https://github.com/Haivision/srt. After downloading, there are installation instructions for different operating systems at the bottom of the home page. The server used this time is the CentOS7 server on Alibaba Cloud, and the configuration is not high. The rental price is affordable.
Insert picture description here
I installed it in the /home/libsrt directory. In the bin folder under this directory, srt-live-transmit is SRT live streaming forwarding, srt-file-transmit is SRT file forwarding, and srt-ffplay is SRT streaming playback (only in Available in operating systems with a graphical interface). The SRT distribution server uses srt-live-transmit, and the opening method is also very simple:

cd /home/libsrt/bin
./srt-live-transmit srt://:4201 srt://:4202 -v

Insert picture description here
Here, port 4201 of the local IP is monitored as the SRT stream input port, and port 4202 of the local IP is the SRT stream output port. Then in vMix, select the push end as the caller, fill in the server IP and 4201 port, and pull the stream. Also select as caller, fill in server IP and 4202 port.
Insert picture description here
Here on the right is the final output of vMix, the SRT distribution server built by the push stream, 1080p resolution, 2M bit rate, and delay set to 100ms. On the left is the screen pulled back from the SRT distribution server, and the delay is also set to 100ms. It can be seen that when the public network SRT distribution server does forwarding, the delay of one push and pull is only 600ms.

In the subsequent tests, the bit rate was increased to 10M, and the one-push-pull delay was only 1 second. It can be seen that SRT is still quite excellent under the requirements of high image quality and low latency. At the same time, with the SRT distribution server on the cloud, the sender and receiver are no longer limited by the fixed IP of the public network, and the actual use scenario becomes very flexible.

Guess you like

Origin blog.csdn.net/weixin_42550813/article/details/106374524