How to Use the FFmpeg Weave Filter
This article provides a practical guide on how to use the
weave filter in FFmpeg to combine video fields into
interlaced frames. You will learn the fundamental concept of the filter,
its syntax, key parameters, and step-by-step command-line examples for
common video processing workflows.
What is the FFmpeg Weave Filter?
The weave filter is used to merge consecutive frames in
a video stream into a single interlaced frame. It takes two input
frames, treats them as fields (one representing odd lines, the other
representing even lines), and interleaves them.
This process doubles the vertical resolution of the individual fields
while halving the overall frame rate of the video. It is the opposite of
the separatefields filter.
Syntax and Parameters
The basic syntax for the weave filter is:
-vf "weave=first_field=value"The filter accepts one primary parameter:
first_field(orf): Specifies which field should be placed first (on the top line).top/t(Default): The first input frame is treated as the top field (Top Field First / TFF).bottom/b: The first input frame is treated as the bottom field (Bottom Field First / BFF).
Practical Examples
1. Recombining Separated Fields
If you have previously split an interlaced video into separate fields
using the separatefields filter, you can reconstruct the
original interlaced video using weave:
ffmpeg -i input.mp4 -vf "separatefields,weave=first_field=top" output.mp42. Converting Progressive Video to Interlaced (60p to 30i)
To convert a high-frame-rate progressive video (e.g., 60fps) into an interlaced video (e.g., 30fps interlaced) using Top Field First:
ffmpeg -i input_60p.mp4 -vf "separatefields,weave=first_field=top" -c:v libx264 -flags +ilme+ildct output_30i.mp4Note: The -flags +ilme+ildct flags tell the encoder
to use interlaced motion estimation and interlaced discrete cosine
transform to preserve the interlaced structure correctly.
3. Setting Bottom Field First (BFF)
If your target playback system or broadcast standard requires Bottom
Field First, set the first_field parameter to
bottom:
ffmpeg -i input_60p.mp4 -vf "separatefields,weave=first_field=bottom" output_bff.mp4