Search code examples
ffmpegdetectionscene

ffmpeg scene detection: check only every nth frame?


I'm working on a tool with which I can make quick supercuts of longer films.

I'm using ffmpeg scene detection to split the scenes like this (and then parse the output in Python):

ffmpeg -i "video.mp4" -filter_complex "select='gt(scene,0.3)',metadata=print:file=_ffScenes.txt" -vsync vfr scn_%%03d.jpg

Many films have fades, which is a problem with scene detection.

I don't need the accuracy, analyzing the file at 1 fps would be sufficient. I tried to lower the input frame rate to 1 fps but the scene detection still checks every frame. How could this be done?

Thanks!


Solution

  • Chain two select filters together,

    ffmpeg -i "video.mp4" -filter_complex "select='not(mod(n,X))',select='gt(scene,0.3)',metadata=print:file=_ffScenes.txt" -vsync vfr scn_%%03d.jpg

    where X is your interval, in frames.