How to Use FFmpeg Yadif Filter to Deinterlace Video
Deinterlacing is a crucial step when converting older analog or
broadcast video formats for playback on modern progressive displays.
This article provides a straightforward guide on how to use the
yadif (Yet Another Deinterlacing Filter) filter in FFmpeg,
explaining its basic syntax, key parameters, and practical command-line
examples to achieve high-quality video outputs.
What is the Yadif Filter?
Yadif stands for “Yet Another Deinterlacing Filter.” It is one of the most popular and highly effective CPU-based deinterlacing filters available in FFmpeg. It reconstructs interlaced frames into progressive ones by analyzing both spatial and temporal data in the video stream.
Basic Yadif Command
The simplest way to apply the yadif filter is by using
the video filter flag (-vf) with its default settings:
ffmpeg -i input.mp4 -vf yadif output.mp4By default, this command auto-detects the interlacing field order and outputs one progressive frame for every interlaced frame, maintaining the original frame rate (e.g., converting a 60i video into a 30p video).
Customizing Yadif Parameters
For more precise control, you can pass specific arguments to the
filter using the format yadif=mode:parity:deint.
1. Mode (Output Frame Rate)
0: Outputs 1 frame per frame of input (default). This keeps the original frame rate.1: Outputs 1 frame per field (bobbing). This doubles the frame rate (e.g., converting 60i to 60p), resulting in much smoother motion.2: Like0, but skips the spatial interlacing check.3: Like1, but skips the spatial interlacing check.
2. Parity (Field Order)
-1: Auto-detect field order (default).0: Top Field First (TFF). Common for HD video.1: Bottom Field First (BFF). Common for SD video and DV footage.
3. Deint (Which Frames to Deinterlace)
0: Deinterlace all frames (default).1: Only deinterlace frames that are marked as interlaced.
Practical Examples
Example 1: High-Quality Double Frame Rate (Bobbing)
To get the smoothest motion possible from sports broadcasts or home
videos, you can double the frame rate by setting the mode to
1:
ffmpeg -i input.ts -vf yadif=mode=1:parity=-1:deint=0 -c:v libx264 -crf 18 -c:a copy output.mp4(Shorthand equivalent: -vf yadif=1)
Example 2: Specifying Top Field First (TFF)
If the auto-detection fails and your output video looks jittery, you can explicitly force Top Field First:
ffmpeg -i input.mov -vf yadif=mode=0:parity=0:deint=0 output.mp4(Shorthand equivalent: -vf yadif=0:0:0)
Using these configuration options allows you to handle any interlaced video source and convert it cleanly for modern digital playback.