pub struct HistogramExtractor { /* private fields */ }Expand description
Extracts per-channel color histograms at configurable frame intervals.
Decodes the input video via VideoDecoder with RGB24 output conversion
so that histogram accumulation is a simple one-pass loop with no additional
format dispatch. FFmpeg’s histogram filter is deliberately not used
because it produces video output rather than structured data.
§Examples
use ff_decode::HistogramExtractor;
let histograms = HistogramExtractor::new("video.mp4")
.interval_frames(30)
.run()?;
for h in &histograms {
println!("Frame at {:?}: r[255]={}", h.timestamp, h.r[255]);
}Implementations§
Source§impl HistogramExtractor
impl HistogramExtractor
Sourcepub fn new(input: impl AsRef<Path>) -> Self
pub fn new(input: impl AsRef<Path>) -> Self
Creates a new extractor for the given video file.
The default sampling interval is every frame (interval_frames = 1).
Call interval_frames to sample less frequently.
Sourcepub fn interval_frames(self, n: u32) -> Self
pub fn interval_frames(self, n: u32) -> Self
Sets the frame sampling interval.
A value of N means one histogram is computed per N decoded frames.
For example, interval_frames(30) on a 30 fps video yields roughly one
histogram per second.
Passing 0 causes run to return
DecodeError::AnalysisFailed.
Default: 1 (every frame).
Sourcepub fn run(self) -> Result<Vec<FrameHistogram>, DecodeError>
pub fn run(self) -> Result<Vec<FrameHistogram>, DecodeError>
Runs histogram extraction and returns one FrameHistogram per
sampled frame.
Frames are decoded as RGB24 internally; all pixel format conversion is
handled by FFmpeg’s software scaler.
§Errors
DecodeError::AnalysisFailed—interval_framesis0, the input file is not found, or a decode error occurs.- Any
DecodeErrorpropagated fromVideoDecoder.