video-toolbox-sys

Crates.iovideo-toolbox-sys
lib.rsvideo-toolbox-sys
version0.2.0
created_at2026-01-22 11:58:23.984809+00
updated_at2026-01-22 11:58:23.984809+00
descriptionFFI bindings and helpers for Apple VideoToolbox framework
homepagehttps://github.com/luozijun/rust-videotoolbox-sys
repositoryhttps://github.com/luozijun/rust-videotoolbox-sys
max_upload_size
id2061411
size213,097
Haixuan Xavier Tao (haixuanTao)

documentation

https://docs.rs/video-toolbox-sys

README

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 helpers feature)

Installation

Add to your Cargo.toml:

[dependencies]
video-toolbox-sys = "0.2"

# Optional: Enable high-level helpers
video-toolbox-sys = { version = "0.2", features = ["helpers"] }

Usage

Basic FFI Usage

use video_toolbox_sys::codecs;
use video_toolbox_sys::compression::*;
use video_toolbox_sys::errors::vt_error_to_string;

// Use codec constants
let codec = codecs::video::H264;
let pixel_format = codecs::pixel::BGRA32;

With Helpers Feature

use video_toolbox_sys::helpers::CompressionSessionBuilder;
use video_toolbox_sys::codecs;

let session = CompressionSessionBuilder::new(1920, 1080, codecs::video::H264)
    .hardware_accelerated(true)
    .bitrate(8_000_000)
    .frame_rate(30.0)
    .build(|_, _, status, _, sample_buffer| {
        if status == 0 && !sample_buffer.is_null() {
            // Handle encoded frame
        }
    })
    .expect("Failed to create compression session");

Examples

See the examples/ directory for complete working examples:

  • encode_dummy_image.rs - Encode synthetic frames to H.264
  • camera_to_mp4.rs - Capture from camera and save to MP4
  • av_record.rs - Record audio + video to MOV

Run an example:

cargo run --example encode_dummy_image

Requirements

  • macOS 10.8+ or iOS 8.0+
  • Rust 1.56+

License

MIT

Commit count: 5

cargo fmt