A safe and ergonomic Rust interface for FFmpeg integration, designed for ease of use.
A safe and ergonomic Rust interface for FFmpeg integration, designed for ease of use.
ez-ffmpeg provides a safe and ergonomic Rust interface for FFmpeg integration, offering a familiar API that closely follows FFmpeg’s original logic and parameter structures.
This library:
unsafe codeexamples/hdr_to_sdr), and experimental frame/sample/packet export and WHIP/SRT outputs (experimental APIs may change between minor releases) — see the crate documentation for detailsThe transcoding pipeline is ported from FFmpeg's own fftools/ffmpeg sources — same stage semantics, same function names. Migrating a CLI command? See the CLI-to-API mapping.
wgpu feature requires 1.85+).brew install ffmpeg# For dynamic linking
vcpkg install ffmpeg
# For static linking (requires 'static' feature)
vcpkg install ffmpeg:x64-windows-static-md
# Set VCPKG_ROOT environment variable# The libav*-dev packages are FFmpeg's development libraries.
# Needs FFmpeg 7.1+ (Ubuntu 24.04 ships 6.x — see docs/INSTALL.md).
sudo apt install pkg-config clang libavcodec-dev libavformat-dev \
libavfilter-dev libavdevice-dev libavutil-dev libswscale-dev libswresample-devStatic linking, building FFmpeg from source, and troubleshooting: see docs/INSTALL.md. Shipping a closed-source binary? Package-manager FFmpeg builds are often GPL — check the licensing matrix first.
[dependencies]
ez-ffmpeg = "0.19"The equivalent of ffmpeg -i input.mp4 -vf "hue=s=0" output.mov:
use ez_ffmpeg::FfmpegContext;
use ez_ffmpeg::FfmpegScheduler;
fn main() -> Result> {
// 1. Build the FFmpeg context
let context = FfmpegContext::builder()
.input("input.mp4")
.filter_desc("hue=s=0") // Example filter: desaturate (optional)
.output("output.mov")
.build()?;
// 2. Run it via FfmpegScheduler (synchronous mode)
let result = FfmpegScheduler::new(context)
.start()?
.wait();
result?; // Propagate any errors that occur
Ok(())
}With the cli feature, cli::from_cli runs a supported ffmpeg command directly and cli::emit_rust_code translates one into builder code; unsupported flags fail with explicit errors.
More examples can be found here.
ez-ffmpeg offers several optional features that can be enabled in your Cargo.toml as needed:
.await operations).HttpInput); rejects HLS/DASH playlists. Input::from("https://…") still uses FFmpeg's own protocols.ffmpeg-next/static).wgpu) GPU-accelerated OpenGL filters.ez-ffmpeg is licensed under your choice of the MIT, Apache-2.0, or MPL-2.0 licenses. You may select the license that best fits your needs. Important: While ez-ffmpeg is freely usable, FFmpeg has its own licensing terms. Ensure that your use of its components complies with FFmpeg's license.
No open issues yet, or sync has not completed.