ff-preview
Real-time video preview and proxy workflow for Rust. Provides frame-accurate seek, audio-master A/V sync, a FrameSink trait for custom renderers, RGBA pixel delivery, and proxy generation with auto-substitution.
ff-preview adds a real-time, A/V-synchronised playback and seek loop on top of the decode primitives, converting frames to RGBA via libswscale for display. Decoding is delegated to ff-decode; this crate owns the playback clock, frame-accurate seek, and a FrameSink trait for custom renderers. Errors are typed and chain their source (PreviewError), so a failure reads as an actionable message rather than a raw FFmpeg return code.
It is an independent crate: use it on its own, or combine it with the other ff-* crates to assemble whatever media application, or editing model, you need. The ff-* crates are purified, model-free primitives, so none imposes an editing model on you; avio is one editing engine built on top of them. Each crate is versioned independently; see crates.io for current versions.
Installation
[]
= "0.16"
# Enable async support
= { = "0.16", = ["tokio"] }
# Enable proxy generation
= { = "0.16", = ["proxy"] }
Quick Start
Playback with a custom RGBA sink
PreviewPlayer::open probes the file and prepares the pipeline. Call split()
to obtain an exclusive PlayerRunner (owns the decode pipeline; register the
sink and drive it with run()) and a cloneable PlayerHandle (non-blocking
play / pause / seek / stop controls).
use thread;
use ;
Frame-accurate seek
use Path;
use Duration;
use ;
let mut buf = open.build?;
buf.seek?;
loop
Proxy generation
use Path;
use ;
let proxy_path = new?
.resolution
.output_dir
.generate?;
println!;
Feature Flags
| Feature | What it enables |
|---|---|
| (default) | PreviewPlayer, PlayerRunner, PlayerHandle, DecodeBuffer, PlaybackClock, FrameSink, RgbaSink, RgbaFrame, seek |
tokio |
AsyncPreviewPlayer |
proxy |
ProxyGenerator, ProxyJob, ProxyResolution |
timeline |
Scene, ScenePlayer, SceneRunner |
MSRV
Rust 1.93.0 (edition 2024).
License
MIT OR Apache-2.0