avio
avio is the unified facade for the ff-* crate family. Depend on a single crate and opt in
to only the capabilities you need via feature flags.
Installation
[]
# Default: probe + decode + encode
= "0.7"
# Add filtering
= { = "0.7", = ["filter"] }
# Full stack (implies filter + pipeline)
= { = "0.7", = ["stream"] }
# Async decode/encode (requires tokio runtime)
= { = "0.7", = ["tokio"] }
Feature Flags
| Feature | Enables | Default |
|---|---|---|
probe |
ff-probe — read-only media metadata |
yes |
decode |
ff-decode — video and audio decoding |
yes |
encode |
ff-encode — video and audio encoding |
yes |
filter |
ff-filter — filter graph operations |
no |
pipeline |
ff-pipeline — decode → filter → encode |
no |
stream |
ff-stream — HLS / DASH streaming output |
no |
tokio |
Async wrappers for decode and encode | no |
Quick Start
Probe
use open;
let info = open?;
if let Some = info.primary_video
Decode
use ;
// Video — request RGB24 output (FFmpeg converts internally)
let mut vdec = open
.output_format
.build?;
while let Some = vdec.decode_one?
// Audio — resample to f32 at 44.1 kHz
let mut adec = open
.output_format
.output_sample_rate
.build?;
while let Some = adec.decode_one?
Image Sequences
A %-pattern path (e.g. frame%04d.png) automatically selects the image2
demuxer for decode and muxer for encode:
use ;
// Decode numbered PNGs → video
let mut decoder = open
.hardware_accel
.frame_rate
.build?;
// Encode video → numbered PNGs
let mut encoder = create
.video
.video_codec
.build?;
Encode
use ;
let mut encoder = create
.video
.video_codec
.bitrate_mode
.audio
.audio_codec
.build?;
for frame in &video_frames
encoder.finish?;
Per-Codec Options
VideoCodecOptions and AudioCodecOptions provide typed, per-codec
configuration applied before the codec is opened:
use ;
let opts = H264;
let mut encoder = create
.video
.video_codec
.bitrate_mode
.codec_options
.build?;
Available option structs: H264Options, H265Options, Av1Options,
SvtAv1Options, Vp9Options, ProResOptions, DnxhdOptions,
OpusOptions, AacOptions, Mp3Options, FlacOptions.
Professional Formats
use ;
let mut encoder = create
.video
.video_codec
.pixel_format
.codec_options
.build?;
HDR Metadata
use ;
// HDR10 — PQ transfer + MaxCLL/MaxFALL side data
let mut encoder = create
.video
.video_codec
.bitrate_mode
.pixel_format
.codec_options
.hdr10_metadata
.build?;
// HLG — broadcast HDR without MaxCLL/MaxFALL
use ;
let mut encoder = create
.video
.video_codec
.pixel_format
.color_transfer
.color_space
.color_primaries
.build?;
Async (tokio feature)
use ;
use StreamExt;
let mut encoder = from_builder?;
let stream = open.await?.into_stream;
pin!;
while let Some = stream.next.await
encoder.finish.await?;
Pipeline (pipeline feature)
use ;
builder
.input
.output
.build?
.run?;
Crate Family
| Crate | Purpose |
|---|---|
ff-sys |
Raw bindgen FFI — internal use only |
ff-common |
Shared buffer-pooling abstractions |
ff-format |
Pure-Rust type definitions (no FFmpeg linkage) |
ff-probe |
Read-only media metadata extraction |
ff-decode |
Video and audio decoding |
ff-encode |
Video and audio encoding |
ff-filter |
Filter graph operations |
ff-pipeline |
Decode → filter → encode pipeline |
ff-stream |
HLS / DASH adaptive streaming output |
avio |
Unified facade (this crate) |
MSRV
Rust 1.93.0 (edition 2024).
License
MIT OR Apache-2.0