Skip to main content

Python bindings for the RTSP server library — publish live encoded video over RTSP from Python.

Project description

rtsp-rs

Lint Test Release

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 rtsp::Server;

let mut server = Server::new("0.0.0.0:8554");
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

pip install maturin
maturin develop -m crates/python/Cargo.toml
import rtsp

server = rtsp.Server("0.0.0.0:8554")
server.start()

# Push encoded H.264 frames directly — no manual packetization needed.
server.send_frame(h264_bytes, 3000)

See examples/python/test.py for a full demo that encodes a test pattern with PyAV.

GStreamer

Build and install the plugin:

cargo build -p gst-rtsp-sink --release

# Point GStreamer at the built library
export GST_PLUGIN_PATH=$PWD/target/release

Stream a test pattern:

gst-launch-1.0 videotestsrc \
  ! video/x-raw,width=640,height=480,framerate=30/1 \
  ! x264enc tune=zerolatency bitrate=2000 key-int-max=30 \
  ! video/x-h264,stream-format=byte-stream \
  ! rtspserversink port=8554

Stream from a webcam (macOS):

gst-launch-1.0 avfvideosrc \
  ! videoconvert \
  ! x264enc tune=zerolatency bitrate=2000 \
  ! video/x-h264,stream-format=byte-stream \
  ! rtspserversink port=8554

Stream from a webcam (Linux):

gst-launch-1.0 v4l2src device=/dev/video0 \
  ! videoconvert \
  ! x264enc tune=zerolatency bitrate=2000 \
  ! video/x-h264,stream-format=byte-stream \
  ! rtspserversink port=8554

Stream from a file:

gst-launch-1.0 filesrc location=video.mp4 \
  ! qtdemux ! h264parse \
  ! video/x-h264,stream-format=byte-stream \
  ! rtspserversink port=8554

Then connect with any RTSP client:

ffplay rtsp://localhost:8554/stream
vlc rtsp://localhost:8554/stream

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).

cargo build -p rtsp-rs             # Core library
cargo build -p gst-rtsp-sink       # GStreamer plugin
cargo build -p rtsp-python         # Python bindings (needs maturin)
cargo test  --workspace            # All tests
cargo clippy --workspace           # Lint

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rtsp_rs-0.1.8.tar.gz (39.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rtsp_rs-0.1.8-cp314-cp314-win_amd64.whl (230.5 kB view details)

Uploaded CPython 3.14Windows x86-64

rtsp_rs-0.1.8-cp314-cp314-manylinux_2_34_x86_64.whl (402.4 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

rtsp_rs-0.1.8-cp314-cp314-macosx_11_0_arm64.whl (352.7 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rtsp_rs-0.1.8-cp313-cp313-win_amd64.whl (230.9 kB view details)

Uploaded CPython 3.13Windows x86-64

rtsp_rs-0.1.8-cp313-cp313-manylinux_2_34_x86_64.whl (403.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

rtsp_rs-0.1.8-cp313-cp313-macosx_11_0_arm64.whl (352.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rtsp_rs-0.1.8-cp312-cp312-win_amd64.whl (230.8 kB view details)

Uploaded CPython 3.12Windows x86-64

rtsp_rs-0.1.8-cp312-cp312-manylinux_2_34_x86_64.whl (402.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

rtsp_rs-0.1.8-cp312-cp312-macosx_11_0_arm64.whl (352.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rtsp_rs-0.1.8-cp311-cp311-win_amd64.whl (232.8 kB view details)

Uploaded CPython 3.11Windows x86-64

rtsp_rs-0.1.8-cp311-cp311-manylinux_2_34_x86_64.whl (406.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

rtsp_rs-0.1.8-cp311-cp311-macosx_11_0_arm64.whl (354.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rtsp_rs-0.1.8-cp310-cp310-win_amd64.whl (232.9 kB view details)

Uploaded CPython 3.10Windows x86-64

rtsp_rs-0.1.8-cp310-cp310-manylinux_2_34_x86_64.whl (406.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

rtsp_rs-0.1.8-cp310-cp310-macosx_11_0_arm64.whl (354.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file rtsp_rs-0.1.8.tar.gz.

File metadata

  • Download URL: rtsp_rs-0.1.8.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rtsp_rs-0.1.8.tar.gz
Algorithm Hash digest
SHA256 b4d8d21f7c01827fbf8209130713b41d027bdbc7ba96edb4bc597df2b41c920d
MD5 80cb6c071ba9307ab0234b0c5aa2815c
BLAKE2b-256 44cf77ba46c59897c8f46e1bf877c0e4b857ec1a4f4bb86f198f2bb297f72a66

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: rtsp_rs-0.1.8-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 230.5 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rtsp_rs-0.1.8-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 530ed64043951a23f74610d892a0ddd49482fc41d823b4f911eceee285825e63
MD5 079676f5a7ddb16f647eed7d55f0dac3
BLAKE2b-256 a135fa4de52703940e60d1abcba4ebafd9c424a3c9ceb8bc47aded2c6ed6c78f

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rtsp_rs-0.1.8-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a99ed46a57ef6aa21669063f06a986cfdf966079f832867d3e04f658f4a3e793
MD5 7f41872439ac4b0b150ba7ba2cc9e932
BLAKE2b-256 35d8146299a970976abde7271c864171beaef9cac9e523589e709450cd8d540f

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rtsp_rs-0.1.8-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e097144e374b6833a47a404aa58c63ab910a9c5d98fd01692f368a585560342
MD5 0cac67e29a1835c979d94d6eaf16fa7a
BLAKE2b-256 fb557cda03b9df388d65c3721aa4ac8b37b09e9e80a7cd1c667dbfdc4cd6d588

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: rtsp_rs-0.1.8-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 230.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rtsp_rs-0.1.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b46205ec7699b666d3a351e9f262832fa3069c3386b5dcc009792a3bf0409f42
MD5 5398a83c8dc9ec4dfa27d5179fb6adcf
BLAKE2b-256 de9fd0e218f3ce22aeb26374aa5a5ce79a1c2b574eb139259f6f172bb8c108d3

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rtsp_rs-0.1.8-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7b0e7784097a35737020c81ac191735a49cebf4f7f4aae1377a7df674b56a529
MD5 1438b44a045dec5d1f7f870ca92f4dbe
BLAKE2b-256 db997b2c8384c8f2806cbc191515bcc3221ea5bee7b56ba87dcafed566c9e3c5

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rtsp_rs-0.1.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e0ad8de8a742c961aebd32547c3cf9e4383af281d7276234e7fb4a8b40c4045
MD5 50288dadadff0cc775f40d2abba8a58f
BLAKE2b-256 000b6b5bdab5733e488639fdfe0521762591a8d5fd85304de1012719bd7113e4

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rtsp_rs-0.1.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 230.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rtsp_rs-0.1.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6ee8a4d550bb5ed816ef4a281c5b0036687efe5abe67baf49506f60766364001
MD5 a9fee9b5a2d51ffc4522ebd77e762ae9
BLAKE2b-256 6761359a72d5531bd2144983535242e9e3f2727fa674952e611b5c5c7d8e9fd9

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rtsp_rs-0.1.8-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 18f2b2fcd7758530568c9650b20640c07fd89fbf4fce457d9b5a142168749144
MD5 fd68d0a24698ad4b837bfd7addcfa2ae
BLAKE2b-256 ad1d988764c7bba3158b86a0a5d46f8c173d4a7b3c95c92fc5f3d3ebbc1f316d

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rtsp_rs-0.1.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bfecfd7e38fe48bd3b0c2cd6da01531efe2de8d45f050ac5de7433f7e9cfaf8b
MD5 66ff732dfa6a996177aa4b2c86baf268
BLAKE2b-256 f50e0a1171deecea3adceaf84a1f312bc16cbd2d8eadc4a2c450e7d8640c0a7e

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: rtsp_rs-0.1.8-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 232.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rtsp_rs-0.1.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b5eee27da8f3806d57deab84e28ed79f23bb23bb2e46f280ebc942d76a5abb91
MD5 cca58ca831088d7782569195aa15b64e
BLAKE2b-256 5948e1acf18998abfdaed020742c7dc5f78bd9b4bbc31d52ca5663d4dd971d97

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rtsp_rs-0.1.8-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5c95ca59ba50b91d1b0906d8eac12776bf091391cb79603f0eb7b4d29697d9c6
MD5 da17cdfa3d528b9ab8159ca50b288b11
BLAKE2b-256 54a8aa12ff757676c457d063141dc3851f0a75c928675ec951a4ebb1175aa513

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rtsp_rs-0.1.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a0234a1d87bbbde623237092f4cc2234c7fcb78ceb9254d0f53fae051c21580
MD5 0efbaa6c500c737d72751408c4ce8b9e
BLAKE2b-256 7b15157549963cf749a294aec84c0add9c242e5fbdc8f8b31f77d7e4dab70dc9

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: rtsp_rs-0.1.8-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 232.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rtsp_rs-0.1.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 95bacd4366fefbab22e0eeb80a1a35a6dba044de4be31a3c39d506e01397c796
MD5 bd71af4334dcd667b9bac207f099d7c3
BLAKE2b-256 242935c3538c25ea901f3e50fc861a7d71202aae11f20e7c1320b1cb310cf83f

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rtsp_rs-0.1.8-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f6b6fa4237ba27cbf5958d63d7a2de77d50995390c5eaeb30cfe055a810cb75e
MD5 6cb4d060915061b8d5c1be6982b0a306
BLAKE2b-256 c58a2db52f5bdf7e09ae094a1e85ad64679a443e8cb700f904eaf8c3e38d2904

See more details on using hashes here.

File details

Details for the file rtsp_rs-0.1.8-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rtsp_rs-0.1.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 937d34740ae2ef40f8d47c8ce277a016d5bd02687876eecbced01b4650c2f0be
MD5 cb22b24325b5e3ae62c2e032452020f8
BLAKE2b-256 82ad266287430ea5960b8cef411f7c89e5c288a4ebd16fba3382feef45bae8fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page