TodayTools

Real-Time Messaging Protocol

How RTMP works

Sending a live stream to a platform

Donate
L7ApplicationPort 1935TCP
What brings you here?

Watch it happen

How much detail

A streaming app on a laptop goes live: handshake, connect, publish, then audio and video.

Mateo's laptop
Home router
Internet
Live ingest server
CableInternetSetupRequestControlResponseData

6 steps, 19 packets

First up: TCP to 1935. Press Play to watch it happen, one step at a time.

0 of 60/6

What is RTMP?

RTMP is how most streaming apps and hardware encoders push a live video up to a server. The app opens one TCP connection, usually to port 1935, does a short handshake, connects to an application, then publishes with a stream key and sends a steady flow of audio and video messages.

RTMP was created for Flash and is no longer used to play video to viewers. Its job today is ingest: the first mile from the person streaming to a live platform. The platform then repackages the video, usually into HLS, for millions of viewers. RTMPS is the same thing inside TLS.

Think of it like this. RTMP is like a reporter's live line to the studio. The reporter dials in, gives a code word (the stream key) so the studio knows which show it is, and then talks without stopping. The studio, not the reporter, handles broadcasting it to every home.

Step by step

Normal

6 steps

A streaming app on a laptop goes live: handshake, connect, publish, then audio and video.

  1. 1

    TCP to 1935

    Open the connection

    The streaming app opens one TCP connection to the server's RTMP port, 1935. Everything that follows, commands and media, shares it.

  2. 2

    RTMP handshake

    C0 C1, S0 S1 S2, C2

    Both sides send a version byte and 1536 bytes of random data, then echo each other's data back. It proves both really speak RTMP.

  3. 3

    Connect

    Join the app called live

    The connect command names the application on the server. The server sets window and chunk sizes and answers NetConnection.Connect.Success.

  4. 4

    Create a stream

    createStream

    Inside the connection, the app asks for a numbered stream to carry the media.

  5. 5

    Publish

    Send the stream key

    publish carries the stream key, which tells the server whose channel this is. The server answers NetStream.Publish.Start.

  6. 6

    Go live

    Metadata, then audio and video

    The app sends metadata (size, frame rate, codecs), then a stream of video and audio messages. The server repackages them, often as HLS, for viewers.

Wrong stream key

5 steps

One character of the stream key is wrong, so the server refuses to let the app publish.

  1. 1

    TCP

    Connection opens

    The network part works fine.

  2. 2

    Handshake

    Works too

    The RTMP handshake does not check the key.

  3. 3

    Connect

    Still fine

    Connecting to the live app does not check the key either.

  4. 4

    Stream

    createStream works

    The server hands out a stream number as usual.

  5. 5

    Publish refused

    The key is checked here

    The server looks up the stream key and finds no channel. It closes the connection, and some servers send an error status first. The streaming app shows a failed to connect message.

RTMPS

4 steps

The same stream wrapped in TLS on port 443, so the stream key cannot be read on the way.

  1. 1

    TCP to 443

    The HTTPS port

    RTMPS uses port 443, which almost every network allows, and wraps RTMP in TLS.

  2. 2

    TLS handshake

    Check the server, agree keys

    The app checks the server's certificate for live.example.com and both sides agree on keys, just as a browser does for HTTPS.

  3. 3

    RTMP inside

    Same handshake and commands

    Inside the TLS tunnel the RTMP handshake, connect and publish run exactly as before. An onlooker sees only encrypted records.

  4. 4

    Key protected

    Nobody can copy it

    With plain RTMP the stream key crosses the network as readable text. With RTMPS it is encrypted, which is why most live platforms now ask for RTMPS.

Myths and mix-ups

  • RTMP is not dead; it is still the most common way to send a live stream to a platform, even though viewers no longer watch over it.
  • The stream key is not a username; anyone who has it can broadcast on your channel.
  • Plain RTMP is not encrypted, so the stream key can be read on the network; use RTMPS when offered.
  • RTMP is not an internet standard with an RFC; it is a company specification.

Try it yourself

Run these on your own computer to see RTMP at work.

  • Stream a file as if it were live

    ffmpeg -re -i in.mp4 -c:v libx264 -preset veryfast -b:v 3000k -g 60 -c:a aac -b:a 128k -f flv rtmp://live.example.com/live/STREAM_KEY

    Use your platform's server URL and key. -re reads at real speed and -g 60 puts a key frame every 2 seconds at 30 fps.

  • Check the port is reachable

    nc -vz live.example.com 1935

    Succeeded means TCP 1935 is open from your network. Some offices block it; RTMPS on 443 usually works.

  • Watch the handshake

    sudo tcpdump -n -i any tcp port 1935

    Start streaming while it runs. You will see the TCP handshake, two large handshake blocks, then a steady upload.

RTMP at a glance

Layer
Application (7)
Default port
1935 (TCP), RTMPS usually 443
Transport
TCP
Format
Binary chunks, commands in AMF0
Main use today
Sending a live stream to a server (ingest)
Handshake
C0 C1 C2 and S0 S1 S2, 1536 byte blocks
Defined in
Adobe RTMP specification 1.0 (2012), not an RFC

Defined inAdobe RTMP Specification 1.0 (no RFC exists)Enhanced RTMP (for newer codecs, community spec)

Header fields

What RTMP puts in its messages, with example values from the stories above.

RTMP

Chunk stream ID
0Messages are cut into chunks so audio, video and commands can take turns on one connection.
Message type
Handshake (no chunk header)
Message stream ID
00 means the connection itself, not a media stream.
C0 version
3Version 3 is plain RTMP. Other values were used for old encrypted variants.
C1 time
0
C1 random
1528 random bytesThe server must echo these back in S2, which proves it really read them.
S0 version
3
S1
1536 bytes: time, zero, random
S2
Echo of C1Shows the server received the client's random data.
C2
Echo of S1, 1536 bytes

Test yourself

Question 1 of 5Score 0

What is RTMP mainly used for today?

Questions people ask

What is an RTMP server URL and stream key?

The URL, like rtmp://live.example.com/live, says which server and application to connect to. The stream key is a secret name you send in publish that ties the stream to your channel.

What port does RTMP use?

TCP port 1935. RTMPS, the encrypted form, usually uses port 443.

Is RTMP still used?

Yes, for sending live streams from apps and encoders to platforms. It is no longer used to play video to viewers; platforms convert it to HLS or similar.

What is the difference between RTMP and RTMPS?

RTMPS is RTMP wrapped in TLS. The stream key and the video are encrypted on the way, so nobody on the network can copy them.

Why does my stream say failed to connect to server?

The usual causes are a wrong stream key, a wrong server URL, or a network that blocks port 1935. Try RTMPS on port 443 if the platform offers it.

Donate