How to Use FFmpeg chromaberrap for Chromatic Aberration
This guide explains how to simulate chromatic aberration on a video
using FFmpeg’s built-in chromaberrap filter. You will learn
the basic command syntax, understand the key parameters for adjusting
horizontal and vertical color channel shifts, and explore practical
examples to achieve realistic lens distortion effects.
Understanding the chromaberrap Filter
The chromaberrap filter simulates chromatic aberration
(color fringing) by displacing the red and blue color channels in
opposite directions relative to the green channel. This replicates the
real-world optical phenomenon where a camera lens fails to focus all
wavelengths of color to the same convergence point.
Basic Syntax and Parameters
The basic structure of the filter within an FFmpeg command is:
ffmpeg -i input.mp4 -vf "chromaberrap=h_shift=value:v_shift=value" output.mp4The filter accepts two primary parameters to control the displacement:
h_shift: Controls the horizontal shift of the red and blue channels. It accepts float values (typically between -100.0 and 100.0). Positive values shift the channels in one direction, while negative values shift them in the opposite direction.v_shift: Controls the vertical shift of the red and blue channels. It also accepts float values.
If you do not specify these parameters, they default to
0, resulting in no aberration.
Practical Examples
1. Subtle, Realistic Aberration
For a realistic lens imperfection, use small values. This is ideal for matching digital CGI with real camera footage.
ffmpeg -i input.mp4 -vf "chromaberrap=h_shift=1.5:v_shift=1.0" -c:a copy output.mp42. Extreme Stylized Aberration
For a glitch, dreamlike, or psychedelic aesthetic, increase the shift values significantly.
ffmpeg -i input.mp4 -vf "chromaberrap=h_shift=8.0:v_shift=6.0" -c:a copy output.mp43. Horizontal-Only Aberration
If you only want the color fringing to occur along the horizontal axis, set the vertical parameter to zero.
ffmpeg -i input.mp4 -vf "chromaberrap=h_shift=4.0:v_shift=0" -c:a copy output.mp4Format Compatibility
The chromaberrap filter works best with video formats
that support separate color planes (like YUV formats). If your input
video uses a different pixel format, you should force conversion to a
compatible format like yuv420p prior to applying the
filter, or chain it in the filtergraph:
ffmpeg -i input.mp4 -vf "format=yuv420p,chromaberrap=h_shift=3.0:v_shift=3.0" output.mp4