How to Clamp Luma in FFmpeg Using lutyuv

This article demonstrates how to use the FFmpeg lutyuv filter to clamp the luminance (luma) channel of a video to a specific range while leaving the chrominance (chroma) channels completely untouched. You will learn the correct command-line syntax and the mathematical expressions required to restrict luma values without altering the color information of your video.

The lutyuv Filter Syntax

The lutyuv filter allows you to apply lookup table (LUT) equations to individual YUV channels: y (luma), u (blue-difference chroma), and v (red-difference chroma). Inside the filter, val represents the input pixel value for the channel being processed.

To clamp the luma channel while keeping the chroma channels unmodified, use the following FFmpeg command:

ffmpeg -i input.mp4 -vf "lutyuv=y='clip(val, 16, 235)':u='val':v='val'" output.mp4

How the Equation Works

Adjusting for Different Bit Depths

The example above assumes standard 8-bit video, where pixel values range from 0 to 255. If you are working with high-bit-depth video (such as 10-bit video, where values range from 0 to 1023), you must scale your clamping values accordingly.

For 10-bit broadcast-safe clamping, use:

ffmpeg -i input.mp4 -vf "lutyuv=y='clip(val, 64, 940)':u='val':v='val'" output.mp4