TL;DR: RTSP is a network protocol used to control streaming media servers, allowing users to play, pause, and stop live or recorded video streams in real time over IP networks.
What is RTSP?
RTSP (Real-Time Streaming Protocol) is an application-level protocol used for establishing and controlling media sessions between endpoints, typically between a client (like a video player) and a media server (like a CCTV system or streaming platform). It is commonly used in surveillance systems, live broadcasts, and IP cameras to deliver real-time video and audio streams.
Unlike protocols that handle the actual transmission of data (e.g., RTP), RTSP focuses on stream control—allowing operations like play, pause, seek, and record without handling the data payload itself. It’s often compared to a “remote control” for media streaming.
RTSP typically works alongside RTP (Real-time Transport Protocol) for media delivery and RTCP (RTP Control Protocol) for performance monitoring.
How Does RTSP Work?
- Client Initiation: A client (e.g., a video player or NVR) sends a DESCRIBE request to a media server to get details about the media stream (e.g., codec, format).
- Session Setup: The client sends a SETUP request to establish transport settings (often RTP over UDP or TCP).
- Control Commands: The client uses PLAY, PAUSE, or TEARDOWN commands to control the stream. These commands do not stream the content but instruct the server on how to manage the session.
- Media Delivery: The media is delivered via RTP, not RTSP itself.
- Session Termination: The TEARDOWN command ends the session, releasing resources on the server.
Types of RTSP Implementations
- RTSP over UDP: Offers lower latency and is suitable for real-time applications but may suffer from packet loss.
- RTSP over TCP: More reliable and firewall-friendly, as all data goes through a single connection, but it can introduce higher latency.
- RTSP over HTTP (RTSP tunneling): Encapsulates RTSP within HTTP for compatibility with firewalls or proxies.
- Secure RTSP (RTSPS): RTSP with TLS encryption for secure communication (less common than HTTPS or SRT alternatives).
How to Implement RTSP
- Choose a Media Server: Use a server that supports RTSP, such as:
- VLC Media Player (for testing)
- Wowza Streaming Engine
- FFmpeg (for streaming or transcoding)
- Live555 (open-source RTSP library)
- Configure IP Camera or Source: Ensure the source supports RTSP. Most IP cameras expose an RTSP URL (e.g.,
rtsp://<ip>:<port>/stream). - Use a Compatible Player or Client:
- VLC (
Media > Open Network Stream) - OpenCV (for programmatic access in Python/C++)
- FFmpeg (
ffmpeg -i rtsp://...)
- Network Setup:
- Open ports typically used by RTSP (e.g., 554)
- Use NAT/firewall rules if accessing streams externally
- Secure the Stream: Use authentication (e.g., username/password) and encrypted channels where supported.