FFmpeg Inflate Filter Guide

This article provides a practical overview of using the inflate filter in FFmpeg to apply a morphological inflation (dilation) effect to images and video streams. You will learn the basic syntax of this filter, how it processes different color planes, and how to chain the filter to achieve stronger visual effects.

What is Morphological Inflation?

Morphological inflation, often referred to as dilation in image processing, expands the brighter areas of an image. The inflate filter in FFmpeg achieves this by replacing each pixel’s value with the maximum value found in its 3x3 pixel neighborhood. This technique is highly useful for mask expansion, edge enhancement, and artistic video effects.

FFmpeg Inflate Filter Syntax

The basic syntax for the inflate filter is:

inflate=threshold0:threshold1:threshold2:threshold3

Each parameter controls the threshold of change allowed for a specific color plane (such as Y, U, V, and Alpha in YUV color spaces):

A threshold value of 0 means no change will be applied to that specific plane.

Practical Command Examples

1. Apply Inflation to All Planes

To apply the default inflation effect to your video (affecting both brightness and color planes):

ffmpeg -i input.mp4 -vf "inflate" output.mp4

2. Apply Inflation Only to the Luma (Brightness) Plane

If you want to dilate only the brightness channel while keeping the color channels unmodified, set the thresholds for the other planes to 0:

ffmpeg -i input.mp4 -vf "inflate=65535:0:0:0" output.mp4

3. Multi-Pass Inflation for a Stronger Effect

Because the inflate filter operates on a small 3x3 pixel matrix, a single pass might be too subtle for high-resolution video. You can chain multiple inflate filters together to grow the bright areas further:

ffmpeg -i input.mp4 -vf "inflate,inflate,inflate" output.mp4

This multi-pass approach creates a much more pronounced dilation effect, which is particularly useful when expanding black-and-white text masks or alpha channels.