Interlaced sources should be deinterlaced before encoding. How to choose a yadif/bwdif mode (keep frame rate vs. double the fields), and how to avoid applying it to video that is already progressive.
Chapter 1 explained what interlacing is and why it should be cleaned up before encoding (Scanning and interlacing). This lesson focuses on how to do that cleanup with FFmpeg. If you compress interlaced video as-is with progressive encoding settings, the comb pattern (combing), where two fields from different moments are mixed in a single frame, is bad for compression and also stays visible on screen.
ffprobe -v error -select_streams v:0 -show_entries stream=field_order -of default=nw=1 input.ts
# The result is one of field_order=progressive / tt / bb / tb / bt.
# tt = top field first, bb = bottom field first. If the value is unknown, check by eye as well.
# Confirm with statistics whether there really are mixed frames (idet filter)
ffmpeg -i input.ts -vf idet -frames:v 500 -an -f null -The idet filter analyzes frames and summarizes in the log how many it classified as progressive or interlaced (TFF/BFF). Some files have wrong metadata (tags), so if in doubt, look at these statistics together with the actual comb pattern on screen.
yadif (Yet Another DeInterlacing Filter) is the most widely used deinterlacing filter. The key option is mode.
The mode numbers and names are in the yadif entry of the FFmpeg filter documentation. Modes 2 and 3 are variants that skip the spatial check.
# Keep the frame rate (default)
ffmpeg -i input.ts -vf "yadif=mode=0:deint=interlaced" -c:v libx264 -crf 20 -c:a copy out.mp4
# Double the fields: more frames per second, so the file can grow even at the same CRF
ffmpeg -i input.ts -vf "yadif=mode=1:deint=interlaced" -c:v libx264 -crf 20 -c:a copy out60.mp4parity (specifying the field order) is auto-detected by default. If detection is wrong, motion jitters back and forth, so in that case try setting it yourself with parity=tff or parity=bff.bwdif (Bob Weaver Deinterlacing Filter) is described in the FFmpeg documentation as a motion-adaptive filter that builds on yadif and uses the w3fdif and cubic interpolation algorithms together. Its options (mode, parity, deint) have the same form as yadif's, so you can try it just by swapping the filter name. Which one looks better depends on the source, and this site has no measured data for it, so for important sources the surest approach is to render both and compare scene changes, subtitles, and thin-line areas by eye. It is generally known that bwdif is heavier to process than yadif, but the actual speed difference varies by environment, so measure it yourself.
ffmpeg -i input.ts -vf "bwdif=mode=0:deint=interlaced" -c:v libx264 -crf 20 -c:a copy out.mp4A source made by telecine (3:2 pulldown), which moves film (24 fps) onto TV standards (29.97 fps), has a regular pattern of frames built from mixed fields. For such sources, restoring the fields back to the original frames (fieldmatch + decimate, pullup, and so on) is sometimes the right approach rather than smearing it with yadif. Be suspicious if the progressive and interlaced verdicts in the idet log repeat in a steady pattern. Conditions differ by source and there is no single correct command, so check the result on a short section before running the whole thing.
When you must keep and deliver the video interlaced, such as for compatibility with broadcast standards, people sometimes skip deinterlacing and use encoding settings that support interlacing. For a final file for web or mobile, on the other hand, you normally deinterlace to make it progressive. The deciding factor is where the file is going.
A widely used deinterlacing filter. mode 0 keeps the frame rate, and mode 1 outputs one frame per field, doubling the frame rate.
A motion-adaptive deinterlacing filter built on yadif that uses w3fdif and cubic interpolation. Its options have the same form as yadif's.
An analysis filter that classifies frames as progressive or interlaced (TFF/BFF) and produces statistics.
The 3:2 pulldown that moves 24 fps video onto the 29.97 fps TV standard, and the processing that restores the original frames.
You want to turn a 59.94 field/second interlaced source into 59.94 frame/second progressive video, preserving as much smoothness of motion as possible. Which yadif mode is right?
How do you process only the interlaced frames in a source that mixes progressive and interlaced frames?