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
impl EncoderBuilder
Sourcepub fn new(width: usize, height: usize, framerate: Ratio) -> Self
pub fn new(width: usize, height: usize, framerate: Ratio) -> Self
Starts a builder with the three required stream parameters.
Sourcepub fn colorspace(self, cs: Colorspace) -> Self
pub fn colorspace(self, cs: Colorspace) -> Self
Sets the colorspace tag. Default: plain C420.
Sourcepub fn pixel_aspect(self, aspect: Ratio) -> Self
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.
Sourcepub fn interlace(self, interlace: Interlace) -> Self
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.
Sourcepub fn extension(self, value: &[u8]) -> Result<Self, Error>
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.
Sourcepub fn raw_params(self, raw: &[u8]) -> Result<Self, Error>
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.
Sourcepub fn write_header<W: Write>(self, writer: W) -> Result<Encoder<W>, Error>
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.