Configure FFmpeg Lagfun Filter Decay Factors
This article explains how to configure the decay factor for the luma
and chroma channels using the FFmpeg lagfun video filter.
You will learn the specific parameters used to target individual video
planes and see practical command examples to achieve custom temporal
fading and motion trail effects.
The lagfun filter is a temporal effect in FFmpeg that
creates a trail or “ghosting” effect by slowly fading out pixels from
previous frames. The speed of this fade is controlled by the decay
factor, where a value of 0.0 means instant decay (no
effect) and 1.0 means no decay (the pixel remains
indefinitely).
To configure the decay factors for the luma and chroma channels individually, you must target the specific plane parameters of the filter:
decay1: Controls the decay factor for the first plane (Luma / Y).decay2: Controls the decay factor for the second plane (Chroma U / Cb).decay3: Controls the decay factor for the third plane (Chroma V / Cr).decay4: Controls the decay factor for the fourth plane (Alpha, if applicable).
Basic Syntax
The basic syntax for specifying these channels in your filtergraph is:
lagfun=decay1=value:decay2=value:decay3=valuePractical Examples
1. High Luma Lag with Fast Chroma Decay
If you want a strong, bright motion trail but want to prevent color bleeding or rainbow-like smearing, you can set a high decay for the luma channel and a low decay for the chroma channels:
ffmpeg -i input.mp4 -vf "lagfun=decay1=0.95:decay2=0.5:decay3=0.5" output.mp4In this command: * decay1=0.95 keeps the
brightness/detail details on screen for a long time. *
decay2=0.5 and decay3=0.5 force the color
information to fade quickly, keeping the trails mostly monochromatic or
naturally colored.
2. High Chroma Lag with Fast Luma Decay
To create an artistic, psychedelic color-bleeding effect where colors smear across the screen but the sharp details of the video update normally, reverse the settings:
ffmpeg -i input.mp4 -vf "lagfun=decay1=0.2:decay2=0.98:decay3=0.98" output.mp4In this command: * decay1=0.2 ensures the
black-and-white structural details of the video do not lag. *
decay2=0.98 and decay3=0.98 create extreme,
long-lasting trails for the color channels.