As a concrete example to become familiar with PySceneDetect, let's use the following short clip from the James Bond movie, GoldenEye (Copyright © 1995 MGM):
https://www.youtube.com/watch?v=OMgIPnCnlbQ
You can download the clip from here (may have to right-click and save-as, put the video in your working directory as goldeneye.mp4).
In this case, we want to split this clip up into each individual scene - at each location where a fast cut occurs. This means we need to use content-aware detecton mode (detect-content) or adaptive mode (detect-adaptive). If the video instead contains fade-in/fade-out transitions you want to find, you can use detect-threshold instead.
Using the following command, let's run PySceneDetect on the video, and also save a scene list CSV file and some images of each scene:
scenedetect --input goldeneye.mp4 detect-adaptive list-scenes save-imagesRunning the above command, in the working directory, you should see a file goldeneye.scenes.csv, as well as individual frames for the start/middle/end of each scene as goldeneye-XXXX-00/01.jpg. The results should appear as follows:
The split-video command can be used to automatically split the input video using ffmpeg or mkvmerge. For example:
scenedetect -i goldeneye.mp4 detect-adaptive split-videoType scenedetect help split-video for a full list of options which can be specified for video splitting, including high quality mode (-hq/--high-quality) or copy mode (-c/--copy).
Detectors take a variety of parameters, which can be configured via command-line or by using a config file. If the default parameters do not produce correct results, you can generate a stats file using the -s / --stats option.
For example, with detect-content, if the default threshold of 27 does not produce correct results, we can determine the proper threshold by first generating a stats file:
scenedetect --input goldeneye.mp4 --stats goldeneye.stats.csv detect-adaptiveWe can then plot the values of the content_val column:
The peaks in values correspond to the scene breaks in the input video. In some cases the threshold may need to be raised or lowered accordingly.













