Vapoursynth TemporalDegrain2: Difference between revisions

From wiki.selur.net
Jump to navigation Jump to search
New filter page (via create-page on MediaWiki MCP Server)
 
Update to current Hybrid behaviour; code as <pre> (via update-page on MediaWiki MCP Server)
 
Line 77: Line 77:
== Example ==
== Example ==
Default settings on a 10-bit YUV 4:2:0 source:
Default settings on a 10-bit YUV 4:2:0 source:
<syntaxhighlight lang="python">
<pre>
# removing grain using TemporalDegrain2
# removing grain using TemporalDegrain2
clip = degrain.TemporalDegrain2(clip, degrainPlane=4, postFFT=0, fftThreads=1, SrchClipPP=3, tools={'mv': 'mvutensils', 'expr': 'akarin', 'dfttest': 'neo_fft', 'nlmeans': 'knlm', 'rg': 'zsmooth', 'median': 'zsmooth', 'tcanny': 'tcanny', 'fft3d': 'neo_fft'})
clip = degrain.TemporalDegrain2(clip, degrainPlane=4, postFFT=0, fftThreads=1, SrchClipPP=3, tools={'mv': 'mvutensils', 'expr': 'akarin', 'dfttest': 'neo_fft', 'nlmeans': 'knlm', 'rg': 'zsmooth', 'median': 'zsmooth', 'tcanny': 'tcanny', 'fft3d': 'neo_fft'})
</syntaxhighlight>
</pre>


== How Hybrid calls it ==
== How Hybrid calls it ==

Latest revision as of 09:53, 16 November 2026

TemporalDegrain2 is ErazorTT's improved TemporalDegrain: a strong temporal degrainer with QTGMC-style motion estimation, two motion-compensated degrain stages, an optional motion-compensated post denoiser and contra-sharpening. It handles low-contrast areas and diverging motion better than the original.

Filtering → Vapoursynth → DeGrain

TemporalDegrain2 controls in Hybrid
TemporalDegrain2 controls in Hybrid

What it does

  1. A blurred, gamma-adjusted search clip is built and the motion is searched on it (with global motion and lambda tuning as in QTGMC).
  2. Stage 1: MDegrain, limited to what an FFT3D "limit" clip changes.
  3. Stage 2: a second MDegrain.
  4. Optionally a motion-compensated post denoiser (FFT3D, DFTTest or KNLMeansCL) and a contra-sharpening.

Most thresholds follow GrainLevel unless they are set by hand.

Settings

DeGrain

Control Parameter Range / values Hybrid default Meaning
Radius degrainTR 0 – 3 1 Frames on each side for the degrain stages; 0 = no MDegrain. More than about fps/8 rarely helps.
Planes degrainPlane all, luma only, chroma only all Planes that are degrained (chroma only = both chroma planes).
GrainLevel grainLevel -2 – 3 2 Sets the automatic SAD/SCD thresholds, search clip and limit values.
GrainLevelSetup grainLevelSetup on/off off Setup aid: shows stage 0 with radius 3 to choose the grain level; ignores the other settings.
SAD1 / SAD2 ppSAD1, ppSAD2 2 – 64000 automatic (11 / 7 at grain level 2) Per-pixel SAD thresholds of the two stages; set by hand with the check box.
SCD1 / SCD2 ppSCD1, thSCD2 1 – 255 automatic (5 at grain level 2) / 128 Scene change thresholds; SCD2 on a 0–255 scale (128 ≈ 50 %).
Limit sigma limitSigma 0 – 40 automatic Strength of the FFT3D limit clip; by hand with the check box. Automatically chosen from the resolution and grain level.
Limit blocksize limitBlksz 4, 8, 12, 16, 24, 32, 64, 96 automatic Block size of the FFT3D limit clip; by hand with the check box.
DCT DCT 11 MVTools DCT modes usual spatial blocks Block comparison mode; with SATD the SAD thresholds are raised by 1.7.

Motion Estimation

Control Parameter Range / values Hybrid default Meaning
Algo meAlg onetime, nStep, logarithmic, exhaustive, hexagon, UMH, pure horizontal, pure vertical hexagon Search algorithm.
Algo param. meAlgPar 1 – 64 automatic (2) Search range parameter; by hand with the check box.
Subpixel search meSubpel 1, 2, 4 automatic Subpixel accuracy; automatically 4 for SD, 2 for HD, 1 above 1080p.
Blocksize meBlksz 4 – 128 automatic Block size; automatically 8 up to 720p, 16 for 1080p, 32 above.
TM / Chroma / Global / Recalculate meTM, ChromaMotion, GlobalMotion, rec on/off off / on / on / off Truemotion, chroma in the search, global motion, refinement pass.
Search clip SrchClipPP 0 – 3 3 Search clip preprocessing: 0 none, 1 bilinear blur, 2 TCanny blur, 3 blur with limited merge.
Subpixel interp. SubPelInterp soft, bicubic, sharper Wiener sharper Wiener Interpolation for the subpixel search.

Post-processing

Control Parameter Range / values Hybrid default Meaning
Method postFFT none, FFT3D, DFTTest, KNLMeansCL none Post denoiser after the degrain stages.
Radius postTR 0 (spatial only), 1 (3 frames), 2 (5 frames), 3 (7 frames) 1 (3 frames) Temporal radius of the post denoiser; FFT3D allows at most 2.
Sigma postSigma 0 – 40 1 Strength of the post denoiser.
FFT threads fftThreads 1 – 16 1 Threads for the FFT3D limit and post filters.
DeviceID knlDevId 0 – 4 0 GPU for KNLMeansCL.
Sharpen extraSharp on/off off Stronger contra-sharpening (radius 3 instead of 1).

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

Example

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

# removing grain using TemporalDegrain2
clip = degrain.TemporalDegrain2(clip, degrainPlane=4, postFFT=0, fftThreads=1, SrchClipPP=3, tools={'mv': 'mvutensils', 'expr': 'akarin', 'dfttest': 'neo_fft', 'nlmeans': 'knlm', 'rg': 'zsmooth', 'median': 'zsmooth', 'tcanny': 'tcanny', 'fft3d': 'neo_fft'})

How Hybrid calls it

  • TemporalDegrain2 works on 8–16-bit integer YUV and gray clips; interlaced material is handled by Hybrid's general field handling.
  • Values behind a check box are written whenever the check box is ticked; the search clip setting, planes, post method and FFT threads are always written; other values only when they differ from the defaults.
  • The limit settings are disabled with radius 0, the post radius and sigma without a post method.
  • TemporalDegrain2 also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

The script

The VapourSynth port follows ErazorTT's AviSynth TemporalDegrain v2 (doom9 thread "TemporalDegrainV2", 2018). Its recommendation: start with the defaults; for strong cleaning find the noisiest area, use GrainLevelSetup to choose a grain level from 0 to 3, then try the FFT3D post denoiser with a sigma around 1. For more, raise the radius rather than the sigma; above sigma 3, or when banding appears, use DFTTest.

Sources