Skip to main content

KeyframeEnumerator

Struct KeyframeEnumerator 

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

Enumerates the timestamps of all keyframes in a video stream.

Reads only packet headers — no decoding is performed — making this significantly faster than frame-by-frame decoding. By default the first video stream is selected; call stream_index to target a specific stream.

§Examples

use ff_decode::KeyframeEnumerator;

let keyframes = KeyframeEnumerator::new("video.mp4").run()?;
for ts in &keyframes {
    println!("Keyframe at {:?}", ts);
}

Implementations§

Source§

impl KeyframeEnumerator

Source

pub fn new(input: impl AsRef<Path>) -> Self

Creates a new enumerator for the given video file.

The first video stream is used by default. Call stream_index to select a different stream.

Source

pub fn stream_index(self, idx: usize) -> Self

Selects a specific stream by zero-based index.

When not set (the default), the first video stream in the file is used.

Source

pub fn run(self) -> Result<Vec<Duration>, DecodeError>

Enumerates keyframe timestamps and returns them in presentation order.

§Errors
  • DecodeError::AnalysisFailed — input file not found, no video stream exists, the requested stream index is out of range, or an internal FFmpeg error occurs.

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.