Vapoursynth Temporalfix

From wiki.selur.net
Jump to navigation Jump to search

Temporalfix adds temporal consistency to clips upscaled with single-image AI models: lines and details that wobble or flicker from frame to frame are averaged over neighbor frames along the motion.

Filtering → Vapoursynth → Frame → Stabilize

Temporalfix controls in Hybrid
Temporalfix controls in Hybrid

What it does

Single-image upscalers treat each frame on its own, so fine lines often "wiggle" over time. Temporalfix stabilizes them by motion-compensated temporal averaging. There are two versions: the classic version runs on the CPU and works best for 2D animation; the Torch version uses an AI model, normally on the GPU. Frame ranges listed under Exclude are left untouched.

Requirements

  • Classic: CPU; the optional mvgpu motion search needs Vulkan.
  • Torch: Windows and Hybrid's torch add-on. The Torch checkbox is only enabled when the torch Temporalfix package is found. The cuda and tensorrt backends need an NVIDIA GPU (tensorrt an RTX card and vs-mlrt's TensorRT with Torch-TensorRT); directml needs vs-mlrt's ONNX Runtime and a DirectX 12 GPU; cpu runs without a GPU (slow).

Settings

Control Parameter Range / values Hybrid default Meaning
Torch – on/off off Switches between the classic and the Torch version.
Exclude exclude frame ranges, e.g. [10 20] [600 900] empty Frame ranges that are not processed.
Classic
Strength strength 0 – 10000 500 Suppression strength; 400–700 is usually good.
Temporal Radius tr 1 – 25 6 Frames that are averaged; higher is more stable, slower and needs more RAM.
Denoise denoise on/off off Also removes leftover grain and low-frequency flicker.
Debug debug on/off off Pink overlay on untouched areas; only used in Hybrid's preview, never in the encode.
Tools – MV: mvgpu, mvutensils; Expr: akarin; RG: zsmooth, neo_smo; Median: zsmooth, std; TMedian: zsmooth; BoxBlur: vszip, std; PlaneStats: vszip; EdgeMasks: edgemasks – Implementations used by the classic version.
Torch
Strength strength 0.0 – 3.0 2.0 Suppression strength.
Backend backend cuda, cpu, tensorrt, directml tensorrt (cuda when TensorRT is missing) Inference backend; only installed backends are listed.
GPU ID gpu_id 0 – 8 0 GPU to use; not for the cpu backend.
Tiles tiles 1 – 16 1 More tiles need less VRAM but are slower.
Streams num_streams 1 – 16 1 Parallel streams; only for TensorRT.

Example

Default settings on a 10-bit YUV 4:2:0 source (640x356):

# stabilizing using Temporalfix
clip = vs_temporalfix_classic.classic(clip, tools={'mv': 'mvutensils', 'expr': 'akarin', 'rg': 'zsmooth', 'median': 'zsmooth', 'tmedian': 'zsmooth', 'boxblur': 'vszip', 'planestats': 'vszip', 'edgemasks': 'edgemasks'})

How Hybrid calls it

  • Classic: works on 8–16-bit integer YUV in limited or full range (the script handles the range itself); processing is done internally in 16 bit, the motion search on an 8-bit prefiltered copy. Options are only written when they differ from the defaults.
  • Torch: the clip is converted to RGB half precision for tensorrt and directml and to float RGB for cuda and cpu. The backend is always written, the GPU ID (except for cpu) when it is not 0; Hybrid passes its own folder for the TensorRT engines.
  • With TensorRT the first run builds an engine, which can take minutes; it is rebuilt when strength or frame size change.
  • Frame count and frame rate do not change.

Background

Classic version

The classic version is based on SMDegrain/G41Fun-style degraining and SpotLess, with masks for areas that do not follow the global motion and color fixes. Its author recommends cropping black borders before using it.

Torch version

The model supports more backends (cpu, directml) and a GPU index; Hybrid offers cuda and TensorRT.

Sources