Edge Academy

Definition

Real-Time Messaging Protocol (RTMP) is a protocol for streaming audio, video, and data over the Internet.

Overview

After Adobe acquired the company that created RTMP, Macromedia, they released a partial version for public use. Like a lot of source code released to the public, Real-Time Messaging Protocol has multiple variations:

  • RTMPS – Uses a Secure Sockets Layer (SSL) connection.
  • RTMPE – Encrypted with Adobe’s security mechanism.
  • RTMPT – Encapsulated within HTTP requests to travel through firewalls.
  • RTMFP – Uses UDP instead of TCP.

Each type of Real-Time Messaging Protocol is primarily used for three different processes:

How Real-Time Messaging Protocol Works

RTMP is a TCP-based protocol designed to maintain low-latency connections for audio and video streaming. To increase the amount of data that can be smoothly transmitted, streams are split into smaller fragments called packets. RTMP also defines several virtual channels that work independently of each other for packets to be delivered on. This means that video and audio are delivered on separate channels simultaneously.

The 3-step process

At a high level, Real-Time Messaging Protocol works as a three-step process.

Step 1: The handshake

Once RTMP establishes a TCP connection it performs a handshake by exchanging three packets between the client and the server. These packets are called chunks.

The process looks like this:

  • The client sends over a chunk to tell the server which protocol version it is using.
  • Without waiting for a response, the client sends another chunk with a timestamp.
  • The server responds with an echo of the chunks it receives, this time including a timestamp of the time it received them.
  • The client sends one final packet that is a copy of the timestamp packet and the server returns it.
  • Once the final packet exchange is complete, the handshake is considered complete.

Step 2: The connection

The client and server can now begin negotiating a connection through Action Message Format (AMF) messages. For example, the client would send over a connect request that looks like this:

(Invoke) "connect"
(Transaction ID) 1.0
(Object1) { app: "sample", flashVer: "MAC 10,2,153,2", swfUrl: null,
 tcUrl: "rtmpt://127.0.0.1/sample ", fpad: false,
 capabilities: 9947.75 , audioCodecs: 3191, videoCodecs: 252,
 videoFunction: 1 , pageUrl: null, objectEncoding: 3.0 }

And the server will receive the request and respond with the appropriate message sequence:

(Invoke) "_result"
(transaction ID) 1.0
(Object1) { fmsVer: "FMS/3,5,5,2004", capabilities: 31.0, mode: 1.0 }
(Object2) { level: "status", code: "NetConnection.Connect.Success",
 description: "Connection succeeded",
 data: (array) { version: "3,5,5,2004" },
 clientId: 1728724019, objectEncoding: 3.0 }

Step 3: The stream

The client can now start a video or audio stream by sending three messages to the server: createStream, ping, and play.

Examples of Real-Time Messaging Protocol

You can create a Real-Time Messaging Protocol live stream by leveraging software such as Simple-RTMP-Server (SRS) on your own server or a provider such as ManyCam. The standard method of setting up an RTMP live stream requires at least one server for your streaming software and a connection to a separate content delivery network.

The primary issue with this standard setup is the opportunity for increased latency as your stream travels from your server to your CDN before being distributed to your viewers. StackPath solves this problem with edge compute.

Real-Time Messaging Protocol on the edge

As discussed, a media server is an absolute necessity if you want to leverage RTMP for livestreaming. Wowza Streaming Engine, for example, is a widely used streaming software for live and on-demand video that can be installed on any server—such as one of StackPath’s virtual machines or containers.

Your streaming engine will ingest an RTMP live stream and then provide your CDN with cacheable chunks, usually around 10 seconds.

As traffic travels to your CDN and out to viewers, latency is created. With StackPath edge compute, your media servers are already on the edge and can deliver content without the need for a content delivery network. By leveraging our virtual machines or containers on the edge you can reduce latency and costs.

Key Takeaways

  • Real-Time Messaging Protocol (RTMP) is an open source protocol owned by Adobe that’s designed to stream audio and video by maintaining low latency connections.
  • Clients use a handshake to form a connection with an RTMP server which then allows users to stream video and audio.
  • RTMP livestreaming generally requires a media server and a content delivery network, but by leveraging StackPath edge compute you can remove the need for a CDN and drastically reduce latency and costs.
Request Demo

Have questions? Chat now with the live chat button on this page or request a demo from our edge experts.

Request a Demo
Get an Advantage

Stay informed of the latest edge news, updates and solutions.

Subscribe