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
impl BlackFrameDetector
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 threshold is 0.1 (10% of pixels must be below the
blackness cutoff for a frame to count as black).
Sourcepub fn threshold(self, t: f64) -> Self
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.
Sourcepub fn run(self) -> Result<Vec<Duration>, DecodeError>
pub fn run(self) -> Result<Vec<Duration>, DecodeError>
Runs black-frame detection and returns the start Duration of each
detected black interval.
§Errors
DecodeError::AnalysisFailed—thresholdoutside[0.0, 1.0], input file not found, or an internal filter-graph error.