Skip to main content

HistogramExtractor

Struct HistogramExtractor 

Source
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

Source

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.

Source

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

Source

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

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.