video & live streaming

What Is RTMP & How Does It Work?

Video streaming protocol, for example, RTMP, MPEG-DASH, etc., refers to a standardized delivery method for breaking up a video clip into chunks and sending it to the audience by reassembling it. Nowadays, live streaming has emerged as one of the most popular media of entertainment and communication. The video streaming is getting popularity much faster than any other industries in the current world. Therefore, the technologies related to video and video streaming are also changing frequently to keep pace with this rapidly growing industry. We are observing many companies i.e. apple, adobe, etc. have developed their own streaming communication protocols/ video protocols for data transmission so that the file could be lightweight and presentable to the viewers. Most commonly used protocols are TCP, UDP, HLS, MPEG-DASH, RTSP, RTP, RTCP, RTMP, etc. Among them, Real Time Messaging Protocol (RTMP) is a low latency streaming protocol which was first developed for Flash media player for live streaming and also to play on demand. But now it is used by almost all media players.

What is RTMP?

RTMP stands for Real Time Messaging Protocol. It is an Adobe proprietary protocol. It was initially developed by Macromedia Inc. and later on, the company was acquired by Adobe in 2005. RTPM is an application-level protocol designed for delivering on-demand media and live media (i.e live audio, video, and data) over the Internet between a Flash player and RTMP Media Server.

Variations of Real Time Messaging Protocol (RTMP)

RTMP is a TCP based network protocol which maintains persistent connections and allows low-latency communication. There are some variations of RTMP protocol which allow for other communication methods.

RTMPT: RTMPT is a version of RTMP that is tunneled over HTTP.

RTMPS: RTMPS is a version of RTMP that is sent over TLS/SSL for secure connections.

RTMPE: RTMPE is an enhanced and encrypted version of RTMP which uses Adobe’s own security mechanism to ensure real-time cryptographic protection of content.

RTMFP: RTMFP stands for Real-Time Media Flow Protocol which is a secure transport protocol to communicate over the network. RTMFP is a UDP-based protocol, whereas RTMP is TCP-based. It has significant advantages in the efficient delivery of live streaming media, decreasing latency and overhead, increasing voice/audio quality and greater connection reliability.

How does RTMP work?

Real Time Messaging Protocol is a TCP-based network protocol. It provides a bidirectional message multiplex service over a reliable stream transport between a pair of communicating peers (e.g communication between the RTMP Server and Client flash player/Web player/Mobile device).

RTMP work flow diagram
Fig: RTMP work flow Diagram

A Real Time Messaging Protocol connection is established by a handshake between Client Flash player and RTMP Server. For a specific stream, the handshake begins with the request from Flash player then the Server receives that request. After receiving the request all Video and Audio documents are sent to an SWF (Small Web Format) file which can be played in a Flash Player and can be implanted reversely in a Web Page or even Mobile Devices.

For smooth transmission, the streams are broken into smaller parts (fragments) and interleaved before they are sent over the network. The fragmented stream size is configurable. Larger fragment sizes reduce CPU usage, but also commit to larger writes that can delay other content on lower bandwidth connections. Smaller fragments are not good for high bit rate streaming. Fragment size is maintained independently for each direction. However, the splitting fragments are interleaved and multiplexed over a single connection in such a way that each channel meets its bandwidth, latency and other quality-of-service requirements. Packets interleaved in this fashion are treated as indivisible, and are not interleaved on the fragment level. Real Time Messaging Protocol encapsulates video in MP4 and FLV (Flash Video) and audio in AAC and MP3 format.

Pros and Cons of RTMP

Pros

  • Passive protocol (except for RTMFP), does not have limitations with active client connection in comparison with RTP/RTSP.
  • Natively supported by flash players and Adobe’s technological stack
  • Players can maintain a tiny buffer, instead of downloading a video during playback, saving bandwidth.
  • RTMP has broad DRM support. Rights holders are very familiar with the ecosystem.
  • Real Time Messaging Protocol offers robust support for live streaming as well as dynamic streaming where the video quality adjusts automatically to the changes in the available bandwidth.

Cons

  • RTMP only works in Flash and not in HTML5.
  • Some advance codecs are not supported by RTMP like H.265.
  • Most RTMP content is sent via the non-standard port 1935 than HTTP port 80, which makes it vulnerable to getting blocked by (corporate) firewalls. This issue can be prevented by streaming in RTMPT (tunneling over HTTP), which comes at a server performance cost.     
  • Since RTMP data is streamed to the player, that’s why the connection requires higher bandwidth than the video bitrate. As a result, if the connection drops for a couple of seconds, the stream will stutter.

However, Real Time Messaging Protocol is an old and proven streaming protocol and a popular CDN choice for a long time. RTMP is used to avoid latency in communication and save bandwidth. The Flash Player that used to view Video and Audio stream via Real Time Messaging Protocol is also popular and used extensively. Though there are some limitations in streaming with RTMP, still it remains a platform favored by most.