Video trends · 5 min read

RTMP definition

What is RTMP and why do we use it for live streaming?

Find out what RTMP is, why we transcode twice - from RTMP to HLS, and what the future has in store for live streaming

Erikka Innes

February 24, 2021

If you've watched videos, listened to audio, or seen a live stream, you've probably encountered RTMP. RTMP stands for Real-Time Messaging Protocol and it's been used for streaming video and audio on the internet as far back as 2002, which is when Macromedia first created it. In the beginning, RTMP was proprietary, but eventually Adobe bought Macromedia and made RTMP publicly available in 2008.

 

We've been using it for live streaming since 2002. Even now, a common practice is to take data from a source, transcode it to RTMP, and then transcode that to HLS. Why is transcoding twice so common? Why don't we transcode straight to HLS for live streams? Why is RTMP so great? Well, there's a few reasons that we'll get into.

What Does RTMP Do?

First of all, let's review what RTMP does. It uses a persistent (continuous) TCP (Transmission Control Protocol) to stream audio and video from a source to a destination. Using TCP enables it to keep packets of information in the right order when received and viewed - so you don't end up watching the end of your movie or sports game before the middle. Because RTMP uses TCP to travel, it uses a three-way handshake when transporting data. The client (live stream sender) requests a connection from the server it's sending data to. It receives a response, creates a session and transmits the data.

 

RTMP combined with Flash Player became so popular because it was very fast, delivering content with around 5 seconds of latency. Over time, Flash has fallen out of use, but we continue using RTMP.

What are the Benefits and Drawbacks of RTMP?

RTMP is great (even now) because:

  • It's easy to set up an encoder. There are many software based encoders that are cheap, and often hardware solutions are also low cost.
  • It's delivered as a single file, which is easier to manage and process than lots of chunks (looking at you HLS).
  • Because RTMP was the industry standard for so long, it's cheaper to set up and it's easier to support because there are many tools and people who are deeply knowledgeable about how to work with RTMP.
  • It's still one of the fastest solutions out there (don't worry, we'll get to why it isn't THE fastest anymore in a little bit).

 

RTMP is limited because:

  • New standards were developed that allow for HTML5 video streaming and adaptive bitrate delivery (...HLS).
  • It has difficulty getting past firewalls.
  • There are numerous security issues with Flash.
  • Today a lot of browsers don't support RTMP.
  • RTMP doesn't work on mobile devices.
  • The quality of footage is not as high as newer standards.

RTMP for First-Mile Delivery and Last-Mile Delivery

Because of the points I've listed, RTMP is still used, but it's no longer used for everything. You might hear terms for live streaming like 'first-mile delivery' and 'last-mile delivery.' First-mile delivery is what happens right after you transfer footage from a source to an encoder, and the encoder converted it to RTMP. Wherever the encoder sends the RTMP content to is first-mile delivery. Last-mile delivery is the CDN (or sometimes EDGE server that also handles transcoding if you use a decentralized approach) that's going to deliver content to a viewer or user device. Due to the remaining benefits of RTMP, it's used for first-mile delivery. Because of the drawbacks, RTMP is not used for last-mile delivery.

 

In the image, first-mile delivery is the phase from when footage becomes RTMP through to where it is going to be transcoded. Last-mile delivery is after something has been transcoded to HLS and is being delivered to a viewer (Delivery). For the Convert to RTMP section, note that some cameras stream in RTMP, handling this step automatically, some you can convert to RTMP on your computer, and some you can send to another place to be converted.

rtmp, hls, delivery, first mile, last mile delivery

Why is Transcoding Twice So Common?

If you've been reading closely so far, no doubt you guessed why all kinds of places, like Facebook, YouTube, api.video accept RTMP and then do a second transcoding to HLS. It's because RTMP is still a combination of the fastest and most popular (reliable) choice for first-mile delivery. (Note I said it's the combination - there's starting to be faster options, but we don't yet have something that's as popular as RTMP.) It's easy to use, cost effective, well known, and reliable. But it's not good for last-mile delivery. For last-mile delivery, you want a protocol that's going to be fast, good quality, and capable of being handled by mobile, browsers, whatever the situation might be. That's why everyone eventually ends up transcoding to HLS.

 

Some day, RTMP might be replaced by other, newer standards being created, for example SRT (Secure Reliable Transport) is a protocol that addresses some of the issues RTMP faces. SRT preserves video quality better than RTMP, has less trouble getting past firewalls, and is lower latency.

A Little Bit About HLS

HLS (HTTP Live Streaming) is an open standard created by Apple that offers faster and faster options as time goes by. While initially HLS wasn't a great choice for live broadcasting (latency times were often 15-30 seconds), low latency HLS has started solving this problem. With low latency HLS, you can live stream with under 2 seconds of latency, and there are faster options all the time. A great thing about the HLS protocol, is if a receiver doesn't understand something about the HLS it's being sent - say it's missing an extension or similar, it will default to playing whatever form of the HLS it does understand. So while this might mean higher latency in some instances, it means more reliable playback overall.

 

If you have more questions about RTMP or any other video-related information, contact us in the community forum!

Try out more than 80 features for free

Access all the features for as long as you need.
No commitment or credit card required

Video API, simplified

Fully customizable API to manage everything video. From encoding to delivery, in minutes.

Built for Speed

The fastest video encoding platform. Serve your users globally with 140+ points of presence. 

Let end-users upload videos

Finally, an API that allows your end-users to upload videos and start live streams in a few clicks.

Affordable

Volume discounts and usage-based pricing to ensure you don’t exceed your budget.