Skip to main content

VideoParams

Struct VideoParams 

Source
pub struct VideoParams {
    pub width: u32,
    pub height: u32,
    pub frame_rate: Rational,
    pub pixel_format: PixelFormat,
    pub color_space: ColorSpace,
    pub chroma_location: ChromaLocation,
    pub display_aspect_ratio: Option<Rational>,
    pub bit_depth: u8,
    pub bitrate_bps: Option<u64>,
}
Expand description

Video stream encoding / decoding parameters.

Fields§

§width: u32

Frame width in pixels.

§height: u32

Frame height in pixels.

§frame_rate: Rational

Frame rate as a rational number (e.g. Rational::new(30, 1) for 30 fps, Rational::new(30000, 1001) for ≈29.97 fps).

§pixel_format: PixelFormat

Pixel format (default: PixelFormat::Yuv420p).

§color_space: ColorSpace

Colour space (default: ColorSpace::Bt709).

§chroma_location: ChromaLocation

Chroma sample location (default: ChromaLocation::Left).

§display_aspect_ratio: Option<Rational>

Display aspect ratio, if different from the storage aspect ratio.

§bit_depth: u8

Bit depth per colour component (8 for standard, 10 or 12 for HDR).

§bitrate_bps: Option<u64>

Target or measured peak bitrate in bits per second, if known.

Implementations§

Source§

impl VideoParams

Source

pub fn new(width: u32, height: u32, frame_rate: Rational) -> Self

Creates minimal VideoParams with width, height, and frame_rate.

All other fields receive sensible defaults:

Source

pub fn storage_aspect_ratio(&self) -> Rational

Returns the storage aspect ratio width / height as a Rational.

Source

pub fn effective_aspect_ratio(&self) -> Rational

Returns the display aspect ratio, falling back to the storage aspect ratio when not explicitly set.

Source

pub fn is_valid(&self) -> bool

Returns true if the frame dimensions are valid (both non-zero).

Source

pub fn pixel_count(&self) -> u64

Returns the total number of pixels per frame.

Source

pub fn fps(&self) -> f64

Returns the frame rate as a floating-point number.

Source

pub fn with_pixel_format(self, fmt: PixelFormat) -> Self

Builder-style setter for pixel format.

Source

pub fn with_color_space(self, cs: ColorSpace) -> Self

Builder-style setter for colour space.

Source

pub fn with_bit_depth(self, depth: u8) -> Self

Builder-style setter for bit depth.

Source

pub fn with_bitrate(self, bps: u64) -> Self

Builder-style setter for bitrate.

Trait Implementations§

Source§

impl Clone for VideoParams

Source§

fn clone(&self) -> VideoParams

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 VideoParams

Source§

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

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

impl PartialEq for VideoParams

Source§

fn eq(&self, other: &VideoParams) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for VideoParams

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.