streamer-rs
⚠️ Work in progress — not stable for production use. APIs will change without notice.
Backend-agnostic async library for streaming audio and video in Rust.
Defines a clean trait layer over media backends so application code stays independent of any particular codec or hardware vendor. GStreamer is the first implementation; FFmpeg and V4L2/VAAPI are planned.
Features
| Feature | Description | Status |
|---|---|---|
gstreamer |
GStreamer backend (capture, encode, decode, pipeline) | ✅ Available |
ffmpeg |
FFmpeg backend | 🗓 Planned |
vaapi |
V4L2 / VAAPI hardware acceleration | 🗓 Planned |
The gstreamer feature is enabled by default.
System requirements
The gstreamer feature requires GStreamer development libraries:
# Debian / Ubuntu
# macOS
To build without any system dependencies:
Installation
[]
= "0.1"
# Without GStreamer (core traits only):
= { = "0.1", = false }
Usage
Capture from a camera
use ;
async
Encode frames
use ;
async
Launch a GStreamer pipeline directly
use ;
async
CPU frames (BytesFrameData)
For pipelines that don't go through GStreamer, use BytesFrameData:
use Bytes;
use ;
let data = BytesFrameData;
let frame = VideoFrame ;
let bytes = frame.data.to_bytes.await?;
Frame data and GPU memory
VideoFrame<D: FrameData> is generic over its pixel data. The FrameData trait has a single required method:
async ;
GStreamer decodes directly on the GPU when hardware acceleration is enabled. GstFrameData holds the native gst::Buffer without copying it to CPU memory until to_bytes() is called. When a GstFrameData frame is passed to GstVideoEncoder or GstVideoSink, the buffer is forwarded to GStreamer's appsrc natively — no roundtrip through CPU memory.
| Type | Where data lives | Copy on to_bytes() |
|---|---|---|
BytesFrameData |
CPU (Bytes) |
None (clone is cheap) |
GstFrameData |
Where GStreamer left it (GPU / CPU) | Only if not already mapped |
Implementing a new backend
- Add a feature flag in
Cargo.toml - Create
src/backends/<name>/and implement the relevant traits:VideoSource— produces framesVideoSink— consumes framesVideoEncoder— raw frames → compressed packetsVideoDecoder— compressed packets → raw framesVideoTransform— frame-to-frame transformPipeline— full pipeline lifecycle
- Define your
FrameDatatype (or reuseBytesFrameData) - Gate the module in
src/backends/mod.rswith#[cfg(feature = "<name>")] - Re-export from
src/lib.rsunder the same gate
No changes to core traits are required.
License
Copyright © SpinorML Ltd. Licensed under the GNU Affero General Public License v3.0.