RTSP
The remote control for streams: describe, set up, play, stop, in HTTP-style text.
DESCRIBE
The first question a player asks. It looks like HTTP, and that is by design.
Whole frame
Text, line by line, just like HTTP. RTSP only controls the stream (describe, set up, play, stop); the video itself travels separately in RTP.
| Field | Offset | Example value | Meaning |
|---|---|---|---|
| Method | Byte 0–7 | DESCRIBE | What the client asks for. DESCRIBE = 'tell me what this stream consists of'. The others: OPTIONS, SETUP, PLAY, PAUSE, TEARDOWN. |
| Space | Byte 8 | 0x20 | Separator. |
| URL | Byte 9–35 | rtsp://cam.example.com/live | The stream to talk about. Note the scheme: rtsp:// (default port 554). RTSP is deliberately a lot like HTTP, but it is stateful: the server remembers a session between requests. |
| Space | Byte 36 | 0x20 | Separator. |
| Version | Byte 37–44 | RTSP/1.0 | The protocol version. |
| CRLF | Byte 45–46 | 0D 0A | End of the request line. |
| CSeq header | Byte 47–55 | CSeq: 2 | A sequence number for requests. The server copies it into its reply so the client can match answers to questions, since several requests may be in flight. |
| Accept header | Byte 56–80 | Accept: application/sdp | The format the client wants the description in: SDP (Session Description Protocol), a plain-text list of streams, codecs and ports. |
| Blank line | Byte 81–82 | 0D 0A | End of the headers. A DESCRIBE has no body. |
Overview
RTSP (Real Time Streaming Protocol) is how a player talks to an IP camera or media server. Its messages look like HTTP (a request line, headers, a blank line) but it controls a session: DESCRIBE, SETUP, PLAY, PAUSE, TEARDOWN. The server remembers state between requests.
It does not carry the video. After PLAY, the camera sends RTP packets to the ports agreed in SETUP.
Key facts
- Transport
- TCP 554 (control)
- Media
- RTP/RTCP over UDP, or interleaved in TCP
- Encoding
- ASCII text, CRLF lines
- Methods
- OPTIONS DESCRIBE SETUP PLAY PAUSE TEARDOWN
- Describes with
- SDP
- Standard
- RFC 2326 / RFC 7826 (2.0)
SETUP
Negotiating where the media will be sent.
Whole frame
The client picks its UDP ports and the server will aim RTP at them. Alternatively the media can be interleaved inside this same TCP connection, which helps through firewalls.
| Field | Offset | Example value | Meaning |
|---|---|---|---|
| Method | Byte 0–4 | SETUP | SETUP = 'prepare to receive this track'. It negotiates the transport: which ports the media will use. |
| Space | Byte 5 | 0x20 | Separator. |
| Track URL | Byte 6–42 | rtsp://cam.example.com/live/trackID=1 | The control URL of one track (taken from the SDP). Video and audio are set up separately. |
| Version and CRLF | Byte 43–53 | RTSP/1.0 | Version, then end of line. |
| CSeq header | Byte 54–62 | CSeq: 3 | Next request number. |
| Transport header | Byte 63–112 | Transport: RTP/AVP;unicast;client_port=5000-5001 | The heart of SETUP: send RTP (profile AVP) as unicast UDP to my ports 5000 (RTP, even) and 5001 (RTCP, odd). The server answers with its own ports and a Session ID. |
| Blank line | Byte 113–114 | 0D 0A | End of the headers. |
A whole session
From first question to TEARDOWN, and where RTP joins in.
Whole exchange
RTSP is the remote control; RTP is the picture. Control over TCP on port 554, media over UDP on ports picked during SETUP.
1What is this stream?
Over a TCP connection to port 554, the player asks for a description.
2Camera describes itself
The reply carries an SDP body: two tracks (video H.264, audio AAC), their payload types and control URLs.
3Prepare the video track
The player proposes UDP ports for RTP and RTCP.
4Session created
The camera confirms and returns its own ports and a Session ID that every following request must carry.
5Start sending
npt=0- means 'from the beginning (or, for live, from now) onwards'.
6Acknowledged
The reply says the first RTP packet's sequence number and timestamp, so the player can sync.
7The video flows
From here the control channel is quiet. Media travels as RTP over UDP to the negotiated port, with RTCP reports on the next port.
8Stop and clean up
TEARDOWN ends the session; the camera stops sending and frees resources.
Where you meet it
- IP cameras, CCTV, NVRs (the usual rtsp://camera/stream URL)
- Media servers and video test streams
- ffmpeg, VLC and GStreamer all speak it: `ffplay rtsp://...`
Watch out for
- A stream that works in VLC but not through a firewall is usually the UDP ports in SETUP: switch the player to RTSP over TCP (interleaved).
- Cameras often limit concurrent sessions. A stuck session with no TEARDOWN blocks a new viewer until it times out.
- Web browsers cannot play RTSP directly: gateways convert it to HLS or WebRTC.
Standards
- RFC 2326: RTSP 1.0
- RFC 7826: RTSP 2.0
- RFC 8866: SDP