From Avisynth wiki
Jump to: navigation, search

Compares two clips (the "filtered" clip and the "original" clip) and returns the following data for each frame:

Mean Absolute Deviation 1
(minimum, average, maximum)
Mean Deviation
(minimum, average, maximum)
Max. Positive Deviation
Max. Negative Deviation
Peak Signal-to-Noise Ratio (PSNR) 2
(minimum, average, maximum)
(minimum, average, maximum)
Overall PSNR

These data are displayed on screen by default (see example image), or can optionally be written to a logfile.

By default a PSNR graph is displayed; this graph shows overall PSNR visually as a timeline that grows left-to-right along the bottom of the screen as the clip plays.

Syntax and Parameters

Compare(clip clip_filtered, clip clip_original
      [, string channels, string logfile, bool show_graph ] )

clip  clip_filtered, clip_original =

The "filtered" clip and the "original" clip. Size and color formats must match.
Color format may be RGB24, RGB32, YUY2 or YV12.
The "filtered" clip is returned.

string  channels = ""

Set the color channels to be compared with a combination of R,G,B [,A] or Y,U,V, depending on the source color format.
By default, all channels are compared.

bool  show_graph = true

If true, (the default) the PSNR graph is drawn on the screen.

string  logfile = ""

If specified, the results will be written to a file, and not drawn on the clip.
Using a logfile is much faster if you need to compare a lot of frames.


  • Basic usage – display differences on screen:
A=BicubicResize(640, 272)
B=A.Sharpen(1.0) ## Sharpen is our filter under test
return Compare(B, A)
  • Create a log file:
Compare(clip1, clip2, "", "compare.log")
  • Compare chroma channels only:
Compare(clip1, clip2, "UV")

External Links


v2.58 Added YV12 support.
Personal tools