You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow for clips to be split with content outside of start/end timeframe #115
Description of Problem & Solution
When using -start and -end, the tool defines the area of a video to be processed. In some cases, however, you may wish to limit the area to be analyzed, but treat the area outside of that window as part of the split files.
Example, 30 minute file with one scene break at 15 minutes:
In the current tool, a command such as scenedetect -i somevideo.mp4 time -s 00:13:00 -e 00:15:00 detect-threshold split-video -c will produce two clips, each of 2 minute duration.
However, in some cases you may wish to have two 15 minute clips, including the content before and after the processed duration.
Proposed Implementation:
A proposed command line to enable this would be -expand-split-clips
Alternative Solutions:
Using the timecodes generated can be fed into ffmpeg and executed manually / via a script.
This should definitely be possible to add to PySceneDetect, thanks for the suggestion @charlesvestal.
Technical notes for myself (or anyone else who wants to take a crack at this) which may be useful:
It should be possible to just modify the arguments passed to the get_scenes_from_cuts() function called by the SceneManager, passing 0 for the start time and the video length for the end time to achieve the desired outcome (the only difficulty being getting the video length)
When creating the VideoManager with this option, only the start time should be modified; the end time must only be set when calling detect_scenes() to support getting the video length
Surprisingly, the only thing which makes this complicated is reliably getting the total number of frames in a video file; I've found using the OpenCV get method to obtain VideoCapture properties can be somewhat unreliable (thus internally it is only used for estimation of progress, but video streams are processed until exhausted)
Something like SeekToEnd() needs to be implemented to the VideoManager to manually seek to the end and get this number in the case where -expand-split-clips is passed
Perhaps an additional option could be added to allow using the estimated total length instead of seeking through the whole video (which is currently somewhat slow), but I would prefer correctness over speed for the first implementation of such a feature regardless
Activity
Breakthrough commentedon Sep 1, 2019
This should definitely be possible to add to PySceneDetect, thanks for the suggestion @charlesvestal.
Technical notes for myself (or anyone else who wants to take a crack at this) which may be useful:
get_scenes_from_cuts()function called by the SceneManager, passing 0 for the start time and the video length for the end time to achieve the desired outcome (the only difficulty being getting the video length)detect_scenes()to support getting the video lengthgetmethod to obtain VideoCapture properties can be somewhat unreliable (thus internally it is only used for estimation of progress, but video streams are processed until exhausted)SeekToEnd()needs to be implemented to the VideoManager to manually seek to the end and get this number in the case where-expand-split-clipsis passedAdd --expand-to-video flag to split-video (#115) (#551)
[docs] Update changelog re: #115