ff_format/frame/mod.rs
1//! Video and audio frame types.
2//!
3//! This module provides [`VideoFrame`] and [`AudioFrame`] structures
4//! for working with decoded media frames. These types abstract away
5//! `FFmpeg`'s internal frame structures and provide a safe, Rust-idiomatic API.
6//!
7//! # Examples
8//!
9//! ## Video Frame
10//!
11//! ```
12//! use ff_format::{PixelFormat, PooledBuffer, Rational, Timestamp, VideoFrame};
13//!
14//! // Create a simple 1920x1080 RGBA frame
15//! let width = 1920u32;
16//! let height = 1080u32;
17//! let bytes_per_pixel = 4; // RGBA
18//! let stride = width as usize * bytes_per_pixel;
19//! let data = vec![0u8; stride * height as usize];
20//!
21//! let frame = VideoFrame::new(
22//! vec![PooledBuffer::standalone(data)],
23//! vec![stride],
24//! width,
25//! height,
26//! PixelFormat::Rgba,
27//! Timestamp::default(),
28//! true,
29//! ).unwrap();
30//!
31//! assert_eq!(frame.width(), 1920);
32//! assert_eq!(frame.height(), 1080);
33//! assert!(frame.is_key_frame());
34//! assert_eq!(frame.num_planes(), 1);
35//! ```
36//!
37//! ## Audio Frame
38//!
39//! ```
40//! use ff_format::{AudioFrame, SampleFormat, Rational, Timestamp};
41//!
42//! // Create a stereo F32 audio frame with 1024 samples
43//! let channels = 2u32;
44//! let samples = 1024usize;
45//! let sample_rate = 48000u32;
46//!
47//! let frame = AudioFrame::empty(
48//! samples,
49//! channels,
50//! sample_rate,
51//! SampleFormat::F32,
52//! ).unwrap();
53//!
54//! assert_eq!(frame.samples(), 1024);
55//! assert_eq!(frame.channels(), 2);
56//! assert_eq!(frame.sample_rate(), 48000);
57//! assert!(!frame.format().is_planar());
58//! ```
59
60mod audio;
61mod video;
62
63pub use audio::AudioFrame;
64pub use video::VideoFrame;