Deinterlace Video with FFmpeg w3fdif Filter

This guide explains how to deinterlace interlaced video using the Weston 3 Field Deinterlacing Filter (w3fdif) in FFmpeg. You will learn the command-line syntax for configuring this filter, how to select its mathematical weight parameters, and how to utilize the neural-network-backed nnedi3 filter if your workflow requires true deep-learning-based deinterlacing.

Deinterlacing with the w3fdif Filter

The w3fdif (Weston 3 Field Deinterlacing Filter) is an advanced deinterlacing filter designed by the BBC. It works by using temporal and spatial processing to interpolate missing lines in interlaced footage.

To use w3fdif with custom weight coefficients, you configure the filter parameter in your FFmpeg command.

FFmpeg w3fdif Command Example

ffmpeg -i input.mp4 -vf "w3fdif=filter=complex:deint=all" -c:v libx264 -crf 18 -c:a copy output.mp4

Parameter Breakdown

  • filter: Controls the custom weight coefficients used for spatial and temporal interpolation.
    • complex (or 1): Uses a 5-tap spatial and 3-tap temporal filter weight calculation. This is the default and provides the highest quality, minimizing combing artifacts in high-motion scenes.
    • low (or 0): Uses a simpler 3-tap spatial and 2-tap temporal calculation. It is less CPU-intensive but may produce more aliasing.
  • deint: Specifies which frames to process.
    • all (or 0): Deinterlaces every frame in the video stream.
    • interlaced (or 1): Only filters frames that are flagged as interlaced.

Alternative: Neural-Network-Based Deinterlacing (nnedi3)

While w3fdif uses advanced mathematical matrix weights, it is not a neural network. If you require a true neural-network-based deinterlacer in FFmpeg, you should use the nnedi3 filter. nnedi3 uses a third-generation intra-field deinterlacer based on a neural network structure and requires a custom weights file (nnedi3_weights.bin).

FFmpeg nnedi3 Command Example

ffmpeg -i input.mp4 -vf "nnedi3=weights='nnedi3_weights.bin':deint=all:qual=2" -c:v libx264 -crf 18 -c:a copy output.mp4

Parameter Breakdown

  • weights: Points to the path of your custom neural network binary weights file (usually nnedi3_weights.bin).
  • qual: Sets the quality of the neural network search. Use 1 for fast processing or 2 for a slower, more detailed mathematical fit.
  • deint: Decides whether to deinterlace all frames or only detected interlaced ones.