Think about the awkward moment when you’re video-chatting with a friend and suddenly the picture freezes and the sound starts to stutter. In order to avoid these situations, in the development process of video dating app, what aspects can be technically optimized for delay? Here is a brief introduction.

First, coding optimization

First, make sure Codec turns on the lowest latency setting. Codec generally has low-latency optimized switches, especially for H.264. In addition, encoders generally have delay caused by code control, which is regarded as the cache between the encoder and decoder bit stream. Setting it as small as possible can also reduce the delay without affecting the video quality. Also, it is best not to use the video compression format MJPEG, at least use the MPEG4 video compression format without B frames, preferably using a simple optimization such as H.264 Baseline Profile. Such a simple optimization reduces latency because it is able to encode full frame rate video at a lower bit rate.

2. Optimization of transmission protocol

Use RTMP instead of HLS for transmission between server nodes and nodes to reduce the overall transmission delay. If the end user uses RTMP for playback, transcoding should be performed at the receiving node close to the push stream, so that the transmitted video stream is smaller than the original video stream. In addition, if necessary, TCP can be replaced by customized UDP to reduce the delay by eliminating packet loss and retransmission in weak network links.

Third, transmission network optimization

Cache the current GOP in the server node and cooperate with the player to optimize the start time of the video. In addition, the server can record the second-level frame rate and bit rate of each video stream flowing to each link in real time, so as to monitor the fluctuation of bit rate and frame rate in real time, and then adjust it according to this situation.

Fourth, push stream, play optimization

The cache control of the player side also has a great influence on the first start delay of the video. If only the first start delay is optimized, the data can be decoded immediately when it arrives in the case of 0 cache. However, in order to eliminate the influence caused by network jitter in the weak network environment, it is necessary to set a certain cache, so it is necessary to find a balance between the stability of live broadcast and the optimization of the first start delay, and adjust the value of the optimization buffer size.

In addition to the strategy of dynamically adjusting the buffer size, the real-time monitored network information can also be used to dynamically adjust the bit rate in the playback process to reduce the bit rate and reduce the delay when the network bandwidth is insufficient.

The above is the technical optimization that can be made for delay in the development of video dating app. If you have any questions about this, please leave a message to xiaobian.