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
impl QualityMetrics
Sourcepub fn ssim(
reference: impl AsRef<Path>,
distorted: impl AsRef<Path>,
) -> Result<f32, FilterError>
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);Sourcepub fn psnr(
reference: impl AsRef<Path>,
distorted: impl AsRef<Path>,
) -> Result<f32, FilterError>
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);