Skip to main content

EncoderBuilder

Struct EncoderBuilder 

Source
pub struct EncoderBuilder { /* private fields */ }
Expand description

Builds a stream header and produces an Encoder.

Canonical emit order: W, H, F, I, A, C, then X* in insertion order. Tags with no value set are omitted. A0:0 is the one legal sentinel and is emitted when set explicitly.

Implementations§

Source§

impl EncoderBuilder

Source

pub fn new(width: usize, height: usize, framerate: Ratio) -> Self

Starts a builder with the three required stream parameters.

Source

pub fn colorspace(self, cs: Colorspace) -> Self

Sets the colorspace tag. Default: plain C420.

Source

pub fn pixel_aspect(self, aspect: Ratio) -> Self

Sets the pixel aspect ratio, including the 0:0 unknown sentinel. Default: the A tag is omitted.

Source

pub fn interlace(self, interlace: Interlace) -> Self

Sets the interlacing mode. Default: the I tag is omitted. Interlace::Unknown is treated as no value and omitted.

Source

pub fn extension(self, value: &[u8]) -> Result<Self, Error>

Appends an X vendor extension (value bytes after the X). Repeatable, with insertion order preserved on the wire. The value must be non-empty and free of SP, LF, CR, and NUL bytes, else Error::BadInput.

Source

pub fn raw_params(self, raw: &[u8]) -> Result<Self, Error>

Byte-exact re-encode path: emit raw verbatim as the header parameter bytes (everything after "YUV4MPEG2 ", LF excluded) instead of building canonical tags.

raw must be a well-formed single-line parameter list: SP-separated parameters, each a single ASCII letter tag followed by a value of one byte or more, with no empty parameter (no leading, trailing, or doubled SP) and no LF, CR, or NUL byte. A violation is Error::BadInput, returned before anything is written, so the header can never span two lines. The list is then parsed with the decoder’s grammar, so a missing W or H, a zero dimension, or an unknown C value returns the decoder’s error for it. Frame geometry for plane validation is derived from the list, overriding the builder’s width, height, and colorspace. Pass Decoder::raw_params to reproduce a decoded stream byte-for-byte.

Source

pub fn write_header<W: Write>(self, writer: W) -> Result<Encoder<W>, Error>

Writes the stream header and returns the frame encoder.

Zero dimensions or a zero framerate denominator are Error::BadInput. Plane-size overflow and an over-budget header line are Error::Limits. The high-bit-depth scratch buffer is allocated here, once.

Trait Implementations§

Source§

impl Clone for EncoderBuilder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for EncoderBuilder

Source§

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

Formats the value using the given formatter. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.