In this article, we will explain how to reduce latency for RTMP to HLS. But firstly we will keep you inform some of the terms Stream protocols like RTMP and HLS about the used technologies.
What is RTMP (Real Time Messaging Protocol)?
RTMP means Real-Time Messaging Protocol. RTMP is a protocol, created by Macromedia and now owned by Adobe, that provides high-performance transmission of video, audio and data between dedicated streaming servers and Adobe Flash Player across the internet.
Definition of RTMP by Adobe:
“Adobe’s Real-Time Messaging Protocol (RTMP) provides a bidirectional message multiplex service over a reliable stream transport, such as TCP [RFC0793], intended to carry parallel streams of video, audio, and data messages, with associated timing information, between a pair of communicating peers.”
RTMP is created for high-performance transmission of media such as audio and video data.
What is HLS (HTTP Live Streaming)?
The HLS(HTTP Live Streaming) protocol was developed by Apple. The HLS streaming protocol works by chopping MP4 video content into short, 10 second chunks. On an unreliable wireless network, HLS allows the player to use a lower quality video, thus reducing bandwidth usage. HLS videos can be made highly available by providing multiple servers for the same video, allowing the player to swap seamlessly if one of the servers fails.
How to Reduce latency for RTMP -> HLS Streaming?
To reduce the HLS latency there are some parameters and it can be reduced to 8-10 secs for now.
One of the parameters is having HLS segment time lower value which is by default 2 sec and you can decrease this value to have lower latency but then players start to poll server more frequently and it can be a waste of resource usage.
The second critical parameter is sending keyframe in every 2 seconds(This value should consistent with HLS segment time) and it is critical to split videos into 2-sec duration segments. Open Broadcaster Software(OBS) generally sends keyframe for every 10 seconds and the latency will increase to 30 sec because the player needs 3 segments to start to play.
After you have done these adjustments, your delay will be significantly reduced. If you have any questions or comment just send an email to contact at antmedia dot io or fill the contact form.