Deinterlace Field-Matching Frames with FFmpeg Yadif
This article explains how to use the yadif (Yet Another
Deinterlacing Filter) filter in FFmpeg to selectively deinterlace
field-matching frames. You will learn how to combine the
fieldmatch and yadif filters in a single
filtergraph to deinterlace only the frames that contain residual combing
artifacts, preserving the original quality of perfectly matched
progressive frames.
When processing telecined or mixed-content video, the
fieldmatch filter attempts to reconstruct progressive
frames by matching fields from adjacent frames. However, some frames
cannot be perfectly matched and will still exhibit interlaced “combing”
artifacts. To resolve this, you can use yadif as a
post-processing step that target-deinterlaces only these unmatched,
combed frames.
The key to this process is the deint parameter in the
yadif filter. By setting this parameter to
interlaced (or 1), you instruct
yadif to check the frame metadata and only apply
deinterlacing to frames that fieldmatch has flagged as
interlaced.
The FFmpeg Command Syntax
To implement this workflow, chain the fieldmatch and
yadif filters together using the following command-line
template:
ffmpeg -i input.mp4 -vf "fieldmatch=order=tff,yadif=deint=interlaced" -c:v libx264 -crf 18 -c:a copy output.mp4Parameter Breakdown
fieldmatch=order=tff: This filter reconstructs progressive frames. Theorderoption specifies the field order of the input video. Usetfffor Top Field First orbfffor Bottom Field First. Iffieldmatchencounters a frame it cannot perfectly reconstruct, it flags that frame as interlaced.yadif=deint=interlaced: This tells theyadiffilter to read the flags set byfieldmatch. Instead of deinterlacing every single frame in the video stream,yadifwill bypass the successfully reconstructed progressive frames and only deinterlace the frames flagged as interlaced.-c:v libx264 -crf 18: Re-encodes the video using the H.264 codec at a high-quality constant rate factor.-c:a copy: Copies the audio stream without re-encoding to save processing time and maintain original audio quality.
Using this combination ensures maximum sharpness for the majority of your video while cleanly eliminating combing artifacts on frames that failed the field-matching process.