-
Notifications
You must be signed in to change notification settings - Fork 460
Description
Description of Problem & Solution
I've had some situations where I have a large number of video files with a similar structure where I'd like to select (or omit) a certain number of scenes from the output, either at the beginning or end of the file. These are generally Youtube downloads where the channel has a bunch of content at the beginning (title sequence) or end ("please like and subscribe!") that I'd rather not waste time saving and deleting.
It would be nice of scenedetect
had a way to select these to avoid extra files being created.
Proposed Implementation:
My proposal is to add a --scenes
(-S
) option that takes a string in the form of a comma-separated list of array indexes or slices. These indexes and slices would be used to generate a list of array indexes for the detected scene list, and only those indexes would be output when running save-images
or split-video
.
For example:
scenedetect -i input.mp4 --scenes 0,-3:
would save the first scene and the last three scenes, while
scenedetect -i input.mp4 --scenes 5:-5
would omit the first five and last 5 scenes.
In the case where the scene indexes are all positive (i.e. none of them depend on knowing how long the list is) my implementation of this also short-circuits the detect-scenes
process, stopping after it knows that there are no more scenes that will be kept. So -S 0
runs extremely fast, breaking out of scene detection once it gets to the first cut, and just saving the images / video from the first scene.
Knowing a priori what scenes are to be kept is a bit of a unique situation, so I don't know if this is anything anyone else would care to have, but I've already implemented it and it works for me (tm), so I'd be happy to submit a PR if there's any interest. Would just need to tidy it up and add docs.