How to Use FFmpeg Photosensibility Filter
This article provides a practical guide on how to use the
photosensibility filter in FFmpeg to detect and mitigate
potentially harmful flashing lights in video files. You will learn the
basic syntax, key parameters, and command-line examples needed to make
your video content safer for individuals with photosensitive
epilepsy.
Understanding the Photosensibility Filter
The photosensibility filter in FFmpeg is designed to
prevent photosensitive epileptic seizures by analyzing video frames for
rapid luminance changes (flashing) and high-contrast patterns. When the
filter detects these triggers, it automatically dampens the intensity of
the flashes, smoothing out the transition between frames to make the
video safer for viewers.
Basic Syntax
To apply the filter with its default settings, use the following basic command:
ffmpeg -i input.mp4 -vf "photosensibility" output.mp4This command reads input.mp4, processes the video
streams through the photosensibility filter using default safety
thresholds, and exports the corrected video to
output.mp4.
Adjusting Filter Parameters
You can fine-tune how the filter behaves by adjusting its parameters.
The syntax for passing options is
photosensibility=parameter1=value1:parameter2=value2.
The key parameters include:
f(Frame Factor): Defines the size of the temporal window (in frames) used to calculate light intensity changes. The default value is9. Increasing this value averages the light intensity over a longer period.thresholdort(Threshold Factor): Controls the sensitivity of the detection. The default is1.0. Lowering this value (e.g.,0.5) makes the filter more sensitive, meaning it will detect and reduce milder flashes. Raising it makes the filter less aggressive.skip(Pixel Skip): Speeds up processing by skipping pixels during analysis. The default is1(no skip, highest accuracy). Setting it to2or higher processes the video faster but may miss localized flashing.p(Patch Size): Defines the size of the grid patches used for localized flash detection. The default is16.
Example: Strict Filtering for High-Risk Content
If you are processing a video with known intense strobing and want to apply maximum protection, you can lower the threshold and increase the frame window:
ffmpeg -i input.mp4 -vf "photosensibility=f=12:t=0.5:skip=1" output.mp4Example: Fast Processing for Long Videos
For faster rendering of long videos where processing time is a constraint, you can instruct the filter to skip pixels:
ffmpeg -i input.mp4 -vf "photosensibility=f=9:t=1.0:skip=2" output.mp4Verifying the Results
To verify how the filter is altering your video, compare the original file and the output file side-by-side using a media player. Areas of the video that previously contained rapid, jarring flashes of white or bright colors should now appear significantly dimmer and transition more smoothly, while the rest of the non-flashing footage remains visually unchanged.