How to Use FFmpeg Identity Filter to Verify Video

This guide explains how to use the FFmpeg identity filter to compare two video streams and verify that a video remains completely unchanged after processing, transmission, or container swapping. By evaluating two video inputs frame by frame and pixel by pixel, the identity filter provides quantitative verification metrics directly in your terminal or log files.

What the identity Filter Does

The identity video filter in FFmpeg takes two video streams as inputs—typically an original reference video and a modified or suspected copy—and compares each corresponding frame. It calculates the degree of similarity, reporting exact match statistics across all color planes (such as Y, U, V, or R, G, B). If any pixel differs between the two files, the filter exposes the discrepancy.

Basic Command Syntax

To compare two videos, feed both files into FFmpeg and map their video streams into the identity filter using -filter_complex:

ffmpeg -i original.mp4 -i modified.mp4 -filter_complex "[0:v][1:v]identity" -f null -
  • -i original.mp4: Specifies the reference input video (stream 0:v).
  • -i modified.mp4: Specifies the processed input video (stream 1:v).
  • -filter_complex "[0:v][1:v]identity": Feeds both video streams into the identity filter.
  • -f null -: Discards the processed output so FFmpeg runs as fast as possible without creating a new media file.

Reading the Verification Output

Once execution completes, FFmpeg prints summary metrics to standard error. Look for lines similar to:

[Parsed_identity_0 @ 0x...] Identity Y:1.000000 U:1.000000 V:1.000000 All:1.000000
  • All: 1.000000: A value of 1.0 across all color planes confirms that 100% of the pixels in every frame match identically. The video stream is completely unchanged.
  • Values less than 1.0: Indicates that some pixels differ. For example, All: 0.998421 means that compression artifacts, colorspace shifts, or precision loss modified the video stream.

Exporting Per-Frame Results to a File

If you need automated checks or per-frame auditing, direct the filter output to a log file using the stats_file option:

ffmpeg -i original.mp4 -i modified.mp4 -filter_complex "[0:v][1:v]identity=stats_file=identity.log" -f null -

The resulting identity.log contains detailed metrics for every single frame, allowing you to locate the exact timestamps where any alterations occurred.

Common Requirements for Accurate Verification

For the identity filter to run without errors:

  1. Matching Resolutions: Both inputs must have identical frame dimensions (width and height).
  2. Matching Pixel Formats: Both videos must share the same pixel format (for example, yuv420p). If one video was converted to another format, use the format filter before the comparison to align them.
  3. Matching Frame Counts: The comparison proceeds until the shorter stream reaches its end. Ensure frame rates and durations match so the full duration is evaluated.