Artifact reduction is a vital process for improving the quality of video sources, particularly those that have been heavily compressed or poorly encoded. Artifacts manifest as visual distortions and can significantly detract from the viewing experience. This guide explores the most common artifacts in depth, including practical solutions tailored to address them.
Blocking is common in heavily compressed content and can be particularly challenging to address.
Deblock
clip = core.deblock.Deblock(clip, quant=25)
quant
: Adjust to control the intensity. Start at 20 for mild blocking and increase for severe cases.clip = core.deblock.Deblock(clip, quant=18)
clip = core.knlm.KNLMeansCL(clip, d=1, h=0.8)
quant
values to refine the results.
clip = core.deblock.Deblock(clip, quant=22)
clip = core.deblock.Deblock(clip, quant=16)
Banding occurs in gradients and smooth transitions. It’s especially noticeable in skies, shadows, and HDR content.
f3kdb
clip = core.f3kdb.Deband(clip, range=18, y=64, cb=64, cr=64, grainy=16, grainc=16)
range
: Increase for stronger debanding.grainy
, grainc
: Adds dithering to hide residual bands.mask = core.std.Binarize(clip.std.PlaneStats(), threshold=150)
clip = core.std.MaskedMerge(clip, debanded_clip, mask)
clip = core.f3kdb.Deband(clip, range=20, y=80, cb=80, cr=80, grainy=20, grainc=20)
Ringing can be subtle but becomes highly distracting when sharpening filters are over-applied.
dering
clip = core.dering.Dering(clip, strength=30)
strength
: Adjust based on the severity of the ringing.edges = core.std.Prewitt(clip)
filtered = core.dering.Dering(clip, strength=25)
clip = core.std.MaskedMerge(clip, filtered, edges)
Mosquito noise clusters around edges and often requires a combination of temporal and spatial filtering.
HQDN3D
clip = core.hqdn3d.HQDenoise3D(clip, luma_spatial=4.0, luma_temporal=6.0)
clip = core.knlm.KNLMeansCL(clip, d=2, h=1.0)
For sources with a mix of artifacts, use versatile tools like SMDegrain
:
SMDegrain
clip = core.smd.SMD(clip, tr=3, thSAD=300)
tr
: Temporal radius for analyzing frames.thSAD
: Adjust to control the sensitivity.clip = core.deblock.Deblock(clip, quant=16)
clip = core.smd.SMD(clip, tr=2, thSAD=200)
Here’s a full script addressing multiple artifacts:
import vapoursynth as vs
core = vs.core
# Load source
clip = core.ffms2.Source("artifacted_source.mkv")
# Step 1: Deblocking
clip = core.deblock.Deblock(clip, quant=20)
# Step 2: Debanding
clip = core.f3kdb.Deband(clip, range=18, y=64, cb=64, cr=64, grainy=16, grainc=16)
# Step 3: Deringing
clip = core.dering.Dering(clip, strength=30)
# Step 4: Mosquito Noise Reduction
clip = core.hqdn3d.HQDenoise3D(clip, luma_spatial=4.0, luma_temporal=6.0)
# Output
clip.set_output()
Artifact reduction requires a keen eye and patience. Each type of artifact demands specific techniques, and combining them thoughtfully will yield clean, high-quality results. Always preview your changes and test on small clips before committing to a full encode.