How to Deinterlace Video with FFmpeg w3fdif

This guide provides a practical overview of using the w3fdif (Weston 3 Field Deinterlace Filter) in FFmpeg to eliminate interlacing artifacts from video files. You will learn the core syntax, available configuration parameters, and practical command-line examples to achieve smooth, broadcast-quality progressive video output.

What is the w3fdif Filter?

The w3fdif filter is based on the BBC R&D Weston 3-field deinterlacing algorithm. It analyzes three fields (the current, previous, and next) to reconstruct progressive frames using temporal and spatial filtering. It produces sharp, stable output with minimal edge flickers, making it an excellent alternative to yadif or bwdif when processing interlaced broadcast streams (such as 1080i or 576i sources).

Basic Usage

By default, w3fdif generates one progressive frame per field. This means a standard 29.97i (interlaced) video will be converted into a 59.94p (progressive) video, preserving full motion fluidity.

The simplest command to apply the filter is:

ffmpeg -i input_interlaced.mp4 -vf "w3fdif" -c:v libx264 -crf 18 -c:a copy output_progressive.mp4

Configuration Parameters

The w3fdif filter accepts two primary parameters: filter and deint.

1. filter (Deinterlacing Filter Coefficient)

Controls the filtering complexity used for vertical interpolation:

  • complex (or 1, default): Uses the full Weston 3-field algorithm with complex coefficients. This yields the highest visual quality and sharpest lines.
  • simple (or 0): Uses simpler cubic interpolation. It requires slightly less processing power but may produce softer diagonal edges.

2. deint (Frame Selection)

Specifies which frames are processed:

  • all (or 0, default): Deinterlaces every incoming frame unconditionally.
  • interlaced (or 1): Only deinterlaces frames marked internally as interlaced.

Practical Examples

To ensure the highest visual fidelity with double framerate output using H.264 encoding:

ffmpeg -i input.ts -vf "w3fdif=filter=complex:deint=all" -c:v libx264 -preset slow -crf 17 -c:a aac output.mp4

Correcting Parity / Field Order

Deinterlacers rely on the correct field dominance (Top Field First vs. Bottom Field First). If the source metadata is incorrect, video motion will stutter backward and forward. You can enforce field dominance prior to w3fdif using the setfield filter:

For Top Field First (TFF):

ffmpeg -i input.ts -vf "setfield=tff,w3fdif=filter=complex" -c:v libx264 -crf 18 output.mp4

For Bottom Field First (BFF):

ffmpeg -i input.ts -vf "setfield=bff,w3fdif=filter=complex" -c:v libx264 -crf 18 output.mp4

Maintaining the Original Framerate (Single Rate)

Because w3fdif natively outputs two frames per interlaced input frame (frame-per-field), you can append the fps filter to drop every other frame if you require standard 25p or 29.97p delivery:

ffmpeg -i input.ts -vf "w3fdif=filter=complex,fps=25" -c:v libx264 -crf 18 output.mp4