Skip to main content

FrameExtractor

Struct FrameExtractor 

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

Extracts packed RGB/gray frames from a video input, one pass, for AI/CV.

Build one with FrameExtractor::new, chain options, then call frames for a streaming iterator or collect_frames for a Vec.

Implementations§

Source§

impl FrameExtractor

Source

pub fn new(input: impl Into<Input>) -> Self

Creates an extractor over input (a path, URL, or anything convertible into an Input). Defaults: all frames, source size, Rgb24, ColorPolicy::Tagged, channel capacity 1.

Source

pub fn sampling(self, sampling: Sampling) -> Self

Sets the sampling strategy (default Sampling::All).

Source

pub fn video_stream_index(self, index: usize) -> Self

Selects an explicit video stream by absolute index (default: best video stream). Also pins the input-side per-frame HDR guard / color stamp to that stream — without it they bind to the first video stream, which coincides with the exported one except on exotic multi-video layouts.

Source

pub fn width(self, width: u32) -> Self

Sets the output width in pixels; height (if unset) is derived keeping the aspect ratio (scale=W:-2).

Source

pub fn height(self, height: u32) -> Self

Sets the output height in pixels; width (if unset) is derived keeping the aspect ratio (scale=-2:H).

Source

pub fn pixel(self, layout: PixelLayout) -> Self

Sets the packed pixel layout (default PixelLayout::Rgb24).

Source

pub fn color(self, policy: ColorPolicy) -> Self

Sets the color-interpretation policy (default ColorPolicy::Tagged).

Source

pub fn conversion_precision(self, precision: ConversionPrecision) -> Self

Sets the swscale precision tier for the conversion stage — the single swscale pass that runs any resize plus the pixel-format conversion (default ConversionPrecision::Standard, which matches the FFmpeg CLI’s default scaler flags). ConversionPrecision::High opts into accurate rounding + full chroma interpolation at a several-fold conversion cost — see the enum docs for the tradeoff.

Source

pub fn max_frames(self, max: u64) -> Self

Caps the number of exported frames. The sink owns this exact count.

Source

pub fn start_time_us(self, us: i64) -> Self

Seeks to this start time (microseconds) before extracting.

Source

pub fn duration_us(self, us: i64) -> Self

Limits extraction to this many microseconds of content past the start.

Source

pub fn duration_hint_us(self, us: i64) -> Self

Supplies a duration (microseconds) for UniformN when the input is not probeable (live/piped). Ignored by other sampling modes. Takes precedence over the container/stream duration, but not over an explicit duration_us trim window.

Source

pub fn channel_capacity(self, capacity: usize) -> Self

Sets the prefetch channel capacity (default 1, minimum 1). Each slot costs one packed frame of memory.

Source

pub fn frames(self) -> Result<FrameIter>

Starts the run and returns a streaming iterator over the exported frames.

Option and stream/HDR resolution errors surface here, before any frame is produced; runtime failures surface as the iterator’s terminal Err.

Source

pub fn collect_frames(self) -> Result<Vec<VideoFrame>>

Runs to completion and collects every exported frame into a Vec.

On a terminal error the partial frames are dropped and the error is returned; use frames to keep partial output.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,