I wrote an ffmpeg filter which attempts to do this. It's not perfect, but it does seem to work well with a good part of the test samples I was working with.
It has now been included into ffmpeg, and should be available in the next release.
With mpv, you can enable it with:
mpv video.mp4 --vf=photosensitivity
The filter can be made more or less strict by changing its parameters, e.g.:
mpv video.mp4 --vf=photosensitivity:threshold=0.5 # lower is stricter
To check how bad a video is from the command line, you can run the filter in bypass mode, and look at the verbose output:
ffmpeg -i video.mp4 -vf photosensitivity=bypass=1 -v verbose -f null /dev/null
The output would have lines such as:
[photosensitivity @ 000000000929aa80] badness: 69183 -> 70173 / 15360 (456% - EXCEEDED)
For programmatic use, the filter also produces some frame metadata. You can ask ffmpeg to export it to a text file as follows:
ffmpeg -i video.mp4 -vf photosensitivity=bypass=1,metadata=print:file=photosensitivity-analysis.txt -f null /dev/null
The created photosensitivity-analysis.txt
file will have one block of lines such as these per frame:
frame:300 pts:300 pts_time:10
lavfi.photosensitivity.badness=4.269336
lavfi.photosensitivity.fixed-badness=4.269336
lavfi.photosensitivity.frame-badness=0.459766
lavfi.photosensitivity.factor=1.000000
When badness
is greater than one, the badness threshold has been exceeded.