Vapoursynth TemporalDegrain

From wiki.selur.net
Revision as of 09:52, 16 November 2026 by Selur (talk | contribs) (Update to current Hybrid behaviour; code as <pre> (via update-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

TemporalDegrain is a slow, thorough temporal degrainer for heavy, "dancing" grain. It combines an FFT3D prefilter, two motion-compensated degrain passes and a limited contra-sharpening.

Filtering → Vapoursynth → DeGrain

TemporalDegrain controls in Hybrid
TemporalDegrain controls in Hybrid

What it does

  1. An FFT3D prefilter builds a calm copy of the clip; the motion vectors are searched on it.
  2. A first MDegrain pass denoises the clip, but may not change it more than the FFT3D prefilter does.
  3. A second MDegrain pass denoises further.
  4. A contra-sharpening gives back sharpness, but never more than the source had.

With the higher filtering levels, Hqdn3d runs on the search clip and after the second pass.

Settings

General

Control Parameter Range / values Hybrid default Meaning
Filtering level HQ disable any prefiltering, extra prefiltering step, extra pre- and postfiltering step extra prefiltering step Hqdn3d on the search clip (and after the second pass).

Motion Estimation

Control Parameter Range Hybrid default Meaning
Block size blockSize 4, 8, 16, 32 16 Block size of the motion search.
Subpixel accuracy pel 1 – 2 2 Motion search precision.
Overlap overlapValue 0 – 16 block size / 2 Block overlap; without the check box the script uses half the block size.
Degrain degrain 1 – 3 2 Frames on each side used for degraining.
Degrain threshold 1/2 thrDegrain1, thrDegrain2 0 – 16000 400 / 300 SAD thresholds of the two degrain passes.
Max change maxPxChange 1 – 255 255 Maximum change of a pixel by the degraining.

FFT3D prefilter

Control Parameter Range Hybrid default Meaning
Block (width/height) blockWidth, blockHeight 4 – 512 16 / 16 FFT3D block size.
Sigma sigma 0 – 40 16 Denoising strength of the prefilter.
Sigma2/3/4 sigma2, sigma3, sigma4 0 – 40 sigma × 0.625 / 0.375 / 0.25 (10 / 6 / 4) Strength for the higher frequencies; without the check boxes derived from Sigma. Whole numbers are used.
Overlap width/height overlapWidth, overlapHeight 2 – 512 block size / 2 FFT3D block overlap; without the check box half the block size.

Tools: MV (mvutensils, mv, mvgpu), Expr (akarin, cranexpr, std), RG (zsmooth, neo_smo), Median (zsmooth) and FFT3D (neo_fft).

Example

Default settings on a 10-bit YUV 4:2:0 source:

# removing grain using TemporalDegrain
clip = degrain.TemporalDegrain(clip, tools={'mv': 'mvutensils', 'expr': 'akarin', 'rg': 'zsmooth', 'median': 'zsmooth', 'fft3d': 'neo_fft'})

How Hybrid calls it

  • TemporalDegrain works on 8–16-bit integer YUV and gray clips; interlaced material is handled by Hybrid's general field handling.
  • All values are only written when they differ from the defaults; values behind a check box only while it is ticked. The Tools choice is always written.
  • TemporalDegrain also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

The script

The function was written by Sagekilla from an idea and an AviSynth prototype by Didée (doom9 thread "Need Suggestions for VERY GRAINY source", 2007): FFT3D with sigma 16/10/6/4, two MDegrain passes and a limited sharpening.

Sources