Use yadif_videotoolbox in FFmpeg on macOS

This guide provides a straightforward walkthrough on utilizing the yadif_videotoolbox hardware-accelerated deinterlacing filter in FFmpeg on macOS. You will learn how to verify your FFmpeg build for Apple Silicon and Intel Macs, configure the essential hardware acceleration pipelines, adjust key filter parameters, and execute fast, GPU-accelerated video deinterlacing commands.

Prerequisites and Verification

The yadif_videotoolbox filter leverages Apple's VideoToolbox framework to perform YADIF (Yet Another DeInterlacing Filter) processing directly on the GPU. To use it, you must have a build of FFmpeg compiled with VideoToolbox support (standard with recent Homebrew installations).

Check if your FFmpeg installation includes the filter by running:

ffmpeg -filters | grep yadif_videotoolbox

If supported, the output will display yadif_videotoolbox with video filtering capabilities.

Basic Syntax and Pipeline

To get the full performance benefit of yadif_videotoolbox, keep the decoding, filtering, and encoding inside the GPU memory to avoid costly transfers between system RAM and VRAM.

A standard command structure looks like this:

ffmpeg -hwaccel videotoolbox -i input_interlaced.mov \
  -vf "yadif_videotoolbox" \
  -c:v h264_videotoolbox -b:v 5M \
  -c:a copy output_deinterlaced.mp4

Filter Parameters

The yadif_videotoolbox filter accepts several parameters to customize how fields are processed:

  • mode: Specifies the interlacing mode.
    • 0 (or send_frame): Outputs 1 frame for each frame (default).
    • 1 (or send_field): Outputs 1 frame for each field (doubles the frame rate, e.g., 29.97i to 59.94p).
  • parity: Sets field parity.
    • -1 (or auto): Automatically detects field parity (default).
    • 0 (or tff): Top field first.
    • 1 (or bff): Bottom field first.
  • deint: Specifies which frames to deinterlace.
    • 0 (or all): Deinterlace all frames (default).
    • 1 (or interlaced): Only deinterlace frames marked as interlaced.

Practical Examples

Double Frame Rate Deinterlacing (Bobbing)

To deinterlace 1080i footage into smooth 60fps (or 50fps) progressive video using field-doubling:

ffmpeg -hwaccel videotoolbox -i input.ts \
  -vf "yadif_videotoolbox=mode=send_field:parity=auto" \
  -c:v hevc_videotoolbox -q:v 65 \
  -c:a aac output_60p.mp4

Software Decoding with Hardware Deinterlacing

If your input codec cannot be decoded by VideoToolbox, you can decode in software and upload the frames to VideoToolbox memory using hwupload:

ffmpeg -i input_unsupported_codec.avi \
  -vf "hwupload,yadif_videotoolbox=mode=send_frame" \
  -c:v h264_videotoolbox -b:v 8M \
  -c:a copy output_progressive.mp4