pub struct VideoStreamInfo { /* private fields */ }Expand description
Information about a video stream within a media file.
This struct contains all metadata needed to understand and process a video stream, including resolution, codec, frame rate, and color characteristics.
§Construction
Use VideoStreamInfo::builder() for fluent construction:
use ff_format::stream::VideoStreamInfo;
use ff_format::{PixelFormat, Rational};
use ff_format::codec::VideoCodec;
let info = VideoStreamInfo::builder()
.index(0)
.codec(VideoCodec::H264)
.width(1920)
.height(1080)
.frame_rate(Rational::new(30, 1))
.build();Implementations§
Source§impl VideoStreamInfo
impl VideoStreamInfo
Sourcepub fn builder() -> VideoStreamInfoBuilder
pub fn builder() -> VideoStreamInfoBuilder
Creates a new builder for constructing VideoStreamInfo.
§Examples
use ff_format::stream::VideoStreamInfo;
use ff_format::codec::VideoCodec;
use ff_format::{PixelFormat, Rational};
let info = VideoStreamInfo::builder()
.index(0)
.codec(VideoCodec::H264)
.width(1920)
.height(1080)
.frame_rate(Rational::new(30, 1))
.build();Sourcepub const fn codec(&self) -> VideoCodec
pub const fn codec(&self) -> VideoCodec
Returns the video codec.
Sourcepub fn codec_name(&self) -> &str
pub fn codec_name(&self) -> &str
Returns the codec name as reported by the demuxer.
Sourcepub const fn pixel_format(&self) -> PixelFormat
pub const fn pixel_format(&self) -> PixelFormat
Returns the pixel format.
Sourcepub const fn frame_rate(&self) -> Rational
pub const fn frame_rate(&self) -> Rational
Returns the frame rate as a rational number.
Sourcepub const fn frame_count(&self) -> Option<u64>
pub const fn frame_count(&self) -> Option<u64>
Returns the total number of frames, if known.
Sourcepub const fn color_space(&self) -> ColorSpace
pub const fn color_space(&self) -> ColorSpace
Returns the color space (matrix coefficients).
Sourcepub const fn color_range(&self) -> ColorRange
pub const fn color_range(&self) -> ColorRange
Returns the color range (limited/full).
Sourcepub const fn color_primaries(&self) -> ColorPrimaries
pub const fn color_primaries(&self) -> ColorPrimaries
Returns the color primaries.
Sourcepub fn aspect_ratio(&self) -> f64
pub fn aspect_ratio(&self) -> f64
Returns the aspect ratio as width/height.
Sourcepub const fn is_full_hd(&self) -> bool
pub const fn is_full_hd(&self) -> bool
Returns true if the video is Full HD (1080p or higher).
Sourcepub fn is_hdr(&self) -> bool
pub fn is_hdr(&self) -> bool
Returns true if this video stream appears to be HDR (High Dynamic Range).
HDR detection is based on two primary indicators:
- Wide color gamut: BT.2020 color primaries
- High bit depth: 10-bit or higher pixel format
Both conditions must be met for a stream to be considered HDR. This is a heuristic detection - for definitive HDR identification, additional metadata like transfer characteristics (PQ/HLG) should be checked.
§Examples
use ff_format::stream::VideoStreamInfo;
use ff_format::color::ColorPrimaries;
use ff_format::PixelFormat;
let hdr_video = VideoStreamInfo::builder()
.width(3840)
.height(2160)
.color_primaries(ColorPrimaries::Bt2020)
.pixel_format(PixelFormat::Yuv420p10le)
.build();
assert!(hdr_video.is_hdr());
// Standard HD video with BT.709 is not HDR
let sdr_video = VideoStreamInfo::builder()
.width(1920)
.height(1080)
.color_primaries(ColorPrimaries::Bt709)
.pixel_format(PixelFormat::Yuv420p)
.build();
assert!(!sdr_video.is_hdr());Trait Implementations§
Source§impl Clone for VideoStreamInfo
impl Clone for VideoStreamInfo
Source§fn clone(&self) -> VideoStreamInfo
fn clone(&self) -> VideoStreamInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more