Skip to main content

Decoder

Struct Decoder 

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

Unified video decoder that auto-selects the best available backend.

See the crate-level example for typical usage.

Implementations§

Source§

impl Decoder

Source

pub fn from_file<P: AsRef<Path>>(input: P) -> Result<Decoder, DecoderError>

Creates a new decoder from a file path, auto-selecting the backend.

Priority: Y4M → FFMS2 → FFmpeg → VapourSynth.

§Errors

Returns DecoderError::FileReadError if the file cannot be opened, DecoderError::NoDecoder if no backend is available for the format.

Source

pub fn from_stdin() -> Result<Decoder, DecoderError>

Creates a decoder that reads Y4M data from stdin.

§Errors

Returns DecoderError::EndOfFile if stdin is empty, DecoderError::GenericDecodeError if the Y4M header is invalid.

Source

pub fn from_decoder_impl( decoder_impl: DecoderImpl, ) -> Result<Decoder, DecoderError>

Creates a decoder from a specific DecoderImpl variant, bypassing auto-detection.

Prefer from_file, from_script, or from_stdin unless you need direct backend control.

§Errors

Returns DecoderError if video metadata cannot be extracted from the implementation.

Source

pub fn get_video_details(&self) -> &VideoDetails

Returns the video metadata detected during initialization.

Source

pub fn set_luma_only(&mut self, enabled: bool)

Sets the decoder to only fetch the luma planes from the video. This may improve performance for applications that do not need chroma data.

Source

pub fn read_video_frame<T: Pixel>(&mut self) -> Result<Frame<T>, DecoderError>

Decodes and returns the next video frame.

T must match the video’s bit depth: u8 for 8-bit, u16 for 10–16 bit.

§Errors

Returns DecoderError::EndOfFile at end of stream, DecoderError::GenericDecodeError on corrupted data.

Each frame contains uncompressed pixel data; avoid holding frames longer than needed.

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> 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, 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.