Real Time Streaming Protocol
lastmod 2025-04-23created 2015-08-1963 edits
Real Time Streaming Protocol (RTSP) is a communication protocol developed by the IETF in 1998. It is defined in RFC 2326. RTSP is used in streaming systems to control media servers remotely. Its commands, such as "PLAY" and "PAUSE", resemble VCR operations, and it accesses the server based on time information.
It does not transmit the actual media streaming data. Most RTSP servers use the RTP protocol as the transport layer to transmit the actual audio/video data.
Categories
RTSP commands
Compared with HTTP, the RTSP protocol is similar in syntax and operation. However, while HTTP is stateless, RTSP is a stateful protocol. An arbitrary session ID is used each time a session is tracked, and this approach requires a persistent TCP connection. RTSP messages go from the client to the server. If an error occurs on the server, the server sends a response code for the error back to the client. The basic RTSP request messages are as follows, and the default port is 554.
- DESCRIBE
- A DESCRIBE request includes a URL (rtsp://...). The default port 554 is used for both UDP and TCP. The response to DESCRIBE also includes a description of what was requested, usually in SDP format.
- SETUP
- A SETUP request specifies whether a single media stream should be transmitted. This request must be completed before a PLAY request. The request must include the media stream URL and the transport point. The transport point also includes the port numbers for receiving RTP data (audio/video) and RTCP data (meta information).
- PLAY
- A PLAY request plays one or all media streams. Multiple PLAY requests are possible. To play all media streams, an aggregate URL must be included in the request. The playback range can also be specified. If no range is specified, the media plays from beginning to end. If playback is paused, it resumes from the paused position.
- PAUSE
- A PAUSE request pauses one or all media streams. Playback can be restarted with a PLAY request. The request message must include the media stream URL. A range can also be specified when pausing.
- RECORD
- A RECORD request is the command for recording.
- TEARDOWN
- A TEARDOWN request is the command for ending a session; it stops playback of all media streams and releases all sessions tied to the related data on the server.
Packet flow
It seemed that RTSP and RTP could be sent together over a single port, so the packets were inspected with Wireshark.
No. Time Source Destination Protocol Length Info
5 0.000388 127.0.0.1 127.0.0.1 RTSP 141 OPTIONS rtsp://0.0.0.0:8554/live.sdp RTSP/1.0
7 0.003347 127.0.0.1 127.0.0.1 RTSP 257 Reply: RTSP/1.0 200 OK
9 0.004811 127.0.0.1 127.0.0.1 RTSP 167 DESCRIBE rtsp://0.0.0.0:8554/live.sdp RTSP/1.0
11 0.087192 127.0.0.1 127.0.0.1 RTSP/SDP 698 Reply: RTSP/1.0 200 OK
13 0.095190 127.0.0.1 127.0.0.1 RTSP 204 SETUP rtsp://0.0.0.0:8554/live.sdp/stream=0 RTSP/1.0
15 0.096064 127.0.0.1 127.0.0.1 RTSP 281 Reply: RTSP/1.0 200 OK
17 0.097255 127.0.0.1 127.0.0.1 RTSP 185 PLAY rtsp://0.0.0.0:8554/live.sdp/ RTSP/1.0
19 0.098056 127.0.0.1 127.0.0.1 RTSP 275 Reply: RTSP/1.0 200 OK
39 10.419850 127.0.0.1 127.0.0.1 RTSP 167 PAUSE rtsp://0.0.0.0:8554/live.sdp/ RTSP/1.0
41 10.421940 127.0.0.1 127.0.0.1 RTSP 179 Reply: RTSP/1.0 200 OK
43 10.422700 127.0.0.1 127.0.0.1 RTSP 196 SETUP rtsp://0.0.0.0:8554/live.sdp/stream=0 RTSP/1.0
45 10.490884 127.0.0.1 127.0.0.1 RTSP 253 Reply: RTSP/1.0 200 OK
47 10.492739 127.0.0.1 127.0.0.1 RTSP 185 PLAY rtsp://0.0.0.0:8554/live.sdp/ RTSP/1.0
49 10.494810 127.0.0.1 127.0.0.1 RTSP 275 Reply: RTSP/1.0 200 OK
51 10.496769 127.0.0.1 127.0.0.1 RTP 2251 PT=DynamicRTP-Type-96, SSRC=0x19292F8, Seq=3488, Time=1765483086, PT=DynamicRTP-Type-96, SSRC=0x19292F8, Seq=3489, Time=1765483086, PT=DynamicRTP-Type-96, SSRC=0x19292F8, Seq=3490, Time=1765483086, PT=DynamicRTP-Type-96, SSRC=0x19292F8, Seq=3491, Time=1765483086, PT=DynamicRTP-Type-96, SSRC=0x19292F8, Seq=3492, Time=1765483086
53 10.496959 127.0.0.1 127.0.0.1 RTP 2864 PT=DynamicRTP-Type-96, SSRC=0x19292F8, Seq=3493, Time=1765483086, PT=DynamicRTP-Type-96, SSRC=0x19292F8, Seq=3494, Time=1765483086
55 10.497185 127.0.0.1 127.0.0.1 RTP 2864 PT=DynamicRTP-Type-96, SSRC=0x19292F8, Seq=3495, Time=1765483086, PT=DynamicRTP-Type-96, SSRC=0x19292F8, Seq=3496, Time=1765483086
RTP packet No. 55 looks like this:
No. Time Source Destination Protocol Length Info
55 10.497185 127.0.0.1 127.0.0.1 RTP 2864 PT=DynamicRTP-Type-96, SSRC=0x19292F8, Seq=3495, Time=1765483086, PT=DynamicRTP-Type-96, SSRC=0x19292F8, Seq=3496, Time=1765483086
Frame 55: 2864 bytes on wire (22912 bits), 2864 bytes captured (22912 bits) on interface 0
Null/Loopback
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
Transmission Control Protocol, Src Port: 8554, Dst Port: 52409, Seq: 6830, Ack: 854, Len: 2808
RTSP Interleaved Frame, Channel: 0x00, 1400 bytes
Real-Time Transport Protocol
RTSP Interleaved Frame, Channel: 0x00, 1400 bytes
Real-Time Transport Protocol
You can see that RTP packets are delivered through the RTSP Interleaved Frame.
It is not a part of RTSP OPTION response but an option allowing to send RTP by the same TCP channel as controlling RTSP session, seeRFC 2326It is not part of the RTSP OPTION response, but an option that allows sending RTP over the same TCP channel that controls the RTSP session. (seeRFC 2326)
See the "Embedded (Interleaved) Binary Data" section of RFC 2326.
Libraries and examples
Most recommended
- aiortsp - An asyncio-based RTSP library (python)
-
rtsp-simple-server - ready-to-use RTSP / RTMP server and proxy that allows to read, publish and proxy video and audio streams (Go)
- Simple streaming with Docker:
docker run --rm -p 8554:8554 ullaakut/rtspatt - https://github.com/Ullaakut/RTSPAllTheThings
Other recommendations
- PyRTP - Python RTP Library (python) - https://gitlab.com/nickvsnetworking/pyrtp
Local Download
- RFC 2326 - Real Time Streaming Protocol (RTSP)
- https://tools.ietf.org/html/rfc2326
-
Rfc2326.txt - Rfc2326-ko.txt.zip (Google translate: en -> ko)
See also
- RTP
- RTCP
- FFmpeg
- gStreamer
- live555
- JRTPLIB
- WebRTC
- Session Description Protocol (SDP)
- Media Streaming
- Media Streaming#Demo video: Collection of sample video URLs for streaming
- Low Latency Streaming
Favorite site
- Wikipedia (en) description of RTSP
- RFC2326
- TTAE.IF-RFC2326 (Korean translation)
- ICT Terminology Explained - Real Time Streaming Protocol (real-time streaming protocol)
- bcknightt - RTSP(Real Time Streamming Protocol)
- [Recommended] 7 ways to stream RTSP on the page 1 - See Low Latency Streaming.
Guide
- (Network) What is RTSP (Real Time Streaming Protocol)?
- (RTSP) Example of checking IP Camera status with the curl command
- Understanding RTSP (advanced) : Naver Blog - On interleaved mode
- RTSP ALG | Junos OS | Juniper Networks
- Analysis of the RTSPTestServer example - Analyzes the workflow through code
- Point to Point streaming with ffmpeg - Awesome Life
Programming
- [Recommended] Receiving RTSP stream using FFMPEG and OpenCV library
- Issues with OpenCV and RTSP
- Reading a network camera (IP Camera) in OpenCV
- Stackoverflow: OpenCV and Network Cameras -or- How to spy on the neighbors?
- Jetson TK1: Gstreamer application RTSP stream to OPENCV processing
- FFmpeg H.264 RTSP Server Using Live555 (c++/Code on Git)
- Github: FFmpegRTSPServer (H264 RTSP server using FFmpeg and Live555) 2
Tips
- Developer - Oh Seung-wook : Naver Blog - RTSP/RTP summary notes
- VLC Player - RTSP Streaming Server setup (using a file)
References
- Communication protocol
- GStreamer:Examples:RTSP
- GStreamer:Plugins:udpsink
- GStreamer:Plugins:udpsrc
- GStreamer:Python
- GStreamer:RTP RTSP
- Live Streaming
- LIVE555
- Media Streaming
- MediaMTX
- Programming
- Protocol
- PyAV
- Real-Time Messaging Protocol
- Real-time Transport Protocol
- Request for Comments
- RFC 2326
- Rtsp-simple-server
- RTSP:Examples:SimplePythonServer
- Session Description Protocol
- Simple Realtime Server
- SolutionStack:FullStackDeveloper:Curriculum
- SRT
- Streamedian
- Tbag
- WebRTC