How to Animate Vignette Color in FFmpeg

This article provides a quick overview and step-by-step guide on how to create a color-animated vignette effect in FFmpeg. Because FFmpeg’s native vignette filter only darkens frame edges, achieving an animated color vignette requires combining a color source, the hue filter for color shifting, the vignette filter for shape and movement, and the blend filter to merge the effect onto your video.

The Challenge with the Vignette Filter

The default vignette filter in FFmpeg is designed to reduce luminance towards the edges of an image, resulting in a black or dark shadow. It does not have built-in parameters to change the vignette’s color. To create a colored, moving vignette, you must generate a solid color canvas, apply the vignette filter to it to act as a mask, animate the color and vignette properties over time, and blend it back onto your original video.

The FFmpeg Command

Use the following command to apply a pulsing, color-changing vignette to your video:

ffmpeg -i input.mp4 -filter_complex "color=color=red[c];[c][0:v]scale2ref[col][vid];[col]hue=h='t*40'[animated_color];[animated_color]vignette='angle=PI/4+sin(t)*PI/12':eval=frame[vig];[vid][vig]blend=all_mode=multiply" -c:a copy output.mp4

How the Command Works

The -filter_complex flag handles the creation and blending of the animated layers using several chained filters:

  1. color=color=red[c]: This generates a solid red color canvas source, labeled as [c].
  2. scale2ref: Matches the size of the generated color canvas to the resolution of your input video ([0:v]). This prevents resolution mismatches and outputs the scaled color layer [col] and the video stream [vid].
  3. hue=h='t*40': Animates the hue of the color layer over time (t represents time in seconds). Multiplying t by 40 continuously shifts the color across the spectrum, creating a rainbow cycle effect.
  4. vignette='angle=PI/4+sin(t)*PI/12':eval=frame: Applies the vignette effect to the animated color layer.
    • eval=frame forces FFmpeg to recalculate the expressions for every frame.
    • angle controls the size of the vignette. By using the sine wave function sin(t), the vignette radius pulses larger and smaller over time.
  5. blend=all_mode=multiply: Blends the animated color vignette layer [vig] with the original video stream [vid] using the multiply blend mode. This keeps the center of your video clear while applying the animated color effect to the outer edges.