Generally speaking, the normal delay for RTMP streaming plus FLV playback is 2-3s. If the delay is longer, something is wrong. If you find that the delay is too long, you can perform troubleshooting in the following steps.
The following methods apply only to RTMP and FLV
Alibaba Cloud provides three playback protocols: FLV, HLS and RTMP. Many users adopts the HLS. HLS is a protocol developed by Apple. It is greatly compatible with many browsers and offers cross-terminal support, which makes it the first choice of many users. However, due to the mechanism of the HLS (which is a streaming protocol based on large grain-based TS segments; each segment is more than 5s in duration; and the number of segment is usually 3-4), the total delay is 20-30s. Many users try to reduce delay by setting the TS segment duration. This can effectively reduce delay to some extent, but due to the nature of the protocol, it cannot reduce the delay as much as RTMP or FLV can do.
GOP frame is the video key frame, which is a set of continuous pictures composed of one I frame and multiple B/P frames. It is the basic access unit of video encoder and decoder. Its sequence is repeated to the end of the video. Live service timestamps every frame and then send it to the Internet. It reduces the number of GOP frames and the time it takes the player to load GOP frames. Usually it is configured to be 1-2s.
In general, the server caches parts of the live data and then transmits it through the network to the terminals, which guarantees the smoothness of data transmission. Cached data causes certain live delays. For scenarios where a high level of live service is required, the cache parameter needs to be set lower to achieve a shorter delay.
Of course, when the corresponding cache is small, the data cannot be downloaded timely in case of bad Internet environment, and video lag appears.
Many users adopt the HLS(m3u8) playback protocol and feel that the delay is relatively long. This is normal. Apple’s featured HLS is a streaming protocol based on TS segments. Each segment is more than 5s in duration; and the number of segment is usually 3-4. Therefore, the total delay is generally 20-30s.
This problem can be solved by using FLV as the playback protocol. Note that, if you want to watch live videos on your mobile browser, you have only one choice, that is the HLS(m3u8), because Apple’s Safari browser does not support any other live playback protocols.