video-toolbox-sys
FFI bindings and helpers for Apple VideoToolbox framework.
VideoToolbox is a low-level framework that provides direct access to hardware encoders and decoders on macOS and iOS. It provides services for video compression and decompression, and for conversion between raster image formats stored in CoreVideo pixel buffers.
Features
- Raw FFI bindings to VideoToolbox APIs
- Codec FourCC constants (H.264, HEVC, AAC, etc.)
- Error code to string conversion
- Optional high-level helpers (with
helpersfeature)
Installation
Add to your Cargo.toml:
[]
= "0.2"
# Optional: Enable high-level helpers
= { = "0.2", = ["helpers"] }
Usage
Basic FFI Usage
use codecs;
use *;
use vt_error_to_string;
// Use codec constants
let codec = H264;
let pixel_format = BGRA32;
With Helpers Feature
use CompressionSessionBuilder;
use codecs;
let session = new
.hardware_accelerated
.bitrate
.frame_rate
.build
.expect;
Examples
See the examples/ directory for complete working examples:
encode_dummy_image.rs- Encode synthetic frames to H.264camera_to_mp4.rs- Capture from camera and save to MP4av_record.rs- Record audio + video to MOV
Run an example:
Requirements
- macOS 10.8+ or iOS 8.0+
- Rust 1.56+
License
MIT