How to Use FFmpeg Phase Filter for Analog Video

This article provides a practical guide on using the FFmpeg phase filter to correct phase shifts between the odd and even fields of digitized analog video. You will learn how phase offsets occur during the digitization of analog tapes like VHS, the syntax and modes of the phase filter, and how to apply the correct commands to realign misaligned video fields.

Understanding Field Phase Shifts in Analog Video

When analog video (such as VHS or Betamax) is digitized, it is captured as interlaced frames consisting of two fields: the top (odd) field and the bottom (even) field. If the capture hardware or software experiences timing sync issues, a phase shift can occur. This shift causes the top and bottom fields of the same point in time to be temporally or spatially misaligned, resulting in heavy combing artifacts, horizontal jitter, or a “shivering” effect on static shots.

The FFmpeg phase filter analyzes the input video, detects these phase errors, and shifts the fields relative to each other to restore proper alignment.

FFmpeg Phase Filter Syntax and Modes

The basic syntax for the phase filter is:

-vf "phase=mode"

The mode parameter defines how FFmpeg will analyze and align the fields. The most common modes include:

Step-by-Step Implementation

Step 1: Automatic Phase Correction

For most digitized analog tapes, using the auto-detection mode is the most effective approach. Run the following command to let FFmpeg automatically detect and correct the field phase shift:

ffmpeg -i input.mp4 -vf "phase=a" -c:a copy output.mp4

Step 2: Manual Correction for Stubborn Tapes

If the automatic mode produces inconsistent results (which can happen with severely degraded tapes), you can manually force the field order to correct the alignment.

If your source is Top Field First but suffers from phase lag, force top-field alignment:

ffmpeg -i input.mp4 -vf "phase=t" -c:a copy output.mp4

If your source is Bottom Field First, use:

ffmpeg -i input.mp4 -vf "phase=b" -c:a copy output.mp4

Step 3: Combining Phase Correction with Deinterlacing

The phase filter only corrects the phase shift; it does not deinterlace the video. If you plan to deinterlace your analog video for modern progressive displays (using a filter like yadif or bwdif), you must apply the phase filter before the deinterlacer in your filter chain.

To chain the filters correctly, separate them with a comma:

ffmpeg -i input.mp4 -vf "phase=a,yadif=mode=send_frame:parity=auto" -c:v libx264 -crf 18 -c:a copy output.mp4

In this command, FFmpeg first aligns the misaligned fields using phase=a, and then cleanly deinterlaces the corrected fields using yadif. This prevents the deinterlacer from creating duplicate frames or blurring the image due to the initial phase offset.