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_decode::SceneDetector;
let cuts = SceneDetector::new("video.mp4")
.threshold(0.3)
.run()?;
for ts in &cuts {
println!("Scene change at {:?}", ts);
}Implementations§
Source§impl SceneDetector
impl SceneDetector
Sourcepub fn new(input: impl AsRef<Path>) -> Self
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.
Sourcepub fn threshold(self, t: f64) -> Self
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 DecodeError::AnalysisFailed.
Default: 0.4.
Sourcepub fn run(self) -> Result<Vec<Duration>, DecodeError>
pub fn run(self) -> Result<Vec<Duration>, DecodeError>
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
DecodeError::AnalysisFailed— threshold outside[0.0, 1.0], input file not found, or an internal filter-graph error.