videotoolbox
Safe, zero-runtime-dependency Rust bindings for Apple's VideoToolbox framework — hardware-accelerated H.264, HEVC, and ProRes codecs on macOS.
Status: experimental. Encoder is functional; decoder, pixel transfer, and multi-pass support are planned.
Features
- Hardware-accelerated encoding — H.264, HEVC, and
ProRes422/4444 - Direct
IOSurfaceinput — encode zero-copy from screencapturekit / camera output viaapple-cf::iosurface - Builder pattern — fluent configuration of bitrate, frame rate, keyframe interval, real-time mode
- Pure C bindings — no Swift bridge, no
bindgen, no procedural macros - Single dependency — only
apple-cffor shared types
Why not bindgen?
The full VideoToolbox C surface is ~200 symbols, but the useful set for an encoder is closer to 15. Hand-writing those declarations gives us:
- No build-time dependency on
clang - Type-safe Rust enums for codec types (instead of raw
u32four-character codes) - Builder APIs that map ergonomically to VT's
CFDictionaryproperty bag
Requirements
- macOS 13.0+
- Apple Silicon or Intel Mac with hardware video encoder
Quick start
use *;
use ;
Composes with the rest of the doom-fish stack
screencapturekit-rs ──► IOSurface ──► videotoolbox-rs ──► H.264 bytes
↓
avassetwriter-rs (future)
↓
.mp4 file
Roadmap
-
VTCompressionSession(encoder) -
VTDecompressionSession(decoder) -
VTPixelTransferSession(pixel format / colour space conversion) -
VTPixelRotationSession -
VTMultiPassStorage+VTFrameSilo(two-pass encoding) -
VTHDRPerFrameMetadataGenerationSession(Dolby Vision metadata) -
VTFrameProcessorcapability queries (super-resolution / optical flow detection) -
VTProfessionalVideoWorkflowdecoder/encoder registration -
VTCreateCGImageFromCVPixelBuffer - HEVC profile-level helpers
- Full
VTFrameProcessorpipeline (process frames with Metal command buffers — v0.10) - Async encode API via
VTCompressionSessionEncodeFrameWithOutputHandler
License
Licensed under either of Apache-2.0 or MIT at your option.