Skip to main content

VideoStreamInfo

Struct VideoStreamInfo 

Source
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

Source

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();
Source

pub const fn index(&self) -> u32

Returns the stream index within the container.

Source

pub const fn codec(&self) -> VideoCodec

Returns the video codec.

Source

pub fn codec_name(&self) -> &str

Returns the codec name as reported by the demuxer.

Source

pub const fn width(&self) -> u32

Returns the frame width in pixels.

Source

pub const fn height(&self) -> u32

Returns the frame height in pixels.

Source

pub const fn pixel_format(&self) -> PixelFormat

Returns the pixel format.

Source

pub const fn frame_rate(&self) -> Rational

Returns the frame rate as a rational number.

Source

pub fn fps(&self) -> f64

Returns the frame rate as frames per second (f64).

Source

pub const fn duration(&self) -> Option<Duration>

Returns the stream duration, if known.

Source

pub const fn bitrate(&self) -> Option<u64>

Returns the bitrate in bits per second, if known.

Source

pub const fn frame_count(&self) -> Option<u64>

Returns the total number of frames, if known.

Source

pub const fn color_space(&self) -> ColorSpace

Returns the color space (matrix coefficients).

Source

pub const fn color_range(&self) -> ColorRange

Returns the color range (limited/full).

Source

pub const fn color_primaries(&self) -> ColorPrimaries

Returns the color primaries.

Source

pub fn aspect_ratio(&self) -> f64

Returns the aspect ratio as width/height.

Source

pub const fn is_hd(&self) -> bool

Returns true if the video is HD (720p or higher).

Source

pub const fn is_full_hd(&self) -> bool

Returns true if the video is Full HD (1080p or higher).

Source

pub const fn is_4k(&self) -> bool

Returns true if the video is 4K UHD (2160p or higher).

Source

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:

  1. Wide color gamut: BT.2020 color primaries
  2. 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

Source§

fn clone(&self) -> VideoStreamInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VideoStreamInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for VideoStreamInfo

Source§

fn default() -> VideoStreamInfo

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.