Created
January 5, 2017 21:07
-
-
Save stuxcrystal/4931a92a71f1b556d085a799b332bd68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
def find_keyframes(clip, frame, epsilon=7): | |
for i, frame in enumerate(map(clip.get_frame, range(frame-epsilon, frame+epsilon))): | |
if frame.props.Scenechange: | |
yield i | |
TimeFrame = namedtuple("TimeFrame", "start end") | |
def get_nearest_scenechange(clip, start, end, epsilon=7): | |
core = vs.get_core(accept_lowercase=True) | |
clip = core.resize.Bilinear(clip, 640, 360) # speed up the analysis by resizing first | |
clip = core.wwxd.WWXD(clip) | |
start = tuple(find_keyframes(clip, start, epsilon)) | |
end = tuple(find_keyframes(clip, end, epsilon)) | |
return TimeFrame(start, end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment