Skip to main content

QualityMetrics

Struct QualityMetrics 

Source
pub struct QualityMetrics;
Expand description

Computes video quality metrics between a reference and a distorted video.

All methods are static — there is no state to configure.

Implementations§

Source§

impl QualityMetrics

Source

pub fn ssim( reference: impl AsRef<Path>, distorted: impl AsRef<Path>, ) -> Result<f32, FilterError>

Computes the mean SSIM (Structural Similarity Index Measure) over all frames between reference and distorted.

Returns a value in [0.0, 1.0]:

  • 1.0 — the inputs are frame-identical.
  • 0.0 — no structural similarity.

Uses FFmpeg’s ssim filter internally. Both inputs must have the same frame count; if they differ the function returns an error rather than silently comparing only the overlapping portion.

§Errors
  • FilterError::AnalysisFailed — either input file is not found, the inputs have different frame counts, or the internal filter graph fails.
§Examples
use ff_filter::QualityMetrics;

// Compare a video against itself — should return ≈ 1.0.
let ssim = QualityMetrics::ssim("reference.mp4", "reference.mp4")?;
assert!(ssim > 0.9999);
Source

pub fn psnr( reference: impl AsRef<Path>, distorted: impl AsRef<Path>, ) -> Result<f32, FilterError>

Computes the mean PSNR (Peak Signal-to-Noise Ratio, in dB) over all frames between reference and distorted.

Uses the luminance (Y-plane) PSNR as the representative value.

  • Identical inputs → f32::INFINITY (MSE = 0).
  • Lightly compressed → typically > 40 dB.
  • Heavy degradation → typically < 30 dB.

Uses FFmpeg’s psnr filter internally. Both inputs must have the same frame count; if they differ the function returns an error.

§Errors
  • FilterError::AnalysisFailed — either input file is not found, the inputs have different frame counts, or the internal filter graph fails.
§Examples
use ff_filter::QualityMetrics;

// Compare a video against itself — should return infinity.
let psnr = QualityMetrics::psnr("reference.mp4", "reference.mp4")?;
assert!(psnr > 100.0 || psnr == f32::INFINITY);

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.