ffmpeg-light
A Rust crate that wraps common FFmpeg tasks without the CLI memorization. Transcode, probe, filter, and process video/audio with a clean, type-safe API.
Features
- Video & Audio Filters: Scale, crop, rotate, flip, denoise, deinterlace, volume control, equalization, normalization, and more
- Fluent Builder API: Chain operations naturally with
TranscodeBuilder - Robust Error Handling: Granular error types with contextual recovery suggestions
- Media Probing: Extract duration, codecs, resolutions, and stream information
- Thumbnail Generation: Extract frames at specific timestamps with size control
- Filter Composition: Build complex filter chains with automatic optimization
- Zero Breaking Changes: All v0.1.0 APIs remain fully supported
Why this exists
FFmpeg is powerful but the CLI has hundreds of flags. Using raw C bindings means managing C library builds. This crate sits in the middle: spawns the ffmpeg/ffprobe binaries you already have and gives you a type-safe Rust API.
Install
[]
= "0.2"
Requires ffmpeg and ffprobe on PATH. Get them via:
- macOS:
brew install ffmpeg - Linux:
apt install ffmpeg(or equivalent) - Windows: ffmpeg.org
Quick Start
Probe a file
use probe;
Transcode with filters
use ;
Apply multiple filters
use ;
Grab a thumbnail
use ;
API Overview
Transcoding & Filters
TranscodeBuilder: Fluent API for configuring transcoding jobs.video_codec(),.audio_codec(): Set output codecs.video_bitrate(),.audio_bitrate(): Control quality/file size.add_video_filter(),.add_audio_filter(): Chain filters.preset(): Encoding preset (e.g., "fast", "medium", "slow").size(): Shortcut forScalefilter.run(): Execute the transcode job
Video Filters
Scale: Resize videoCrop: Extract a regionTrim: Cut a time rangeRotate: Rotate by degreesFlip: Mirror horizontally or verticallyBrightnessContrast: Adjust brightness/contrastDenoise: Reduce noise (Light/Medium/Heavy)Deinterlace: Convert interlaced to progressiveCustom: Raw FFmpeg filter syntax
Audio Filters
Volume: Adjust audio levelEqualizer: 3-band EQ (bass, mid, treble)Normalization: Normalize to target loudnessHighPass,LowPass: Frequency filteringCustom: Raw FFmpeg audio filter syntax
Media Inspection
probe(path): Get file duration, codecs, resolution, frame rate, and bit ratesProbeResult: Video/audio stream metadata
Thumbnails
generate_thumbnail(input, output, options): Extract frame at timestampThumbnailOptions: Control timestamp, size, and format
Error Handling
The crate provides granular error types with recovery suggestions:
use Error;
match some_operation
Design notes
- The crate shells out to
ffmpeg/ffprobe. That keeps builds fast, works anywhere binaries exist, and avoids shipping unsafe C bindings. - Arguments are never handed to a shell; every value goes directly to
std::process::Command. - If you need the full FFmpeg surface area, drop down to the CLI; this crate handles the frequent, repetitive tasks.
Supported Platforms
Tested on Linux, macOS, and Windows. Requires ffmpeg and ffprobe on PATH:
- macOS:
brew install ffmpeg - Linux:
apt install ffmpeg(or distro equivalent) - Windows: Download from ffmpeg.org
Paths on Windows work best without spaces. The builder handles argument quoting automatically.
v0.2.0 Release Highlights
- ✅ 8 Video Filters: Scale, Crop, Trim, Rotate, Flip, BrightnessContrast, Denoise, Deinterlace
- ✅ 6 Audio Filters: Volume, Equalizer, Normalization, HighPass, LowPass, Custom
- ✅ Granular Error Types: FFmpegNotFound, ProcessingError, InvalidInput, FilterError, TimeoutError
- ✅ Builder Accessors: Inspect configured filters, codecs, and settings
- ✅ 41 Integration Tests: Comprehensive coverage of filters, error handling, and builder composition
- ✅ Zero Breaking Changes: All v0.1.0 APIs remain fully compatible
Roadmap
- Async command helpers behind a
tokiofeature gate - Batch processing with parallel transcoding
- Hardware acceleration (NVIDIA NVENC, Intel QuickSync, Apple VideoToolbox)
- Streaming segment output (HLS/DASH)
- Subtitle and chapter handling
License
Licensed under the Apache License, Version 2.0.