rtsp-rs
A Rust library for publishing live encoded video over RTSP. Push frames and play the stream with any standard client (VLC, ffplay, GStreamer).
Usable from Rust, Python, or GStreamer.
⚠️ Please read before using
This is a personal, hobby project I built to learn about RTP, RTSP, and streaming. I’m actively evolving it and use it only for my own projects. I have no plans to use or support it in production right now, though I might rely on it there someday if the need arises — so treat it as use at your own risk.
Some of the tests, examples, and documentation in this repo were generated or assisted by AI tools. Treat them as reference material rather than guarantees of correctness.
Status: Pre-release (
v0.x). API may change between versions.
Project structure
crates/
├── core/ # rtsp-rs (crates.io) — core library, use rtsp:: in Rust
├── python/ # rtsp-python — PyO3 bindings → PyPI package rtsp-rs
└── gst/ # gst-rtsp-sink — GStreamer sink plugin
examples/
└── python/ # Python demo (numpy + PyAV)
Quick start
Rust
Add to Cargo.toml: rtsp = { package = "rtsp-rs", version = "0.1" } (the crate is published as rtsp-rs on crates.io; the library is still rtsp in code).
use Server;
let mut server = new;
server.start.unwrap;
// Push H.264 Annex B frames — packetization and delivery are handled internally.
// Timestamp increment = 90000 / fps (e.g. 3000 for 30 fps).
// server.send_frame(&h264_data, 3000).unwrap();
Python
=
# Push encoded H.264 frames directly — no manual packetization needed.
See examples/python/test.py for a full demo that encodes a test pattern with PyAV.
GStreamer
Build and install the plugin:
# Point GStreamer at the built library
Stream a test pattern:
Stream from a webcam (macOS):
Stream from a webcam (Linux):
Stream from a file:
Then connect with any RTSP client:
Building
Requires Rust 1.92+ (latest stable). The GStreamer plugin requires libunwind-dev and libgstreamer1.0-dev (Ubuntu/Debian: sudo apt install libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev).