ff-sys 0.16.0

Low-level FFmpeg FFI bindings for Rust
Documentation

ff-sys

Low-level FFmpeg FFI bindings generated by bindgen. Not intended for direct use; use the higher-level ff-* crates instead.

ff-sys is the raw, unsafe FFI foundation the rest of the ff-* family is built on: bindgen-generated bindings over the FFmpeg C API (libavcodec, libavformat, libavfilter, libswscale, libswresample, libavutil), plus a few thin safe-wrapper modules. It offers no safety guarantees of its own; every call is unsafe. Reach for it directly only when you need an FFmpeg API the higher-level crates do not yet expose; otherwise use the safe ff-* crates. Each crate is versioned independently; see crates.io for current versions.

Installation Prerequisites

FFmpeg 7.x development libraries must be available on your system before building any crate in this workspace. FFmpeg 6.x is not supported (the SWS_* flags differ in API shape), and FFmpeg 8.x is detected separately via the SwsFlags enum.

Windows

Install FFmpeg via vcpkg:

vcpkg install ffmpeg:x64-windows

The build script reads VCPKG_ROOT to locate the installation (defaulting to C:\vcpkg) and expects FFmpeg under <VCPKG_ROOT>\installed\x64-windows. bindgen also requires libclang: set LIBCLANG_PATH to your LLVM bin directory (containing libclang.dll) if it is not in a standard location such as C:\Program Files\LLVM\bin.

Linux

Detected via pkg-config:

sudo apt install libavcodec-dev libavformat-dev libavutil-dev \
                 libavfilter-dev libswscale-dev libswresample-dev

If FFmpeg is installed in a non-standard location, set PKG_CONFIG_PATH to its lib/pkgconfig directory.

macOS

brew install ffmpeg

Platform Support

Platform Detection Notes
Windows vcpkg (VCPKG_ROOT) ffmpeg:x64-windows triplet; LIBCLANG_PATH for bindgen
Linux pkg-config Dev packages (-dev) must be installed
macOS Homebrew, pkg-config Auto-detects /opt/homebrew or /usr/local, falls back to pkg-config

Wrapper Modules

Alongside the raw bindgen output, ff-sys ships thin safe-wrapper modules that isolate the most error-prone FFmpeg call sequences:

Module Wraps
avcodec AVCodecContext, codec open/close
avformat AVFormatContext, demux/mux lifecycle
swscale SwsContext, pixel format conversion
swresample SwrContext, sample format / channel layout conversion

These modules are public (pub mod) but are meant for use by the higher-level ff-* crates rather than for direct consumption.

MSRV

Rust 1.93.0 (edition 2024).

License

MIT OR Apache-2.0