Set FFmpeg Video Field Order to TFF or BFF

This article provides a quick guide on how to set or change the video field order in FFmpeg to either top-field-first (TFF) or bottom-field-first (BFF). You will learn the specific command-line arguments and video filters required to modify the interlacing metadata or physically reorder the video fields of your file.

Method 1: Setting the Field Order Flag (Metadata)

If your video is already interlaced and you simply want to set or correct the container/codec metadata flag without re-encoding the video stream, you can use the -field_order option.

To set the metadata flag to Top-Field-First (TFF):

ffmpeg -i input.mp4 -c copy -field_order tff output.mp4

To set the metadata flag to Bottom-Field-First (BFF):

ffmpeg -i input.mp4 -c copy -field_order bff output.mp4

Note: Using -c copy ensures that the video is not re-encoded, making the process almost instantaneous.

Method 2: Converting Field Order Using the “fieldorder” Filter

If the video fields are physically in the wrong order and you need to convert the actual video stream (which requires re-encoding), you should use the fieldorder video filter. This filter shifts the picture up or down by one line to swap the field order.

To convert a video to Top-Field-First (TFF):

ffmpeg -i input.mp4 -vf "fieldorder=tff" -c:v libx264 -crf 18 -c:a copy output.mp4

To convert a video to Bottom-Field-First (BFF):

ffmpeg -i input.mp4 -vf "fieldorder=bff" -c:v libx264 -crf 18 -c:a copy output.mp4

Method 3: Forcing Field Order During Encoding

When encoding raw or progressive video into an interlaced format, you must explicitly tell the encoder to produce interlaced frames and define the field layout. You can do this by combining the setfield filter with encoder flags.

For TFF encoding (using libx264 as an example):

ffmpeg -i input.mp4 -vf "setfield=tff" -c:v libx264 -flags +ilme+ildct -top 1 output.mp4

For BFF encoding:

ffmpeg -i input.mp4 -vf "setfield=bff" -c:v libx264 -flags +ilme+ildct -top 0 output.mp4