Skip to main content

ThumbnailPipeline

Struct ThumbnailPipeline 

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

Extracts still frames from a video file at requested timestamps.

§Construction

Use the consuming builder pattern:

use ff_pipeline::ThumbnailPipeline;

let frames = ThumbnailPipeline::new("video.mp4")
    .timestamps(vec![0.0, 5.0, 10.0])
    .run()?;

Implementations§

Source§

impl ThumbnailPipeline

Source

pub fn new(path: &str) -> ThumbnailPipeline

Creates a new pipeline for the given file path.

Source

pub fn timestamps(self, times: Vec<f64>) -> ThumbnailPipeline

Sets the timestamps (in seconds) at which to extract frames.

Source

pub fn output_dir(self, dir: impl AsRef<Path>) -> ThumbnailPipeline

Set output directory for run_to_files().

Source

pub fn width(self, w: u32) -> ThumbnailPipeline

Limit thumbnail width; height is scaled proportionally.

Only used by run_to_files().

Source

pub fn quality(self, q: u32) -> ThumbnailPipeline

JPEG quality 0–100.

Only used by run_to_files().

Source

pub fn run(self) -> Result<Vec<VideoFrame>, PipelineError>

Runs the pipeline and returns one VideoFrame per requested timestamp.

Timestamps are processed in ascending order. If timestamps is empty, the file is never opened and Ok(vec![]) is returned immediately.

When the parallel feature is enabled, each timestamp is decoded in its own thread via rayon. Each thread opens an independent VideoDecoder; no decoder context is shared. The output order matches the ascending timestamp order regardless of which thread finishes first.

§Errors

Propagates PipelineError::Decode for any decoding or seek failure.

Source

pub fn run_to_files(self) -> Result<Vec<PathBuf>, PipelineError>

Runs the pipeline, writes each frame as a JPEG to output_dir, and returns the written paths in timestamp order.

File names: thumb_0000.jpg, thumb_0001.jpg, … (zero-padded index). When .width() is set, height is scaled proportionally.

§Errors

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