| Crates.io | videostream |
| lib.rs | videostream |
| version | 2.1.4 |
| created_at | 2023-06-29 19:18:51.302282+00 |
| updated_at | 2026-01-05 16:21:45.457571+00 |
| description | Safe Rust bindings for VideoStream Library - zero-copy video frame management and distribution |
| homepage | https://edgefirst.ai |
| repository | https://github.com/EdgeFirstAI/videostream |
| max_upload_size | |
| id | 903594 |
| size | 205,724 |
Safe Rust bindings for the VideoStream Library - zero-copy video frame management and distribution for embedded Linux.
VideoStream provides inter-process video frame sharing with zero-copy transfers, making it ideal for embedded vision applications that need to distribute camera frames to multiple consumers efficiently.
The VideoStream C library must be installed:
# Ubuntu/Debian
sudo apt-get install libvideostream1
# Or build from source
git clone https://github.com/EdgeFirstAI/videostream
cd videostream
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
sudo cmake --install build
# Ubuntu/Debian
sudo apt-get install -y \
build-essential \
cmake \
pkg-config \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev
Add to your Cargo.toml:
[dependencies]
videostream = "1.5"
use videostream::{Host, PixelFormat};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a host to share 1920x1080 RGB frames
let mut host = Host::new(
"/tmp/videostream.sock",
1920,
1080,
PixelFormat::RGBX,
)?;
// Simulate frame production
loop {
// Get writable access to next frame buffer
let mut frame = host.get_write_buffer()?;
// Write frame data (e.g., from camera)
let data = frame.data_mut();
// ... fill data ...
// Publish frame to all connected clients
host.publish_frame(frame)?;
std::thread::sleep(std::time::Duration::from_millis(33)); // ~30 fps
}
}
use videostream::Client;
use std::time::Duration;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to the host
let mut client = Client::connect("/tmp/videostream.sock")?;
loop {
// Wait for next frame (with timeout)
match client.wait_for_frame(Duration::from_secs(1))? {
Some(frame) => {
// Access frame data (zero-copy)
let data = frame.data();
let (width, height) = frame.dimensions();
println!("Received {}x{} frame ({} bytes)",
width, height, data.len());
// Process frame...
}
None => {
println!("No frame received (timeout)");
}
}
}
}
┌─────────────┐
│ Host │ Frame Producer (1)
│ (Producer) │ - Allocates frame pool
└──────┬──────┘ - Publishes frames via IPC
│
│ UNIX Socket + DmaBuf FDs
│
├─────────┬─────────┬─────────┐
│ │ │ │
┌───▼───┐ ┌──▼────┐ ┌──▼────┐ ┌──▼────┐
│Client │ │Client │ │Client │ │Client │ Frame Consumers (N)
│ #1 │ │ #2 │ │ #3 │ │ ... │ - Zero-copy access
└───────┘ └───────┘ └───────┘ └───────┘ - Thread-safe
Benchmarks on NXP i.MX8M Plus (1080p@30fps):
This crate provides safe wrappers around the unsafe FFI bindings in videostream-sys:
See the examples directory for complete applications:
host_basic.rs - Simple frame producerclient_basic.rs - Simple frame consumercamera_capture.rs - V4L2 camera integrationmulti_client.rs - Multiple consumersContributions are welcome! Please see CONTRIBUTING.md.
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Copyright © 2025 Au-Zone Technologies