How to Apply Spatial-Temporal Deinterlacing in FFmpeg
Deinterlacing is a crucial step when converting legacy interlaced
video formats into progressive frames suitable for modern digital
displays. This article provides a direct, practical guide on how to use
the motion-compensated spatial-temporal deinterlacing filter
(mcdeint) in FFmpeg, explaining its syntax, key parameters,
and offering ready-to-use command examples alongside modern
alternatives.
Understanding the MCDEINT Filter
The mcdeint (motion-compensated deinterlacer) filter is
an advanced spatial-temporal deinterlacing filter in FFmpeg. Unlike
simple spatial deinterlacers that only look at a single frame, or
temporal deinterlacers that simply merge fields, a spatial-temporal
filter analyzes both the current frame and surrounding frames in
time.
By utilizing motion estimation, mcdeint tracks moving
objects across frames to reconstruct missing lines, resulting in much
cleaner edges and significantly fewer interlacing artifacts (like “comb”
effects) without sacrificing image sharpness.
FFmpeg Syntax for MCDEINT
The basic syntax for applying the mcdeint filter in an
FFmpeg command is as follows:
ffmpeg -i input.mp4 -vf "mcdeint=mode:parity:qp" output.mp4The filter accepts three optional parameters separated by colons:
mode: Controls the processing intensity and motion estimation quality.0: Fast (basic spatial-temporal processing).1: Medium (better motion estimation).2: Slow (uses detailed motion estimation).3: Extra slow (highest quality, highly CPU-intensive).
parity: Determines the field dominance (which field comes first).0: Bottom Field First (BFF).1: Top Field First (TFF).-1: Auto-detect (recommended).
qp: Quantization Parameter. Higher values allow smoother motion search but may reduce spatial sharpness. The default is typically sufficient for most uses.
Practical Command Examples
To apply standard-quality motion-compensated deinterlacing with automatic field parity detection, use this command:
ffmpeg -i input_interlaced.mp4 -vf "mcdeint=mode=1:parity=-1" -c:v libx264 -crf 20 output_progressive.mp4For the highest possible quality (which requires significant
processing time), increase the mode to 3:
ffmpeg -i input_interlaced.mp4 -vf "mcdeint=mode=3:parity=-1" -c:v libx264 -crf 20 output_high_quality.mp4Important Usage Considerations
While mcdeint produces high-quality results, it has
several limitations in modern workflows:
- Compilation Requirements: The
mcdeintfilter requires FFmpeg to be compiled with specific legacy components (specifically the Snow codec andlibpostproc). In many modern pre-compiled FFmpeg distributions,mcdeintis disabled or unavailable. - Performance: It is extremely slow and single-threaded, making it impractical for high-definition (HD or 4K) video processing.
Modern Spatial-Temporal Alternatives
If mcdeint is not supported by your FFmpeg build, or if
it runs too slowly, you should use modern, highly-optimized
spatial-temporal deinterlacers:
1. YADIF (Yet Another Deinterlacing Filter)
YADIF is the industry standard for fast, high-quality spatial-temporal deinterlacing.
ffmpeg -i input_interlaced.mp4 -vf "yadif=mode=0:parity=-1" -c:v libx264 output.mp4(Note: mode=0 outputs one frame per frame of video.
mode=1 outputs one frame per field, creating a 60fps
progressive video from a 30i interlaced source).
2. BWDIF (Bob Weaver Deinterlacing Filter)
BWDIF is a newer, hardware-optimized spatial-temporal filter based on YADIF algorithms that delivers better detail preservation.
ffmpeg -i input_interlaced.mp4 -vf "bwdif=mode=0:parity=-1" -c:v libx264 output.mp4