Skip to main content

BlackFrameDetector

Struct BlackFrameDetector 

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

Detects black intervals in a video file and returns their start timestamps.

Uses FFmpeg’s blackdetect filter to identify frames or segments where the proportion of “black” pixels exceeds threshold. One Duration is returned per detected black interval (the start of that interval).

§Examples

use ff_decode::BlackFrameDetector;

let black_starts = BlackFrameDetector::new("video.mp4")
    .threshold(0.1)
    .run()?;

for ts in &black_starts {
    println!("Black interval starts at {:?}", ts);
}

Implementations§

Source§

impl BlackFrameDetector

Source

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

Creates a new detector for the given video file.

The default threshold is 0.1 (10% of pixels must be below the blackness cutoff for a frame to count as black).

Source

pub fn threshold(self, t: f64) -> Self

Sets the luminance threshold for black-pixel detection.

Must be in the range [0.0, 1.0]. Higher values make the detector more permissive (more frames qualify as black); lower values are stricter. Passing a value outside this range causes run to return DecodeError::AnalysisFailed.

Default: 0.1.

Source

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

Runs black-frame detection and returns the start Duration of each detected black interval.

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