What is RTMP?

RTMP (Real Time Messaging Protocol) is a proprietary protocol developed by Macromedia for streaming audio, video and data (including metadata such as subtitles and closed captioning) over the Internet between a Flash player and a server. While the primary motivation for RTMP was to be a protocol for playing Flash video, it is also used in other applications, such as the Adobe LiveCycle Data Services ES.

RTMP is a TCP (Transmission Control Protocol)-based protocol which maintains persistent connections and allows low-latency communication. To deliver streams smoothly and transmit as much information as possible, it splits streams into fragments and their size is negotiated dynamically between the client and server while sometimes it is kept unchanged. Fragments from different streams may then be interleaved and multiplexed over a single connection.

However, in practice individual fragments are not typically interleaved.

Instead, the interleaving and multiplexing is done at the packet level, with RTMP packets across several different active channels being interleaved in such a way as to ensure 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. This allows for convenient file-sharing for such uses as archiving, reference and transcription.

The RTMP defines several virtual channels on which packets may be sent and received, and which operate independently of each other. For example, there is a channel for handling RPC (remote procedure call) requests and responses, a channel for video stream data, a channel for audio stream data, and a channel for out-of-band control messages such as fragment size negotiation. During a typical RTMP session, several channels may be active simultaneously at any given time.

When RTMP data is encoded, a packet header is generated. The packet header specifies, amongst other matters, the ID of the channel on which it is to be sent, a timestamp of when it was generated, and the size of the packet’s payload. This header is then followed by the actual payload content of the packet, which is fragmented according to the currently agreed-upon fragment size before it is sent over the connection.

At a higher level, the RTMP encapsulates MP3 or AAC audio and FLV1 video multimedia streams, and can make remote procedure calls using the Action Message Format. Any RPC services required are made asynchronously, using a single client/server request/response model, such that real-time communication is not required.

The most widely adopted RTMP client is Adobe Flash Player, which supports playback of audio and video streamed from RTMP servers when installed as a web browser plug-in.