Delta file (difference file)

Problem

Compare two video files by using a delta file (difference file).

Solution

ffmpeg \
    -i input_file_1 \
    -i input_file_2 \
    -filter_complex \
        "[1]format=yuva444p, \
            lut=c3=128, \
            negate[1_with_alpha]; \
         [0][1_with_alpha]overlay[out]" \
    -map "[out]" \
    output_file

Command syntax

ffmpeg
starts the command
-i input_file_1
path, name and extension of the first input files
-i input_file_2
path, name and extension of the second input files
-filter_complex
A complex filter graph is needed:
  • three filters are applied successively to the second input file (this is a filter chain):
    • an alpha channel is added,
    • the alpha channel is set to “medium grey” and
    • the colours are inverted;
  • the overlay between the first input file and the colour-inverted second input file gives the difference.
-map "[out]"
maps the [out] stream to the output
output_file
path, name and extension of the output file

Discussion

A delta file is useful for comparing files with little differences, while for comparing files with big differences a split screen may be a better choice.

The different filters of a filter chain are divided by a comma (,). The different filter chains of a filter graph are divided by a semi-colon (;). If the whole filter graph is put into quotation marks, then spaces can be added after , and ; for readability reasons.

The mapping is not necessary in this case, because it’s implicit.

Exercises

  • alpha channel set to another colour than “medium grey”
  • delta file of input files with 10-bit per colour channel

2020-11-22