videostream
Safe Rust bindings for the VideoStream Library - zero-copy video frame management and distribution for embedded Linux.
Overview
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.
Key Features
- Zero-Copy Frame Sharing - Uses Linux DmaBuf and POSIX shared memory
- Multi-Consumer Support - One producer, multiple concurrent consumers
- Thread-Safe - Safe concurrent access to frame pools
- Reference Counting - Automatic memory management
- Hardware Acceleration - V4L2 camera capture and Hantro VPU encoding
- GStreamer Integration - Pipeline-based video processing
Use Cases
- Multi-Process Vision Pipelines - Share camera frames between detection, tracking, and display
- Edge AI Applications - Distribute frames to multiple inference engines
- Video Recording + Analysis - Simultaneously record and analyze camera streams
- Low-Latency Streaming - Hardware-accelerated encoding with minimal overhead
Platform Support
- NXP i.MX8M Plus - Full hardware acceleration (G2D, VPU, DmaBuf)
- Generic ARM64/ARMv7 - Software fallback with shared memory
- x86_64 - Development and testing support
Requirements
Runtime Dependencies
The VideoStream C library must be installed:
# Ubuntu/Debian
# Or build from source
Build Dependencies
# Ubuntu/Debian
Quick Start
Add to your Cargo.toml:
[]
= "1.5"
Host (Frame Producer)
use ;
Client (Frame Consumer)
use Client;
use Duration;
Architecture
┌─────────────┐
│ 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
Performance
Benchmarks on NXP i.MX8M Plus (1080p@30fps):
- Frame Latency: <3ms (DmaBuf), <10ms (shared memory)
- CPU Overhead: <2% per client (frame distribution)
- Memory: ~100KB per client (no frame copies)
- Throughput: 60fps sustained with 3 concurrent clients
Safety
This crate provides safe wrappers around the unsafe FFI bindings in videostream-sys:
- ✅ Memory safety through RAII and lifetimes
- ✅ Thread safety with interior mutability patterns
- ✅ Null pointer checks and error handling
- ✅ Automatic resource cleanup (Drop implementations)
Examples
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 consumers
Documentation
Contributing
Contributions are welcome! Please see CONTRIBUTING.md.
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Copyright © 2025 Au-Zone Technologies