How to Use FFmpeg Hue Filter to Adjust Video Colors
In this guide, you will learn how to use the FFmpeg hue
filter to precisely manipulate a video’s hue, saturation, and
brightness. We will cover the basic syntax of the filter, explain its
key parameters, and provide practical command-line examples to help you
color-correct or creatively style your video files.
The hue filter in FFmpeg allows you to alter video
colors by modifying three main parameters: hue, saturation, and
brightness. This is done using the -vf (video filter) flag
followed by the hue option and your desired values.
The Hue Filter Parameters
The filter accepts several options, but the three most commonly used are:
h: Controls the hue rotation angle in degrees (from 0 to 360).s: Controls the saturation. The default value is1. A value of0produces a grayscale video, while values greater than1increase color intensity.b: Controls the brightness. The default value is0(no change). The value ranges from-10to10, where negative values darken the video and positive values brighten it.
Practical Examples
Below are practical command-line examples demonstrating how to apply these adjustments.
1. Adjusting Saturation
To make a video black and white (completely desaturated), set the
saturation (s) to 0:
ffmpeg -i input.mp4 -vf "hue=s=0" output.mp4To boost the colors and make the video more vibrant, increase the
saturation value above 1:
ffmpeg -i input.mp4 -vf "hue=s=1.5" output.mp42. Adjusting Brightness
To brighten a dark video, increase the brightness (b)
parameter. A value of 1 or 2 is usually
sufficient for noticeable brightness:
ffmpeg -i input.mp4 -vf "hue=b=1.5" output.mp4To darken a video, use a negative brightness value:
ffmpeg -i input.mp4 -vf "hue=b=-1" output.mp43. Changing the Hue (Color Shift)
To shift the overall color palette of your video, rotate the hue angle. For example, to shift the hue by 90 degrees:
ffmpeg -i input.mp4 -vf "hue=h=90" output.mp44. Combining Hue, Saturation, and Brightness
You can combine all three parameters in a single command by separating them with colons. The following command shifts the hue by 45 degrees, increases saturation by 20%, and slightly increases the brightness:
ffmpeg -i input.mp4 -vf "hue=h=45:s=1.2:b=0.5" output.mp4