How to Weave Fields into Interlaced Video with FFmpeg
This article explains how to use the FFmpeg weave filter
to combine individual sequential fields back into a standard interlaced
video stream. You will learn the exact command-line syntax required for
this process, how to specify field dominance (top field first or bottom
field first), and how to set the correct flags to ensure media players
recognize the output as interlaced.
Understanding the Weave Filter
The weave filter in FFmpeg takes two consecutive
progressive frames (which represent individual fields) and interlaces
them into a single frame. This process halves the frame rate of the
input video while doubling the vertical resolution of each frame.
This filter is commonly used when you have previously separated an
interlaced video into individual fields (using the
separatefields filter) to perform edits or filtering, and
now need to reconstruct the original interlaced structure.
Basic Syntax
The basic syntax for the weave filter is as follows:
ffmpeg -i input.mp4 -vf "weave" output.mp4By default, the weave filter assumes the first field is
the top field (Top Field First, or TFF).
Specifying Field Dominance
If your source video uses Bottom Field First (BFF) dominance, you
must explicitly tell the filter to weave the fields accordingly. The
weave filter accepts a single option to define this:
top(or0): Weave top field first (Default).bottom(or1): Weave bottom field first.
Example for Bottom Field First (BFF):
ffmpeg -i input.mp4 -vf "weave=bottom" output.mp4Alternatively, you can use the short-form syntax:
ffmpeg -i input.mp4 -vf "weave=b" output.mp4Encoding Interlaced Output Correctly
Simply weaving the fields together is often not enough; you must also instruct the video encoder to flag the output file as interlaced so that media players know how to deinterlace it during playback.
When encoding to H.264 (using libx264), you should
include the interlaced encoding flags (-flags +ilme+ildct)
and specify the field order using the fieldorder
filter.
Full Command for Top Field First (TFF):
ffmpeg -i input.mp4 -vf "weave=top,fieldorder=tff" -c:v libx264 -flags +ilme+ildct -pix_fmt yuv420p output_tff.mp4Full Command for Bottom Field First (BFF):
ffmpeg -i input.mp4 -vf "weave=bottom,fieldorder=bff" -c:v libx264 -flags +ilme+ildct -pix_fmt yuv420p output_bff.mp4Explanation of the Parameters:
-vf "weave=top,fieldorder=tff": Combines the fields starting with the top field, and then tags the video stream internal metadata as Top Field First.-flags +ilme+ildct: Tells the H.264 encoder to use interlaced motion estimation (ilme) and interlaced discrete cosine transform (ildct).-pix_fmt yuv420p: Ensures wide compatibility with consumer media players.