How to Use FFmpeg w3fdif Filter for Deinterlacing
Deinterlacing is a crucial step when converting interlaced broadcast
or analog video into a modern progressive format. This guide provides a
straightforward tutorial on how to use the w3fdif (Weston
3-Field Deinterlacing Filter) in FFmpeg to achieve high-quality
deinterlacing, explaining its key parameters, syntax, and practical
command-line examples.
What is the w3fdif Filter?
The w3fdif filter is based on the Weston 3-field
deinterlacing algorithm. It interpolates missing lines by looking at
three consecutive fields of video. Compared to the more common
yadif (Yet Another Deinterlacing Filter),
w3fdif often produces cleaner diagonal edges and reduces
flickering in detailed areas, making it an excellent choice for
high-quality video preservation.
Basic Syntax
To use w3fdif in FFmpeg, you apply it using the video
filter flag (-vf). The basic structure of the command
is:
ffmpeg -i input.mp4 -vf "w3fdif" output.mp4Key Parameters of w3fdif
You can customize the filter’s behavior using specific parameters separated by colons.
1. Filter Mode (filter)
This parameter controls the complexity of the interpolation filter
coefficients. * simple (or 0): Faster
processing, lower quality. * complex (or 1):
Slower processing, significantly higher quality with better detail
preservation (Default).
2. Output Mode (mode)
This determines the output frame rate and how fields are processed. *
frame (or 0): Outputs one progressive frame
for each interlaced frame (e.g., 30i becomes 30p). * field
(or 1): Outputs one progressive frame for each field,
doubling the frame rate (e.g., 30i becomes 60p). This mode preserves the
fluid motion of the original interlaced source.
3. Deinterlace Selection
(deint)
Specifies which frames should be processed. * all (or
0): Deinterlace all frames (Default). *
interlaced (or 1): Only deinterlace frames
that are flagged as interlaced.
Practical Examples
Example 1: High-Quality Double Framerate Deinterlacing (Recommended)
This command doubles the framerate (converting 50i/60i to 50p/60p) for fluid motion, utilizing the complex filter coefficient for the highest possible quality.
ffmpeg -i input.mp4 -vf "w3fdif=mode=field:filter=complex" -c:v libx264 -crf 18 -c:a copy output.mp4Example 2: Standard Framerate Deinterlacing
If you need to keep the original frame rate (converting 30i to 30p)
to match standard film rates or to reduce file size, use
mode=frame.
ffmpeg -i input.mp4 -vf "w3fdif=mode=frame:filter=complex" -c:v libx264 -crf 18 -c:a copy output.mp4Example 3: Fast Deinterlacing
For faster processing on older hardware while still using the Weston algorithm, switch the filter complexity to simple:
ffmpeg -i input.mp4 -vf "w3fdif=mode=field:filter=simple" -c:v libx264 -crf 20 -c:a copy output.mp4