PySceneDetect icon indicating copy to clipboard operation
PySceneDetect copied to clipboard

Define minimum and maximum number of splits in split-video

Open hanoonaR opened this issue 2 months ago • 1 comments

@Breakthrough,

Thank you for sharing your great work.

I have a question regarding the split-video functionality (scenedetect -i video.mp4 split-video). Is there a way to control the number of scenes or split? Like, set a minimum or maximum number of splits? Otherwise could you please suggest an alternative?

Thank you.

hanoonaR avatar Apr 23 '24 00:04 hanoonaR

Hi @hanoonaR;

Controlling the number of splits would require some kind of resolution method to determine both where to add missing cuts, and also where to remove them. With the Python API this is certainly possible, since you can do whatever you would like with the resulting scene list before the video is split:

from scenedetect import detect, ContentDetector, split_video_ffmpeg
scene_list = detect('my_video.mp4', ContentDetector())
# modify scene_list here
split_video_ffmpeg('my_video.mp4', scene_list)

As an example, you could combine the shortest scenes together until you have the desired amount.

You could also use minimum scene length and detect only a certain portion of the video to limit the maximum number of scenes. For example if you set minimum scene length to 1 second and limit the processing duration to 10s, there can never be more than 10 scenes detected.

To add this as an official feature however, we need to look into how it will be used, so the right method can be chosen. There are also some open questions. For example, where should the cuts be placed if we didn't find any? Could you share more about your use case?

Thanks for the comment/idea, glad you're finding the project useful!

Breakthrough avatar Apr 23 '24 01:04 Breakthrough