Skip to content

Decombing

currentMigrated from docs/filtering/decombing.mdx at 37c3317fd058; modified for Encode Wiki · CC BY-SA 4.0

Combing is the set of horizontal teeth along moving edges that appear when two fields from different moments are shown as one frame. Decombing fixes only the frames or areas that have it and leaves the rest alone. It is what you want when most of a video is clean progressive and a minority of frames are not, and it is the wrong tool for video that is combed throughout, which needs a proper deinterlace.

  • Hybrid sources. Film that was telecined, with credits, titles or inserted footage that were added at video rate. After IVTC the film is clean and those sections are still combed.
  • Failed field matching. Bad edits, cadence changes, orphaned fields. A handful of frames come out with two different film frames woven together.
  • Interlaced video encoded as progressive. Many web rips and re-encodes were never deinterlaced and are flagged progressive, so nothing in the container tells a player to deinterlace.
  • Resized interlaced footage, which smears the combing into soft ghosting.

Ghosting from blended fields (a double image rather than teeth) can’t be fixed by a deinterlacer, because the two moments are already averaged together. That needs deblending, which is a separate and difficult problem.

Look at a moving edge at 1:1 in a previewer. Combing is a regular alternating-line tooth pattern along the edge; it is easy to miss when the picture is scaled. idet gives an overview of the video:

Terminal window
ffmpeg -i input.mkv -vf idet -f null -

If a video flagged progressive still shows a large TFF or BFF count, parts of it are interlaced. Static scenes classify as progressive whatever the source was, so a count is a hint, not a map. Scrub through credits, scene cuts and the places where IVTC is likely to have slipped.

The most reliable approach is to let the field matcher find combed frames and apply a deinterlacer to those alone. In FFmpeg the field-matching IVTC chain does this, because fieldmatch marks the frames it could not repair and deint=interlaced makes yadif process only those:

Terminal window
ffmpeg -i input.mkv -vf "fieldmatch,yadif=deint=interlaced,decimate" -c:v libx264 -crf 18 output.mkv

This also decimates, so only use it on telecined sources. In VapourSynth, vfm from vs-jetpack accepts a postprocess function that runs on whatever it still sees as combed, without necessarily decimating:

from vsaa import NNEDI3
from vsdeinterlace import vfm
clip = vfm(clip, tff=True, postprocess=NNEDI3(double_rate=False).deinterlace)

Detection is controlled by cthresh (how strong combing must be at a pixel; defaults to 9) and mi (how many combed pixels in a block make the frame count as combed; defaults to 80). Sharp, high-contrast detail such as text and animation lines can be flagged falsely when the thresholds are too low, and faint combing is missed when they are too high. Set chroma=False only when chroma problems such as rainbowing cause false detections.

For light combing left in an otherwise progressive video, vinverse removes it by blurring vertically and then restoring detail:

from vsdeinterlace import vinverse
clip = vinverse(clip, amnt=255)

amnt limits how far any pixel may change (in 8-bit units); 255 means no limit. Because it filters every frame, it softens clean frames slightly, so apply it to the affected sections only: trim them out, filter, and join them back.

Decombing wrongly applied to clean frames costs detail for nothing, so verify what the detector flags. The opposite mistake, leaving combing in the encode, is much more visible once the video is scaled up or played on a high-resolution display. If you find that most of the video is combed, stop decombing and deinterlace it.