pythonvideo-processing

Using scenedetect to spot subtle cut edits in a video?


I'm trying to use the Scenedetect Python package to detect subtle cuts in a video. For example, I'm looking at this video:

https://www.youtube.com/watch?v=fNb_-Tmxq8Q

I have downloaded the video and run the following on the mp4 file:

  --input Bruised\ Makeup\ Tutorial\ \[fNb_-Tmxq8Q\].mp4  detect-adaptive list-scenes

SceneDirect can pick up the more obvious cuts. However, there are some cuts it's missing: for example the quick cut at around 0:05 and the blur at around 0:16. I downloaded the --stats file but it's not clear to me how to define those cuts in a way that will capture them but avoid false positives. Any suggestions for how to do this?


Solution

  • I screwed around a bit with that tool (since I didn't know it before) and I think I found a solution. Have you already tried adjusting the config file? Changing the threshold did the job for me so that I don't get any false-positives anymore even tough the cut (e.g.) at 0:06 is being detected.

    For me it was easiest to just create a file called "config.cfg" and pass it along in the command. My command ended up like this: scenedetect -i Bruised\ Makeup\ Tutorial.mp4 -c .\config.cfg list-scenes

    In this custom config file, I just changed the "min-content-val" and "frame-window" variables. You can look up a sample config file from the creator here: https://raw.githubusercontent.com/Breakthrough/PySceneDetect/v0.6.4-release/scenedetect.cfg
    (This really helped me to figure out what to change. Maybe you want to try out changing different values too)

    If you want to, you can uncomment the config lines you need, but there are quite a few more options in that file than you actually need, so you can also just create a new empty file and add the variables you need to change. My config-file ended up like this:

    [detect-adaptive]
    min-content-val = 10
    frame-window = 3
    

    The first variable is kind of a threshold. But changing this one will result in more false-positives.
    This is where the other variable comes into play. It changes the amount of adjacent frames that are being averaged for each frame. I increased it from 2 to 3 which reduced the number of false-positives by quite a bit. For a different video you might have to change the config a bit more... But you probably can just play around with some values until you have a result you're happy with.

    You also asked about detecting the transition at the start with the blur. I don't think this tool is able to handle that. It is only able to detect changes happening between a few frames which makes this transition (which is quite smooth / long) really hard to detect for such an algorithm.

    Hope all of this helps!