@UnstableApi
public final class SsimHelper


A helper for calculating SSIM score for transcoded videos.

SSIM (Structural Similarity) Index is a statistical measurement of the similarity between two images. The mean SSIM score (taken between multiple frames) of two videos is a metric to determine the similarity of the videos. SSIM does not measure the absolute difference of the two images like MSE (mean squared error), but rather outputs the human perceptual difference. A higher SSIM score signifies higher similarity, while a SSIM score of 1 means the two images are exactly the same.

SSIM is traditionally computed with the luminance channel (Y), this class uses the luma channel (Y') because the decoder decodes to luma.

Summary

Constants

static final int

The default comparison interval.

Public methods

static double
calculate(
    Context context,
    String referenceVideoPath,
    String distortedVideoPath
)

Returns the mean SSIM score between the reference and the distorted video.

Constants

DEFAULT_COMPARISON_INTERVAL

public static final int DEFAULT_COMPARISON_INTERVAL = 11

The default comparison interval.

Public methods

calculate

public static double calculate(
    Context context,
    String referenceVideoPath,
    String distortedVideoPath
)

Returns the mean SSIM score between the reference and the distorted video.

The method compares every n-th frame from both videos.

Parameters
Context context

The Context.

String referenceVideoPath

The path to the reference video file, which must be in Assets.

String distortedVideoPath

The path to the distorted video file.

Throws
java.io.IOException

When unable to open the provided video paths.

java.lang.InterruptedException