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
impl Decoder
Sourcepub fn from_file<P: AsRef<Path>>(input: P) -> Result<Decoder, DecoderError>
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.
Sourcepub fn from_stdin() -> Result<Decoder, DecoderError>
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.
Sourcepub fn from_decoder_impl(
decoder_impl: DecoderImpl,
) -> Result<Decoder, DecoderError>
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.
Sourcepub fn get_video_details(&self) -> &VideoDetails
pub fn get_video_details(&self) -> &VideoDetails
Returns the video metadata detected during initialization.
Sourcepub fn set_luma_only(&mut self, enabled: bool)
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.
Sourcepub fn read_video_frame<T: Pixel>(&mut self) -> Result<Frame<T>, DecoderError>
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.