High-level RTSP multimedia streaming library, in Rust
Go to file
Andrey Tkachenko 8e9c950389 Fix h265 aggregation packet issue 2023-04-26 12:55:31 +04:00
.github/workflows fixes for workspace split 2022-07-13 11:17:28 -07:00
benches remove StreamContextRef type 2022-05-11 09:27:40 -07:00
examples Add codec specific params 2023-03-28 15:19:38 +04:00
fuzz v0.4.3: upgrade h264-reader crate 2022-09-28 22:12:17 -07:00
player Add H265 Codec 2022-11-14 18:49:42 +04:00
src Fix h265 aggregation packet issue 2023-04-26 12:55:31 +04:00
.gitignore initial commit 2021-06-03 16:49:53 -07:00
CHANGELOG.md Tolerate Ubiquiti's useless `a=fmtp:96\r` in SDP 2022-10-20 23:17:26 -07:00
Cargo.lock Fix h265 aggregation packet issue 2023-04-26 12:55:31 +04:00
Cargo.toml Add H265 Codec 2022-11-14 18:49:42 +04:00
LICENSE-APACHE.txt initial commit 2021-06-03 16:49:53 -07:00
LICENSE-MIT.txt initial commit 2021-06-03 16:49:53 -07:00
README.md WebRTC proxy example (#60) 2022-07-15 16:12:26 -07:00



crates.io version Documentation CI

High-level RTSP multimedia streaming library, in Rust. Good support for ONVIF RTSP/1.0 IP surveillance cameras, as needed by Moonfire NVR. Works around brokenness in cheap closed-source cameras.

Status: In production use in Moonfire NVR. Many missing features.


  • client support
    • basic authentication.
    • digest authentication.
    • RTP over TCP via RTSP interleaved channels.
    • RTP over UDP (experimental).
      • re-order buffer. (Out-of-order packets are dropped now.)
    • RTSP/1.0.
    • RTSP/2.0.
    • SRTP.
    • ONVIF backchannel support (for sending audio).
    • ONVIF replay mode.
    • receiving RTCP Sender Reports (currently only uses the timestamp)
    • sending RTCP Receiver Reports
  • server support
  • I/O modes
    • async with tokio
    • async-std
    • synchronous with std only
  • codec depacketization
    • video: H.264 (RFC 6184)
      • SVC
      • periodic infra refresh
      • multiple slices per picture
      • multiple SPS/PPS
      • interleaved mode
      • AAC output format
      • Annex B output format (#44)
    • audio
      • AAC
        • interleaving
      • RFC 3551 codecs: G.711, G.723, L8/L16
    • application: ONVIF metadata
  • clean, stable API. (See #47.)
  • quality errors
    • detailed error description text.
    • programmatically inspectable error type.
  • good functional testing coverage. (Currently lightly / unevenly tested. Most depacketizers have no tests.)
  • fuzz testing. (In progress.)
  • benchmark

Help welcome!

Getting started

Try the mp4 example. It streams from an RTSP server to a .mp4 file until you hit ctrl-C.

$ cargo run --package client mp4 --url rtsp://ip.address.goes.here/ --username admin --password test out.mp4

Example client

$ cargo run --package client <CMD>

Where CMD:

  • info - Gets info about available streams and exits.
  • mp4 - Writes RTSP streams to mp4 file; exit with Ctrl+C.
  • onvif - Gets realtime onvif metadata if available; exit with Ctrl+C.

Example WebRTC proxy

This allows viewing a H.264 video stream from your browser, with the help of webrtc-rs.

$ cargo run --package webrtc-proxy -- --help


This builds on the whole Rust ecosystem. A couple folks have been especially helpful:

Why "retina"?

It's a working name. Other ideas welcome. I started by looking at dictionary words with the letters R, T, S, and P in order and picking out ones related to video:

$ egrep '^r.*t.*s.*p' /usr/share/dict/words'
retinoscope close but too long, thus retina
retrospect good name for an NVR, but I already picked Moonfire
rotascope misspelling of "rotascope" (animation tool) or archaic name for "gyroscope"?


Your choice of MIT or Apache; see LICENSE-MIT.txt or LICENSE-APACHE, respectively.