How to Use FFmpeg Selective Color Filter
The selectivecolor filter in FFmpeg is a powerful color
grading tool that allows you to adjust specific color ranges in a video
without affecting the rest of the image. This guide explains how the
selectivecolor filter works, details its syntax and color
range parameters, and provides practical command-line examples to help
you precisely target and modify colors like reds, blues, greens, and
neutrals.
Understanding the selectivecolor Filter
The selectivecolor filter mimics the selective color
adjustment tool found in professional image editing software like Adobe
Photoshop. It works by adjusting the CMYK (Cyan, Magenta, Yellow, Black)
components of specific color ranges.
The filter recognizes nine distinct color ranges: * reds
* yellows * greens * cyans *
blues * magentas * whites *
neutrals * blacks
Parameter Syntax
For each color range you want to adjust, you specify four values
corresponding to Cyan, Magenta, Yellow, and Black
(CMYK). These values must be floating-point numbers between
-1.0 and 1.0, separated by spaces.
selectivecolor=color_range='C M Y K'
- Positive values increase the presence of that color component.
- Negative values decrease it (shifting towards the complementary color, e.g., decreasing Cyan increases Red).
Key Options
correction_method: Specifies how the adjustments are applied.absolute(default): Adjusts the color components by a fixed, absolute value.relative: Adjusts the color components relative to their original value, which often results in a more subtle, natural effect.
psfile: Allows you to apply a Photoshop Selective Color preset file (.asv) directly to your video.
Practical Examples
1. Enhancing Red Tones
To make the red tones in your video warmer by adding yellow and reducing cyan, use the following command:
ffmpeg -i input.mp4 -vf "selectivecolor=reds='-0.1 0 0.2 0'" -c:a copy output.mp4In this example, -0.1 decreases Cyan (adding red)
and 0.2 increases Yellow in the red ranges.
2. Cool-Toning Neutrals (Color Grading)
To give your overall video a cooler, more cinematic look, you can add Cyan and Magenta to the neutral gray tones:
ffmpeg -i input.mp4 -vf "selectivecolor=neutrals='0.15 0.05 -0.1 0'" -c:a copy output.mp4This increases Cyan by 15%, Magenta by 5%, and reduces Yellow by 10% in the neutral tones.
3. Creating a Selective Color Desaturation Effect
To keep only the red tones vibrant while desaturating other colors, you can reduce the CMYK values of other color ranges:
ffmpeg -i input.mp4 -vf "selectivecolor=yellows='0 0 0 1':greens='0 0 0 1':cyans='0 0 0 1':blues='0 0 0 1'" -c:a copy output.mp4Setting the Black (K) value to 1 for yellows,
greens, cyans, and blues effectively darkens and desaturates those
specific channels.
4. Using a Photoshop Preset File
If you have already created a Selective Color look in Photoshop and
saved it as an .asv file, you can apply it directly to your
video:
ffmpeg -i input.mp4 -vf "selectivecolor=psfile='my_preset.asv'" -c:a copy output.mp4