Avisynth common filter options

From wiki.selur.net
Revision as of 18:45, 21 November 2026 by Selur (talk | contribs) (Avisynth filter documentation (via create-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Besides its own settings, every Avisynth filter in Hybrid can have a few common option groups. They sit to the right of the filter's own controls and decide where and how much the filter is applied: only through a mask, only on part of the frame, only on some frames, blended with the original, or on a turned/scaled copy of the frame. Which groups a filter offers depends on the filter.

The groups can be shown or hidden under Filtering → Avisynth → Misc → UI (Show mask controls, Show merge controls, Show frame range controls, Show region controls, Show gimmick controls, Show 'Reset'-controls). Hiding a group does not reset or switch off its settings.

In the script the groups act from the outside in: a copy of the clip from before the filter is kept, Region crops the frame, Gimmick changes the frame before the filter and undoes it afterwards, and after the filter come the overlay of the region, Merge, Masked, and finally the frame selection of ApplyOnlyTo (Range, then Every). The copy of the unfiltered clip is only made when one of these groups is active.

Masked

Masked group
Masked group

Applies the filter only where a mask allows it: the filtered clip is used where the mask is white, the unfiltered clip where it is black (mt_merge). The masks need the masktools2 plugin, which Hybrid loads automatically.

Control Default Meaning
Mask LimitMask Kind of mask. Every mask has its own page of controls.

Masks and their controls:

  • LimitMask: Limit 1–254 (default 30, on the 8-bit scale). The mask is built from the difference between the unfiltered and the filtered clip: it is white where the difference is larger than the limit. With invert on (default) it is white where the difference is smaller than the limit, so the filter only applies where it changed little.
  • RectangleMask: a rectangle given by Left, Top, Right and Bottom (0–32768, default 0). The values are margins from the frame edges; invert swaps inside and outside. If all four are 0, the whole frame is filtered.
  • EdgeMask (Sobel), EdgeMask (Prewitt), EdgeMask (Roberts), EdgeMask (Cartoon): masks of the edges of the unfiltered picture. They have invert, binarize with a threshold (0–255, default 128) and show.
  • MotionMask: marks moving areas. Low, High and Scene (0–255, default 10 each) are the thresholds of the motion detection; plus invert, binarize with threshold and show.

binarize turns the mask into pure black/white at the threshold, invert swaps black and white (binarize is applied first). show shows the mask instead of the result in the preview; filters after it are skipped.

Example (Sobel edge mask, Levels on a 10-bit source):

SourceUnfiltered = last  # keeping the unfiltered clip for Levels
Levels(64,1.00,1023,0,1023)
SourceUnfilteredMask = mt_edge(SourceUnfiltered, mode="sobel")
mt_merge(SourceUnfiltered, last, SourceUnfilteredMask, luma=true)

OnRegion

OnRegion group
OnRegion group

Applies the filter only to a rectangle of the frame, given by X, Y, Width and Height (0–32768). It only acts when width and height are both set. The rectangle is cropped out before the filter and put back with Overlay afterwards. The region and the ApplyOnlyTo selection work independently: frames outside the selected range stay unfiltered in the whole region.

Example (region of 320 × 160 at 16/16):

SourceUnfiltered = last  # keeping the unfiltered clip for Levels
last.Crop(16,16,320,160)
Levels(64,1.00,1023,0,1023)
Overlay(SourceUnfiltered, last, x=16, y=16)

ApplyOnlyTo

ApplyOnlyTo group
ApplyOnlyTo group

Applies the filter only to selected frames. If both are ticked, Every wins over Range.

Control Default Meaning
Range – Frames to filter: a single frame (25), a range ([10 20]) or a mix ([10 20] 25 30). The entries are sorted, overlapping or adjacent ranges are joined and reversed ranges are skipped. The filtered and the unfiltered clip are joined with Trim; frames outside the ranges stay unfiltered.
Every: Cycle / Offsets 5 / – Cycle 2–100. In every group of Cycle frames only the frames at the given offsets (separated by spaces, from 0 to Cycle−1) are filtered; 0 3 with cycle 5 filters frames 0, 3, 5, 8, … Invalid and duplicate offsets are dropped. Without offsets Every is ignored; with all offsets listed the whole clip is filtered.

Example (Range [100 200]):

SourceUnfiltered = last  # keeping the unfiltered clip for Levels
Levels(64,1.00,1023,0,1023)
SourceUnfiltered.Trim(0,99) ++ last.Trim(100,200) ++ SourceUnfiltered.Trim(201,0)

Merge

Merge group
Merge group

Blends the filtered result with the unfiltered clip. The value is the share of the filtered result: 0 = unfiltered, 1 = fully filtered, 0.3 = 30 % filtered and 70 % original.

Control Range Default Meaning
Y 0 – 1 1 Share of the filtered result in luma.
C 0 – 1 1 Share of the filtered result in chroma.

If both values are 1, no merge is written at all, so the result is fully filtered. With equal values Merge is used; with different values luma and chroma are merged separately (MergeLuma, MergeChroma). The unfiltered clip that masks and the frame selection use afterwards stays untouched.

Example (0.3 for luma and chroma):

SourceUnfiltered = last  # keeping the unfiltered clip for Levels
Levels(64,1.00,1023,0,1023)
Merge(SourceUnfiltered, last, 0.3)

Gimmick

Gimmick group
Gimmick group

Changes the frame before the filter and undoes the change afterwards — useful for filters that only work in one direction or at a certain size.

  • Pre Color: converts the clip to the chosen color format (no change or any AviSynth+ format) before the filter. The clip is not converted back afterwards.
  • Restrict bit depth: do not (default), 8, 10, 16 or 32. Sets the bit depth the filter gets, if the filter supports that; otherwise the setting is ignored and a message is logged. The clip is not converted back afterwards.
  • Rotate: off, 90° clockwise (TurnRight), 90° counter-clockwise (TurnLeft) or 180° (Turn180).
  • Flip vertical / Flip horizontal (FlipVertical, FlipHorizontal).
  • Resize: scales the frame to an absolute size (default 48 × 48, 48–32768) or by a factor (0.0001–10, default 1; the result is rounded to an even size) with Bilinear, Bicubic, Lanczos, Point, Spline16, Spline36 (default) or Spline64. With Undo (default on) it is scaled back to the original size afterwards.
  • Compare Effect: only in the double view of the preview; the left side shows the clip before this filter, the right side the result. Filters after it are skipped.

The changes are applied in the order flips, resize, rotate and undone in exactly the reverse order: rotate, resize, flips. If nothing is chosen, nothing is written to the script.

Example (flip horizontal and rotate 90° clockwise):

# Gimmick for Levels
last.FlipHorizontal()
last.TurnRight()
Levels(64,1.00,1023,0,1023)
# undo Gimmick for Levels
last.TurnLeft()
last.FlipHorizontal()

Reset and FilterQueue buttons

  • Reset (next to the filter's check box, hidden unless enabled under Misc → UI) resets all settings of the filter to Hybrid's defaults.
  • Add to queue / Remove from queue: Add appends the filter with its current settings (including all groups above) to the filter queue, Remove deletes the last occurrence of this filter from the queue.

AviSynth has no Tools group.

See also: Vapoursynth common filter options

Sources