In this article we are going to learn about HLS and RTMP and which one on these protocols is best for streaming
Here is what you are going to learn in this article
- Understanding Streaming Protocols
- What are streaming protocols?
- How do protocols affect content delivery?
- The role of protocols in video streaming
- Ensuring smooth playback
- Managing data transmission
- What is RTMP?
- Overview of RTMP
- History and development
- How does RTMP work?
- Persistent connection over TCP
- Real time data transmission
- Advantages of RTMP
- Low latency
- Efficient bandwidth usage
- Mature Ecosystem
- Disadvantages of RTMP
- Limited Device Compatibility
- Overview of RTMP
- Security Concerns
- Declining Support
- What is HLS (HTTP live streaming)?
- How does HLS work?
- HTTP based protocol
- Uses adaptive bitrate streaming
- Advantages of HLS
- Highly Compatible
- Adaptive Bitrate streaming
- Enhanced security
- Disadvantages of HLS
- High Latency
- Increased server load
- How does HLS work?
- HLS Vs RTMP: A comparison
- Latency
- Device Compatibility
- Adaptive Streaming
- Security
- Scalability
- Use-Cases
- Emerging Alternatives
- WebRTC (Web Real-Time Communication)
- Overview and Benefits of WebRTC
- Comparison with HLS and RTMP
- MPEG-DASH
- Overview of MPEG-DASH
- How it compares
- WebRTC (Web Real-Time Communication)
- Converting between Protocols
- Converting RTMP to HLS
- Converting HLS to RTMP
- How to choose right protocol for your use-case
- Access your needs
- Consider the type of content you have
- Evaluate the Resources
- Conclusion and FAQ
- Can I use both HLS and RTMP together?
- Is RTMP still relevant today?
- What is the future of streaming protocols?
Overview of HLS and RTMP
Brief introduction to both the protocols
RTMP (Real Time Messaging protocol):
RTMP was developed by Adobe systems for transmitting audio, video and data over the internet using servers and flash player
RTMP was designed with low latency communication in mind and it is widely used for live streaming and broadcasting applications
RTMP uses the TCP protocol and is known for having persistent communication and stream media in real time.
HLS (HTTP Live Streaming):
HLS or the HTTP live streaming protocol was developed by Apple, the speciality of this protocol is that it breaks down the content into small chunks and transmits them over the internet using HTTP based file segments
These file based segments are then sent to the client devices using standard servers and played back in sequence by the client
Hence, HLS has adaptive bit rate streaming, allowing the stream quality to adjust dynamically based on the client device network conditions and device capabilities
Understanding Streaming Protocols
What are Streaming Protocols
Steaming protocols are a set of rules and standards, these rules dictate how the audio and video is transmitted over the internet from the server to the client devices.
The rules include methods for packaging, transmitting and unpacking the audio and video content.
These rules make sure that the data reaches the client devices efficiently and in correct order
How do Streaming protocols affect Content Delivery
- Quality of service: These affect the buffering and playback of the video and thus the reliability and consistency of the video stream
- Latency: Latency is the time delay between when the stream is sent form the server and when it is received by the client device
- Compatibility: Does the protocol require any additional software or plugins to be installed in client devices in order to play the video stream or not
- Security: Protocols may have different levels of encryption and protection against unauthorized access
Managing Data transmission
- Segmenting data: Segmenting data is the process of breaking down large video files into small chunks / segments of data, that are then transmitted over the internet connection
- Packetizing the data: Encapsulating the data in to packets with proper headers and meta data that is required to transmit them over the internet
- Transport mechanism: Utilizing the underlying internet protocols like TCP and UDP to send the data through the internet
- Handling different network conditions: Implementing various strategies in order to cope with varying internet conditions like bandwidth congestion and latency
What is RTMP (Real Time Messaging Protocol)
How does RTMP work
RTMP or the Real Time Messaging protocol is developed by Adobe. The protocol was developed to transmit audio and video data from the server to the client running adobe flash player
RTMP operates a persistent TCP connection, which allows for a continuous and reliable data transfer between client and server
Because of this consistent connection the packets can be send reliably and in order without packet loss
The RTMP splits the data into small segments and then stream them in a sequence thus enabling real time data transmission with minimum delay
Thus making RTMP best for real time data transmission and live steaming when low latency is important consideration
Advantages of RTMP
- Low Latency: The standout feature of RTMP is low latency, for this very reason it is the recommended protocol to be used in situations like live streaming. Where the delay in the broadcast is not tolerated like sporting events or financial data
- Efficient Bandwidth usage: The RTMP allows for optimizing the bandwidth usage by maintaining a steady flow of data over a persistent TCP connection.
This efficient use of bandwidth makes sure a smooth video and reduce buffering even on networks with limited capacity.
- Mature Ecosystem
RTMP has been around more than 10 years now and thus has a mature ecosystem with a wide variety of tools , servers, software and support available to support the protocol
this includes many open source media servers encoders and players and ample resources for troubleshooting and optimizing streaming setups
Disadvantages of RTMP
- Limited Device compatibility: An important drawback of the RTMP protocol is its dependence on the Adobe flash player.
The Adobe flash player has been deprecated and is no longer under active development
Most modern browsers are also dropping their support for the adobe flash player and almost no mobile devices support the flash player today
All of these devices and browsers have transitioned to HTML5 based technologies
- Security concerns
RTMP does not natively support secure data transmission over HTTPS. Thus to safely send the streams over the internet and encrypt them you need to use the RTMPS and implementing this adds complexity and this is a cause of concern for many content providers that want to protect proprietary content
- Declining Support
The industry is shifting towards HTML5 based streaming solutions and protocols such as HLS and MPEG-DASH. These protocols are compatible with HTML5 based players that are universally available in mobile devices as well as all the browsers
The flash has been depreciated and hence the whole industry is moving towards modern protocols that offer better support, security and features that these content providers need.
What is HLS (HTTP Live Streaming)
How does HLS work
HLS is a streaming protocol that was developed by Apple Inc for live streaming.
It was designed to live stream to IOS devices with the realease of IOS 3. Initially the apple tailored it specifically for IOS devices but later on open sourced it for everyone to use in mobile streaming. With time the HLS transcended it scope and is now widely used across TVS, desktop computers and browsers.
Advantages of HLS
- Highly compatible:
HLS is universally supported on most browsers and devices, including being natively supported in IOS and Android devices
Most major browsers like Chrome, Safari, Firefox and Edge also support HLS. This widespread support means you can reach a large audience without worrying about device specific needs and installation of any other software on client devices.
HLS also runs on the HTML5 technology thus do not require any additional plugins or external software to work. As HTML5 is supported on all the browsers so is HLS
- Adaptive bitrate streaming:
HLS has adaptive bit rate streaming technology, which dynamically adjusts the quality of the video stream according to the client device network capability
This makes sure a smooth and buffer free experience for the client devices even in changing network conditions
The HLS can deliver the highest possible quality of video stream that the client device can handle according to the network conditions and the device processing capability
thus it provides the best viewing experience to every user.
- Enhanced Security:
HLS supports secure streaming over HTTPS which encrypts the video stream between the server and the client, thus securing it from tempering and interception
HLS can also integrate with DRM protection that is Digital rights management this helps the content providers to enforce access controls and restrict un authorized distribution of their content
This is useful in industries like education, corporate communication, entertainment where content protection is important.
Disadvantages of HLS
- Higher latency:
A drawback of HLS is the higher latency as compared to the RTMP or the WebRTC protocol. A typical latency of 15-30 seconds is expected.
This latency refers to the delay between when a live event is being recorded and then when it reaches the audiences screen
This latency is there because of the processing that is required to segment the video into small chunks that are then send over the internet using HTTP protocol
and then reassembled at the client end and played on the screen
- Not suitable for real time content:
The high latency makes HLS not suitable for content that is of real time in nature.
For example, live events like sports, auctions, interactive online gaming here user response in necessary and delay will cause a bad experience for the user.
- Increased server load:
The segmenting of files in small chunks requires processing power and for this reason HLS increases server load.
The process creates a load on the server and thus increases the hosting costs for content in the cloud.
This could be a concern if you are streaming to millions of users worldwide
HLS also requires some processing on the client device as well and as such very weak devices struggle with HLS protocol. This was a problem in the earlier days when mobile processing power was at a premium
HLS vs RTMP: A Direct Comparison
Let us delve deeper into a direct comparison between HLS and RTMP. We will consider factors like latency, device compatibility, adaptive streaming, security and scalability among other things
Latency
RTMP offers Lower Latency
RTMP is renowned for its low latency streaming capability, it achieves latency as low as 2-5 seconds
The real time transmission capability is important for applications like live streaming, live auctions, online gaming that activities that require immediate user interaction
The RTMP protocol uses a consistent TCP connection that allows for continuous flow of data without any delays introduced by segmenting and buffering
HLS has higher Latency
HLS has higher latency as compared to RTMP, the time delay that HLS has is around 15 - 30 seconds or more
This delay is the result of processing the video streams and converting them into small segments that are then sent through the internet to client devices
These segments are then again joined together on the client end and created into a smooth stream of video which again requires processing and introduces delay
This kind of latency is acceptable in on demand content but can hinder live streaming and other such use cases where immediate user feedback and interactions is necessary
Device Compatibility
HLS has wider compatibility
HLS has a wider compatibility as compared to RTMP protocol. This is because HLS runs on the HTTP protocol which has near universal compatibility
All the growers use HTTP protocol plus devices like Android and IOS have built in capability to use the HLS protocol to play video
A host of devices including smart TVs and streaming devices are compatible with the HLS protocol
HLS works seamlessly with HTML5 players without the need to install any additional plugins or software. Thus HLS has wide compatibility and ability to reach wide variety of audiences.
Adaptive Streaming
HLS supports adaptive streaming
HLS has native support for adaptive bit rate streaming thus allowing the server to send different quality streams of the same content to different users according to their network capabilities
If for example the network is good the client device might select the best quality stream that is available and if on the other hand the network quality is bad a somewhat lower quality stream will be selected. This is done in order to provide the video stream without buffering
Thus the viewer gets the best quality video experience considering the device capability and the network quality the user has available
RTMP does not have adaptive bit rate streaming
RTMP does not have adaptive bit rate streaming, RTMP has fixed quality streams which means that if the user does not have a good enough internet there will be buffering.
There are workarounds available for this like you can manually select the lower quality stream in case of bad internet connectivity, these are not standardized or not as smooth as HLS which automatically selects the best stream.
Security
HLS provides better security
HLS provides better security through HTTPS and incorporates encryption using the AES-128 bit encryption for video segments
HLS can also easily integrate with DRM or Digital Copyrights Management systems to protect from unauthorized access or piracy
These security features makes the HLS the default choice for video on demand services that want the integrity and confidentiality of the video streams
RTMP is less secure over the internet
RTMP does not natively support encryption and secure transmission with HTTPS. Without the use of built in encryption measures the RTMP is susceptible to man in the middle attacks, piracy and other types of hacks
This leads to potentially exposing sensitive content in the hands of pirates and hackers. There are secure variants of RTMP available like RTMPS which is RTMP over SSL/TLS.
But these are not widely supported and adds to the complexity of building with RTMP
Scalability
HLS is more scalable
The HLS use the HTTP protocol and infrastructure for content delivery, this makes the HLS highly scalable
Content Delivery Networks or CDNs can easily distribute the HLS streams globally, the CDNs can also cache the streams near to the users location and reduce the lag time and server load
The use of HTTP allows the HLS use the optimizations built into the existing server infrastructure and load balancing techniques thus helping in handling of large number of users easily
Use-Cases
RTMP
Live interactive Broadcasts:
Live broadcasts where there is user interaction involved like in auctions or interactive gaming or interactive seminars etc
Video Conferencing:
You can have video conferencing with RTMP protocol with a large number of viewers
Closed networks
Streaming in controlled environments where compatibility issues are minimal can be done.
HLS
Broad audience reach:
HLS is a good protocol for content providers that want to reach wide audiences that have a variety of devices and platforms and are located all around the world.
On demand content:
Users such as online content providers like prime video and netflix use the HLS protocol
Enhanced user experience:
The security features along with the adaptive bit rate streaming allows for enhanced user experience
Emerging Alternatives: WebRTC, MPEG-DASH
New protocols are emerging to cater to new use cases and to address the limitations of existing protocols such as HLS and RTMP
These protocols include WebRTC and MPEG-DASH. These protocols offer unique benefits in order to cater to modern streaming requirements
WebRTC Web Real Time Communication
WebRTC is an open source project that enables real time communication of audio, video and data between devices and web browsers but also can stream from server to client as well
WebRTC allows peer to peer communication without the need to install any additional software or plugins
It uses the standard web API as technology thus making it easy and accessible way to implement in modern web applications
Ultra low latency
One of the best features of webrtc is the ultra low latency capability. WebRTC can achieve latency in the range of a few miliseconds
Many webrtc applications require TURN servers to work in order to traverse the NAT. Although WebRTC can work without the turn servers in local network but in order to communicate with devices across the internet many times it requires a turn server
If you are looking for a TURN server provider for your WebRTC applications we suggest Metered TURN server
Metered TURN Server
- API: TURN server management with powerful API. You can do things like Add/ Remove credentials via the API, Retrieve Per User / Credentials and User metrics via the API, Enable/ Disable credentials via the API, Retrive Usage data by date via the API.
- Global Geo-Location targeting: Automatically directs traffic to the nearest servers, for lowest possible latency and highest quality performance. less than 50 ms latency anywhere around the world
- Servers in all the Regions of the world: Toronto, Miami, San Francisco, Amsterdam, London, Frankfurt, Bangalore, Singapore,Sydney, Seoul, Dallas, New York
- Low Latency: less than 50 ms latency, anywhere across the world.
- Cost-Effective: pay-as-you-go pricing with bandwidth and volume discounts available.
- Easy Administration: Get usage logs, emails when accounts reach threshold limits, billing records and email and phone support.
- Standards Compliant: Conforms to RFCs 5389, 5769, 5780, 5766, 6062, 6156, 5245, 5768, 6336, 6544, 5928 over UDP, TCP, TLS, and DTLS.
- Multi‑Tenancy: Create multiple credentials and separate the usage by customer, or different apps. Get Usage logs, billing records and threshold alerts.
- Enterprise Reliability: 99.999% Uptime with SLA.
- Enterprise Scale: With no limit on concurrent traffic or total traffic. Metered TURN Servers provide Enterprise Scalability
- 5 GB/mo Free: Get 5 GB every month free TURN server usage with the Free Plan
- Runs on port 80 and 443
- Support TURNS + SSL to allow connections through deep packet inspection firewalls.
- Supports both TCP and UDP
- Free Unlimited STUN
WebRTC can be used in a variety of applications including
- video conferencing
- Artificial intelligence
- Online gaming