Skip to main content

SceneDetector

Struct SceneDetector 

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

Detects scene changes in a video file and returns their timestamps.

Uses FFmpeg’s select=gt(scene\,threshold) filter to identify frames where the scene changes. The threshold controls detection sensitivity: lower values detect more cuts (including subtle ones); higher values detect only hard cuts.

§Examples

use ff_analysis::SceneDetector;

let cuts = SceneDetector::new("video.mp4")
    .threshold(0.3)
    .run()?;

for ts in &cuts {
    println!("Scene change at {:?}", ts);
}

Implementations§

Source§

impl SceneDetector

Source

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

Creates a new detector for the given video file.

The default detection threshold is 0.4. Call threshold to override it.

Source

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

Sets the scene-change detection threshold.

Must be in the range [0.0, 1.0]. Lower values make the detector more sensitive (more cuts reported); higher values require a larger visual difference. Passing a value outside this range causes run to return AnalysisError::Failed.

Default: 0.4.

Source

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

Runs scene-change detection and returns one Duration per detected cut.

Timestamps are sorted in ascending order and represent the PTS of the first frame of each new scene.

§Errors
  • AnalysisError::Failed — threshold outside [0.0, 1.0], input file not found, or an internal filter-graph error.

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.