Change Video Field Dominance with FFmpeg fieldorder

Changing the field dominance of an interlaced video is crucial for preventing playback issues like judder and interlacing artifacts. This article provides a straightforward guide on how to use the FFmpeg fieldorder filter to convert video field dominance between Top Field First (TFF) and Bottom Field First (BFF), ensuring your interlaced video displays correctly on targeted broadcast or playback systems.

Understanding Field Dominance

Interlaced video consists of two fields per frame: the top field (odd lines) and the bottom field (even lines). Field dominance determines which of these two fields is displayed first. * tff (Top Field First): Typically used in high-definition (HD) interlaced video. * bff (Bottom Field First): Common in standard-definition (SD) analog-derived formats like DV NTSC.

If the field order is flagged incorrectly or needs conversion for a specific broadcast standard, the fieldorder filter in FFmpeg allows you to restructure the video fields.

How the fieldorder Filter Works

The fieldorder filter physically shifts the lines of the video up or down by one line to change the field dominance, and then updates the output file’s metadata container to reflect the new field order.

The basic syntax for the filter is: -vf fieldorder=order

Where order can be either tff or bff.

Changing Field Order to Top Field First (TFF)

To convert a Bottom Field First (BFF) video to Top Field First (TFF), use the following FFmpeg command:

ffmpeg -i input.mp4 -vf fieldorder=tff output.mp4

Changing Field Order to Bottom Field First (BFF)

To convert a Top Field First (TFF) video to Bottom Field First (BFF), run this command:

ffmpeg -i input.mp4 -vf fieldorder=bff output.mp4

Encoding Interlaced Video Correctly

Because the fieldorder filter physically alters the video frames by shifting lines, you must re-encode the video. You cannot use the -c:v copy parameter.

When re-encoding interlaced content, you should also pass interlacing flags to the encoder so the output file metadata is tagged correctly. For example, when encoding to H.264, use the -flags +ilme+ildct flags:

ffmpeg -i input.mp4 -vf fieldorder=tff -c:v libx264 -flags +ilme+ildct output.mp4