forked from kaledj/YTKeyframes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ytkeyframes.py
30 lines (25 loc) · 815 Bytes
/
ytkeyframes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import cv2, sys
import numpy as np
from download import Download
from boundarydetector import BoundaryDetector
from kfextractor import KeyframeExtractor
url = "http://www.youtube.com/watch?v=6FDTMRK7-24"
def main():
print("Downloading video...")
url = sys.argv[1]
dl = Download(url)
videoFile = dl.getVideo()
# videoFile = "testVideo.mp4"
print("Detecting shot boundaries...")
bd = BoundaryDetector(videoFile)
shotBounds = bd.getShotBoundaries()
print("{0} shot boundaries found...".format(np.sum(shotBounds)))
# shotBounds = np.load("bounds.npy")
print("Extracting representative keyframes...")
kfExtractor = KeyframeExtractor(videoFile)
frames = kfExtractor.extractKeyframes(shotBounds)
for frame in frames:
cv2.imshow("Keyframes", frame)
cv2.waitKey()
if __name__ == '__main__':
main()