Deinterlace Motion Heavy Video with FFmpeg Kerndeint

This guide explains how to use the kerndeint (Kernel Deinterlacer) filter in FFmpeg to effectively deinterlace videos containing high amounts of motion. You will learn the syntax of the filter, its key parameters, and practical command-line examples designed to eliminate interlacing artifacts—such as combing—while preserving motion clarity and edge sharpness.

Understanding the Kerndeint Filter

The kerndeint filter is a motion-adaptive deinterlacer that uses a kernel-based approach. Unlike basic deinterlacers that simply blend frames (causing motion blur) or discard fields (halving vertical resolution), kerndeint detects areas of motion and applies deinterlacing only where combing artifacts are present. This makes it highly effective for fast-moving content like sports or action footage.

Syntax and Parameters

The basic syntax for the filter is:

-vf "kerndeint=thresh:map:order:sharp:twoway"

To achieve the best results for highly motion-heavy video, you must configure these key parameters:

  • thresh (Threshold): Controls the sensitivity of motion detection. The range is 0 to 255 (default is 10). A lower threshold makes the filter more aggressive in deinterlacing, which is ideal for high-motion video to ensure no combing artifacts escape.
  • map (Map display): Set to 0 (default) for normal output. Setting it to 1 paints the detected motion pixels white, which is useful for debugging and fine-tuning your threshold.
  • order (Field Order): Specifies the input video's field order. Set to 0 for Bottom Field First (BFF) or 1 for Top Field First (TFF). If unspecified, it auto-detects.
  • sharp (Sharpness): Set to 1 (on) or 0 (off). For high-motion video, keeping this at 1 is crucial to maintain sharp edges during fast movements and avoid a muddy appearance.
  • twoway (Two-way clustering): Set to 1 (on) or 0 (off). Enabling this (1) improves spatial filtering by checking both preceding and succeeding fields, which significantly reduces artifacts in fast-moving scenes.

For a standard high-motion video (assuming Top Field First, which is common for HD interlaced footage), use the following FFmpeg command:

ffmpeg -i input.mp4 -vf "kerndeint=thresh=8:map=0:order=1:sharp=1:twoway=1" -c:v libx264 -preset slow -crf 18 -c:a copy output.mp4

Why this configuration works for high motion:

  1. thresh=8: Lowering the threshold from the default of 10 to 8 ensures that even subtle, fast-moving interlaced edges are captured and corrected.
  2. sharp=1: Prevents the video from looking soft or blurry during high-velocity camera pans.
  3. twoway=1: Sharply reduces temporal aliasing (flickering) by analyzing motion bidirectionally.

How to Fine-Tune the Filter

If you still notice combing artifacts or if the video looks too soft, use this two-step diagnostic process:

  1. Visualize the motion map: Run the command with map=1:

    ffmpeg -i input.mp4 -vf "kerndeint=thresh=8:map=1" -f matroska - | ffplay -

    Areas marked in white are being deinterlaced. If fast-moving edges are not white, lower the thresh value (e.g., to 5). If static areas are white, raise the thresh value (e.g., to 12) to prevent unnecessary filtering.

  2. Adjust Field Order: If the motion looks jittery or plays "one step forward, one step back," your field order is likely inverted. Swap the order parameter (change order=1 to order=0 or vice versa).