MCPcopy Index your code
hub / github.com/YeautyYE/ez-ffmpeg

github.com/YeautyYE/ez-ffmpeg @v0.12.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.12.0 ↗ · + Follow
2,251 symbols 7,756 edges 165 files 757 documented · 34%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Logo

Crates.io Documentation License: MIT/Apache-2.0/MPL-2.0 Rust FFmpeg

Overview

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: - Exposes a safe public API; the internal FFmpeg FFI layer uses audited unsafe code - Keeps the execution logic and parameter conventions as close to FFmpeg as possible - Provides an intuitive and user-friendly API for media processing - Supports custom Rust filters and flexible input/output handling - Offers optional GPU-accelerated custom filters (wgpu) and a high-performance embedded RTMP server - Ships one-shot recipes (thumbnails/sprite sheets, animated GIF, HLS ABR ladders) and a detection/measurement API (black/silence/scene/crop/EBU R128 loudness) that returns typed Rust results instead of only FFmpeg logs

By abstracting the complexity of the raw C API, ez-ffmpeg simplifies configuring media pipelines, performing transcoding and filtering, and inspecting media streams.

The transcoding pipeline is ported from the FFmpeg CLI sources (fftools/ffmpeg, FFmpeg 7.x): the demux/decode/filter/encode/mux stages keep the fftools function names and semantics, and code comments cite the corresponding C file and line (line numbers refer to the FFmpeg n7.1 tag). FFmpeg developers can navigate the codebase by grepping for the names they already know (ts_fixup, video_sync_process, enc_open, mux_fixup_ts, ...).

Not every CLI feature is implemented. Notable gaps (unsupported paths fail with explicit errors): progress/stats reporting (-progress), sub2video, -shortest cross-stream sync, bitstream filters (-bsf), keyframe forcing (-force_key_frames), -fix_sub_duration, two-pass encoding, and attachments.

Version Requirements

  • Rust: Version 1.80.0 or higher.
  • FFmpeg: Version 7.0 through 8.x (one build links either major; the bindings gate on the installed version).

Documentation

More information about this crate can be found in the crate documentation.

Quick Start

Installation Prerequisites

macOS

brew install ffmpeg

Windows

# For dynamic linking
vcpkg install ffmpeg

# For static linking (requires 'static' feature)
vcpkg install ffmpeg:x64-windows-static-md

# Set VCPKG_ROOT environment variable

Adding the Dependency

Add ez-ffmpeg to your project by including it in your Cargo.toml:

[dependencies]
ez-ffmpeg = "*"

Basic Usage

Below is a basic example to get you started. Create or update your main.rs with the following code:

use ez_ffmpeg::FfmpegContext;
use ez_ffmpeg::FfmpegScheduler;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 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(())
}

More examples can be found here.

Features

ez-ffmpeg offers several optional features that can be enabled in your Cargo.toml as needed:

  • wgpu: GPU-accelerated custom video filters written in WGSL, running headless over Vulkan/Metal/DX12/GL — YUV↔RGB conversion on the GPU with the correct color matrix, GPU work overlapped with CPU work while preserving output order, and experimental zero-copy hardware-frame input (Linux/Vulkan). Successor to the deprecated opengl feature.
  • opengl: (deprecated, superseded by wgpu) GPU-accelerated OpenGL filters. Requires a display connection and converts colors on the CPU; kept functional for existing users — see the opengl module docs for migration.
  • rtmp: High-performance embedded RTMP server with native epoll/kqueue, O(1) GOP sharing, and 10,000+ concurrent connections on Linux/macOS (8,000 on Windows). In-process ingest with no TCP between FFmpeg and server.
  • subtitle: Native ASS/SRT subtitle burn-in rendered by a pure-Rust engine inside the frame pipeline — independent of FFmpeg build flags (no --enable-libass needed, no system libass), with in-memory script input and explicit font-file control.
  • flv: Provides support for FLV container parsing and handling.
  • async: Adds asynchronous functionality (allowing you to .await operations).
  • static: Enables static linking for FFmpeg libraries (via ffmpeg-next/static).

License

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.

Extension points exported contracts — how you extend this code

EventSink (Interface)
A destination for [`MetadataEvent`]s. [`try_emit`](EventSink::try_emit) is non-blocking. The default [`emit_blocking`]( [4 …
src/core/analysis/filter.rs
Sample (Interface)
Static sample codec: load/store one sample and the FFmpeg blend at that width. Monomorphized so the hot loops carry no p [2 …
src/subtitle/blend.rs
FrameFilter (Interface)
(no doc) [9 implementers]
src/core/filter/frame_filter.rs
SubtitleRenderer (Interface)
One rendering session for one loaded subtitle track. Configuration happens on the builder thread; [`Self::render_frame` [1 …
src/subtitle/backend.rs

Core symbols most depended-on inside this repo

is_null
called by 280
src/core/codec.rs
as_ptr
called by 240
src/core/context/mod.rs
iter
called by 214
src/core/context/mod.rs
clone
called by 212
src/core/context/obj_pool.rs
len
called by 164
src/rtmp/gop.rs
clone
called by 149
src/rtmp/gop.rs
input
called by 145
src/core/context/ffmpeg_context_builder.rs
as_ptr
called by 133
src/core/codec.rs

Shape

Function 1,244
Method 702
Class 212
Enum 89
Interface 4

Languages

Rust100%

Modules by API surface

src/subtitle/blend.rs75 symbols
src/subtitle/render/raster.rs71 symbols
src/core/context/ffmpeg_context.rs67 symbols
src/rtmp/reactor.rs64 symbols
src/core/recipes/hls.rs57 symbols
src/core/context/output.rs55 symbols
src/subtitle/render/layout.rs49 symbols
src/subtitle/options.rs49 symbols
src/core/scheduler/filter_task.rs47 symbols
src/core/scheduler/ffmpeg_scheduler.rs47 symbols
src/rtmp/rtmp_scheduler.rs45 symbols
src/subtitle/ass/parser.rs44 symbols

For agents

$ claude mcp add ez-ffmpeg \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page