| Crates.io | ffmpeg-light |
| lib.rs | ffmpeg-light |
| version | 0.2.0 |
| created_at | 2025-12-03 17:17:04.422416+00 |
| updated_at | 2026-01-02 20:23:41.343098+00 |
| description | A small Rust crate that wraps a few common FFmpeg tasks |
| homepage | |
| repository | https://github.com/M1tsumi/ffmpeg-light |
| max_upload_size | |
| id | 1964625 |
| size | 93,965 |
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.
TranscodeBuilderFFmpeg 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.
[dependencies]
ffmpeg-light = "0.2"
Requires ffmpeg and ffprobe on PATH. Get them via:
brew install ffmpegapt install ffmpeg (or equivalent)use ffmpeg_light::probe;
fn main() -> ffmpeg_light::Result<()> {
let info = probe("input.mp4")?;
println!("Duration: {:?}", info.duration());
Ok(())
}
use ffmpeg_light::{AudioFilter, TranscodeBuilder, VideoFilter};
fn main() -> ffmpeg_light::Result<()> {
TranscodeBuilder::new()
.input("input.avi")
.output("output.mp4")
.video_codec("libx264")
.audio_codec("aac")
.video_bitrate(2500)
.add_video_filter(VideoFilter::Scale {
width: 1280,
height: 720,
})
.add_audio_filter(AudioFilter::Normalization {
target_level: -23.0,
})
.run()?;
Ok(())
}
use ffmpeg_light::{AudioFilter, TranscodeBuilder, VideoFilter};
fn main() -> ffmpeg_light::Result<()> {
TranscodeBuilder::new()
.input("raw.mov")
.output("processed.mp4")
.add_video_filter(VideoFilter::Crop {
width: 1920,
height: 1080,
x: 0,
y: 0,
})
.add_video_filter(VideoFilter::Denoise {
strength: ffmpeg_light::filter::DenoiseStrength::Medium,
})
.add_audio_filter(AudioFilter::Normalization {
target_level: -23.0,
})
.video_codec("libx264")
.audio_codec("aac")
.run()?;
Ok(())
}
use ffmpeg_light::{thumbnail::ThumbnailOptions, types::Time};
fn main() -> ffmpeg_light::Result<()> {
let options = ThumbnailOptions::new(Time::from_seconds_f64(12.5));
ffmpeg_light::generate_thumbnail("input.mp4", "thumb.png", &options)?;
Ok(())
}
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 for Scale filter.run(): Execute the transcode jobScale: 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 syntaxVolume: Adjust audio levelEqualizer: 3-band EQ (bass, mid, treble)Normalization: Normalize to target loudnessHighPass, LowPass: Frequency filteringCustom: Raw FFmpeg audio filter syntaxprobe(path): Get file duration, codecs, resolution, frame rate, and bit ratesProbeResult: Video/audio stream metadatagenerate_thumbnail(input, output, options): Extract frame at timestampThumbnailOptions: Control timestamp, size, and formatThe crate provides granular error types with recovery suggestions:
use ffmpeg_light::Error;
match some_operation() {
Err(Error::FFmpegNotFound { suggestion }) => {
eprintln!("FFmpeg not found. Help: {:?}", suggestion);
}
Err(Error::InvalidInput(msg)) => {
eprintln!("Bad parameters: {}", msg);
}
Err(Error::FilterError(msg)) => {
eprintln!("Filter problem: {}", msg);
}
Ok(_) => {}
Err(e) => eprintln!("Error: {}", e),
}
ffmpeg/ffprobe. That keeps builds fast, works anywhere binaries exist, and avoids shipping unsafe C bindings.std::process::Command.Tested on Linux, macOS, and Windows. Requires ffmpeg and ffprobe on PATH:
brew install ffmpegapt install ffmpeg (or distro equivalent)Paths on Windows work best without spaces. The builder handles argument quoting automatically.
tokio feature gateLicensed under the Apache License, Version 2.0.