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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

rtsp_rs-0.1.6-cp314-cp314-win_amd64.whl (232.8 kB view details)

Uploaded CPython 3.14Windows x86-64

rtsp_rs-0.1.6-cp314-cp314-manylinux_2_34_x86_64.whl (403.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

rtsp_rs-0.1.6-cp314-cp314-macosx_11_0_arm64.whl (354.7 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

rtsp_rs-0.1.6-cp313-cp313-win_amd64.whl (232.5 kB view details)

Uploaded CPython 3.13Windows x86-64

rtsp_rs-0.1.6-cp313-cp313-manylinux_2_34_x86_64.whl (403.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

rtsp_rs-0.1.6-cp313-cp313-macosx_11_0_arm64.whl (354.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rtsp_rs-0.1.6-cp312-cp312-win_amd64.whl (232.5 kB view details)

Uploaded CPython 3.12Windows x86-64

rtsp_rs-0.1.6-cp312-cp312-manylinux_2_34_x86_64.whl (403.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

rtsp_rs-0.1.6-cp312-cp312-macosx_11_0_arm64.whl (354.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rtsp_rs-0.1.6-cp311-cp311-win_amd64.whl (234.3 kB view details)

Uploaded CPython 3.11Windows x86-64

rtsp_rs-0.1.6-cp311-cp311-manylinux_2_34_x86_64.whl (406.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

rtsp_rs-0.1.6-cp311-cp311-macosx_11_0_arm64.whl (356.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rtsp_rs-0.1.6-cp310-cp310-win_amd64.whl (234.4 kB view details)

Uploaded CPython 3.10Windows x86-64

rtsp_rs-0.1.6-cp310-cp310-manylinux_2_34_x86_64.whl (406.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

rtsp_rs-0.1.6-cp310-cp310-macosx_11_0_arm64.whl (356.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: rtsp_rs-0.1.6-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 232.8 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.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 546667e6bcad62422f61b7195a3efd27267f45e689edb5433afa59c89e852370
MD5 33d4463dbd22c60913306d3b1db97f79
BLAKE2b-256 176c8498cfb47a0af88ddc258736cf8f385c656ec6c66cc912a1b8ba4d015ce7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtsp_rs-0.1.6-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 97d9fc40707c36fbaf03025cbe84a01be9adf7aa4e07117fcedcd75d941d2800
MD5 400fdf532fec3b45f7867489af6ad284
BLAKE2b-256 7b60f07cd5305a0e4f13025a8c84741f815bd402a1a019a2276b5678ada95158

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtsp_rs-0.1.6-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e50a775f85d956dc8b400986d2dcd84e4c0358b61736b941e37422c7dc039984
MD5 19611b197189c67ca74ba1c3aaf6e4af
BLAKE2b-256 5ce62cae88ec861d56cc8b806960c305e8d934fb4f590fd18e5dac16df7f750b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtsp_rs-0.1.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 232.5 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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 cfe4e39c47df68010b62457f04939536de199830e4f754141266ca0c56a433a3
MD5 f9bc094194403448134ced4c84950d74
BLAKE2b-256 06cb7c1b834de9b9d9f9b42216dc021badadb67f3764bad6ccdacba497a9d282

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtsp_rs-0.1.6-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 790c67914cfd789302242efabc6a2a0e8c1e1f9ee3d7d3619f799b64abc1b41e
MD5 2f6f50c97780ca75fcf77909f05cc357
BLAKE2b-256 ddfea57bbd5068a89376c0eec88a126ed4094d0dc054701e6a6edd8466c1b3ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtsp_rs-0.1.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e867218c8ec57de484b7b502fddbe37e5e116cbf407f73a1ae6ea42094b82b24
MD5 5903654c22251be4e7f7b591ad6cfef1
BLAKE2b-256 5f02ba5bb8575852f8d6aa9f4e1f01e7d8ccb3b222dd1d0fb04a732d5abf1c3a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtsp_rs-0.1.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 232.5 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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4dece49e7958a05084a97c00eb8db8b8589de7aefa5f45ee5013c877ac0c0b7c
MD5 51a40b59da18260cb3a9d4bedc48e778
BLAKE2b-256 e377ebfed9522891571f7e619aa3e293408bceb67e1f21e80f803641e1bf0e48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtsp_rs-0.1.6-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8c24e6cdab29b9477801686401ab58b08708b3301a788e3b2e2b1a228cbae49b
MD5 7ad5c7c6921a90e01b6b7898995e110a
BLAKE2b-256 b346bdd6d4195a34b3111e70f0745f225e60c2b6d5a6cb6e225a31715313ff91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtsp_rs-0.1.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 859cacafdaccd54c8316dc83ab6e0e89a8a4f17f79534594a3937c4039e138d8
MD5 4a7869919963565a0e4600b82476abc0
BLAKE2b-256 4e8e9d1011ba08bdde55a58f8f33771f8cceb84cd78d67acaf1f7e607264045b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtsp_rs-0.1.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 234.3 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.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 09fa88ace491bacc4705ba539a4520bcd6a3285edb4720261345605498fdc2db
MD5 c918f08adad67b680af89f80c7a4afa7
BLAKE2b-256 7b21c3cf6a8a92d763e4e297258fe43d28c3b5ab8be797bef3dbe2ff4834c2e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtsp_rs-0.1.6-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b3753e215648e3ca65952770438d595083264ec781c3d51e75c4f7173789e946
MD5 e0758fe5e3dd7c1dab72ed3ec05bc966
BLAKE2b-256 4ac82ea72983e06df4ef1f3120da9a25871ca75e19370210d299ff648d2e8cba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtsp_rs-0.1.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 977ea34e0734ed77017c56036ec184db28b68f71c3094d939c4f87f6e3636485
MD5 2d7558d0c597f06a09939a6853acd12c
BLAKE2b-256 44091967b2c292ba8f855f2162f604279d0ddefb23be704aff7d56e41a43f3e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rtsp_rs-0.1.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 234.4 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.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3ba5201f1e45cb9e66558ab5c6cd60bf064e3208ec7efe46e7c451e02c8613e6
MD5 dd5d2cad038b627d0e8fc4390259a4db
BLAKE2b-256 609e717d1cb6c26d0dfd9cdc3210b58859123ffb2ef536129b3ca7e42589af58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtsp_rs-0.1.6-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 63bd6ab6b11ed9b560d35790f92164017ec5af34b8a1c80d124fb0e430ab3382
MD5 3dc4bf711f8140ad1c073e143d2698a9
BLAKE2b-256 7d48ccb2cefc080c44384c70e68d17e56d269cf774fa89bc94c3a196590c6797

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtsp_rs-0.1.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80343034ee8c98d86e3085958d77107b6574cefc88222a5b4e3065db11223be9
MD5 29394cb0b3e1c1550d3496fa16ea2977
BLAKE2b-256 632ed33d62f20365f77850cdb3649bad358facb461e88d7d54514f10ba65fcdc

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