FFmpeg Selectivecolor: Adjust Specific Color Ranges

The FFmpeg selectivecolor filter allows you to perform targeted color grading by adjusting the CMYK (Cyan, Magenta, Yellow, Key/Black) components within specific color ranges without globally altering the entire image. Modeled after the Selective Color adjustment tool commonly found in digital photo editing software, this filter enables precise shifts in hue, saturation, and luminance across nine distinct tonal ranges: reds, greens, blues, cyans, magentas, yellows, whites, neutrals, and blacks.

Understanding the Filter Syntax

The basic syntax for the filter inside a video filtergraph is:

-vf "selectivecolor=<range>='<component>=<value> <component>=<value>...'"

Available Color Ranges

You can target any of the following nine specific color regions:

  • reds
  • greens
  • blues
  • cyans
  • magentas
  • yellows
  • whites
  • neutrals
  • blacks

Adjustable Components

Within each targeted range, you modify color balance using four variables representing CMYK:

  • c: Cyan
  • m: Magenta
  • y: Yellow
  • k: Black (Key)

Values for these components range from -1.0 to 1.0 (representing -100% to +100%). A positive value adds that specific ink/pigment to the selected range, while a negative value removes it (which increases the complementary color).

Practical Adjustment Examples

1. Adjusting the Cyan Range

To isolate and adjust pixels falling into the cyan spectrum (such as teal skies or shallow water), specify the cyans parameter.

To make cyans deeper and slightly more blue by adding cyan and removing yellow:

ffmpeg -i input.mp4 -vf "selectivecolor=cyans='c=0.20 y=-0.15'" -c:a copy output.mp4

To darken the cyan range, increase the black (k) component:

ffmpeg -i input.mp4 -vf "selectivecolor=cyans='k=0.30'" -c:a copy output.mp4

2. Adjusting the Magenta Range

To isolate and manipulate magenta tones (useful for adjusting neon lights, certain flowers, or correcting unnatural purplish casts):

To desaturate or neutralize a magenta cast by reducing magenta and adding green (reducing m):

ffmpeg -i input.mp4 -vf "selectivecolor=magentas='m=-0.40'" -c:a copy output.mp4

To turn magentas warmer and richer by boosting magenta and yellow:

ffmpeg -i input.mp4 -vf "selectivecolor=magentas='m=0.25 y=0.30'" -c:a copy output.mp4

3. Combining Multiple Ranges

You can adjust multiple ranges simultaneously within a single filter call by separating each range block with a colon (:).

The following command boosts cyan in water/sky, cools down the reds, and shifts magentas towards purple:

ffmpeg -i input.mp4 -vf "selectivecolor=cyans='c=0.30 y=-0.10':reds='c=0.10 m=-0.05':magentas='c=0.20 m=0.10'" -c:a copy output.mp4

Choosing the Correction Method

The selectivecolor filter supports two calculation modes via the method parameter:

  • Relative (method=relative): This is the default. The adjustment is proportional to the existing amount of the component already present. It produces subtle, natural-looking changes and prevents hard clipping.
  • Absolute (method=absolute): Adds or subtracts values linearly based on absolute percentages. This produces much stronger, more aggressive shifts.

To use the absolute method:

ffmpeg -i input.mp4 -vf "selectivecolor=method=absolute:cyans='c=0.25':magentas='m=0.25'" -c:a copy output.mp4

Applying Photoshop Preset Files

If you have already configured a Selective Color adjustment layer in Adobe Photoshop, you can export it as an .asv file and load it directly into FFmpeg using the psfile option:

ffmpeg -i input.mp4 -vf "selectivecolor=psfile='adjustment_preset.asv'" -c:a copy output.mp4