Shift Video Colors Over Time with FFmpeg Hue Filter

Shifting the color spectrum of a video over time is a great way to create psychedelic visual effects, transition elements, or dynamic color corrections. By utilizing FFmpeg’s built-in hue filter paired with time-based expressions, you can continuously rotate the hue of a video as it plays. This guide will show you how to write the exact FFmpeg command required to achieve this effect and how to customize the speed of the color shift.

To shift the color spectrum over time, you must apply the hue filter and define the hue angle (h) using an expression containing the variable t, which represents the current timestamp of the video in seconds.

Here is the basic command to continuously shift the video colors:

ffmpeg -i input.mp4 -vf "hue=h='t*90'" -c:a copy output.mp4

How the Command Works

Controlling the Speed of the Color Shift

You can easily adjust how quickly the colors cycle through the spectrum by changing the multiplier in the math expression:

Advanced: Oscillating Colors

If you want the colors to shift back and forth within a specific range rather than spinning infinitely through the spectrum, you can use the sine wave function (sin):

ffmpeg -i input.mp4 -vf "hue=h='sin(t)*180'" -c:a copy output.mp4

In this command, the hue angle will smoothly oscillate back and forth between -180 and 180 degrees over time.