How to Clamp Video Levels in FFmpeg with Limiter
This guide explains how to use the FFmpeg limiter filter
to restrict video levels to broadcast-safe ranges. You will learn the
exact command to clamp luminance (luma) to 16–235 and chrominance
(chroma) to 16–240, ensuring your video meets standard television
broadcast specifications.
To achieve different limits for luma and chroma, you must chain two
instances of the limiter filter together. This is because a
single instance of the filter applies the same minimum and maximum
thresholds to all selected planes.
The FFmpeg Command
Use the following filtergraph in your FFmpeg command:
ffmpeg -i input.mp4 -vf "limiter=min=16:max=235:planes=1,limiter=min=16:max=240:planes=6" -c:a copy output.mp4How the Filter Parameters Work
The limiter filter accepts three primary parameters: *
min: The lowest allowed pixel value. *
max: The highest allowed pixel value. *
planes: A bitmask specifying which color
planes the filter should process.
Understanding the Plane Bitmask
FFmpeg identifies video planes (such as Y, U, and V) using index
numbers, which are mapped to a bitmask value: * Plane 0 (Luma /
Y): Bitmask value of 1 (\(2^0\)) * Plane 1 (Chroma /
U): Bitmask value of 2 (\(2^1\)) * Plane 2 (Chroma /
V): Bitmask value of 4 (\(2^2\))
To target specific planes, you add their bitmask values together: *
Luma only: Use planes=1. This applies the
16–235 clamp only to the Y channel. * Chroma only: Add
Plane 1 (2) and Plane 2 (4) together to get
planes=6. This applies the 16–240 clamp to both the U and V
channels simultaneously.
By chaining limiter=min=16:max=235:planes=1 and
limiter=min=16:max=240:planes=6 sequentially, FFmpeg
restricts both luma and chroma to your exact specifications without
affecting the rest of the stream.