ff-format
Shared data types for the ff-* crate family. No FFmpeg dependency — these types exist so crates can exchange frames and stream metadata without coupling to FFmpeg's internal structs.
Key Types
| Type | Description |
|---|---|
PixelFormat |
Enumeration of pixel formats (Yuv420p, Rgba, Yuv420p10le, Yuv422p10le, Gbrpf32le, …) |
SampleFormat |
Audio sample formats (Fltp, S16, …) |
ChannelLayout |
Mono, Stereo, Surround51, and others |
ColorSpace |
Bt601, Bt709, Bt2020, and others |
ColorRange |
Limited (studio swing) or Full (PC swing) |
ColorPrimaries |
Bt709, Bt2020, DciP3, and others |
ColorTransfer |
OETF tag: Bt709, Pq (HDR10 / SMPTE ST 2084), Hlg (BT.2100), … |
Hdr10Metadata |
MaxCLL + MaxFALL + MasteringDisplay for HDR10 static metadata |
MasteringDisplay |
SMPTE ST 2086 mastering display colour volume (chromaticity + luminance) |
VideoCodec |
H264, H265, Vp9, Av1, Av1Svt, ProRes, DnxHd, and others |
AudioCodec |
Aac, Opus, Mp3, Flac, Vorbis, and others |
VideoFrame |
Decoded video frame with pixel data and associated Timestamp |
AudioFrame |
Decoded audio frame with sample data and associated Timestamp |
Timestamp |
Media position expressed as a Rational fraction of seconds |
These are the types ff-decode hands back when you decode a frame, and the types ff-encode expects when you push a frame.
Color Science Types
HDR and colour-space metadata is represented as pure-Rust enums — no FFmpeg dependency required:
use ;
// Tag a stream as HLG broadcast HDR.
let transfer = Hlg;
let space = Bt2020;
let primaries = Bt2020;
let range = Limited;
// Tag a stream as HDR10 (PQ transfer + BT.2020 primaries).
let transfer = Pq;
Hdr10Metadata and MasteringDisplay carry HDR10 static metadata that is
embedded as side data on key-frame packets:
use ;
// BT.2020 D65 primaries, coordinates × 50000; luminance × 10000 nits.
let meta = Hdr10Metadata ;
Example
use ;
// Create a timestamp at 2.5 seconds (5/2).
let ts = new;
// Arithmetic on rational timestamps stays exact.
let one_second = new;
let three_seconds = ts + one_second * new;
assert_eq!;
MSRV
Rust 1.93.0 (edition 2024).
License
MIT OR Apache-2.0