Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,20 +8,14 @@ from scenedetect.detectors import ContentDetector
|
|
8 |
|
9 |
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
|
10 |
|
11 |
-
outputs = ["json", "file"
|
12 |
data_outputs = []
|
13 |
|
14 |
|
15 |
def fn(list):
|
16 |
return tuple(list);
|
17 |
|
18 |
-
|
19 |
-
vid = cv2.VideoCapture(video_path)
|
20 |
-
for i in range(start_frame, 1):
|
21 |
-
vid.set(1, i)
|
22 |
-
ret, still = vid.read()
|
23 |
-
output_image = cv2.imwrite(f'{video_path}_frame{i}.jpg', still)
|
24 |
-
return output_image
|
25 |
|
26 |
def find_scenes(video_path, threshold=27.0):
|
27 |
# Open our video, create a scene manager, and add a detector.
|
@@ -37,7 +31,7 @@ def find_scenes(video_path, threshold=27.0):
|
|
37 |
#print(scene_list)
|
38 |
|
39 |
shots = []
|
40 |
-
|
41 |
|
42 |
for i, scene in enumerate(scene_list):
|
43 |
shot_in = scene[0].get_frames() / scene[0].get_framerate()
|
@@ -47,12 +41,21 @@ def find_scenes(video_path, threshold=27.0):
|
|
47 |
data_outputs.append(target_name)
|
48 |
shots.append(target_name)
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
#outputs.append("video")
|
57 |
#shot_in = scene_list[1][0].get_frames() / scene_list[1][0].get_framerate()
|
58 |
#shot_out = (scene_list[1][1].get_frames() - 1) / scene_list[1][0].get_framerate()
|
@@ -60,10 +63,10 @@ def find_scenes(video_path, threshold=27.0):
|
|
60 |
|
61 |
results = fn(data_outputs)
|
62 |
print(results)
|
63 |
-
print(
|
64 |
#ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname="cut.mp4")
|
65 |
|
66 |
-
return scene_list, shots
|
67 |
|
68 |
video_input=gr.Video(source="upload", format="mp4");
|
69 |
|
|
|
8 |
|
9 |
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
|
10 |
|
11 |
+
outputs = ["json", "file"]
|
12 |
data_outputs = []
|
13 |
|
14 |
|
15 |
def fn(list):
|
16 |
return tuple(list);
|
17 |
|
18 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
def find_scenes(video_path, threshold=27.0):
|
21 |
# Open our video, create a scene manager, and add a detector.
|
|
|
31 |
#print(scene_list)
|
32 |
|
33 |
shots = []
|
34 |
+
stills = []
|
35 |
|
36 |
for i, scene in enumerate(scene_list):
|
37 |
shot_in = scene[0].get_frames() / scene[0].get_framerate()
|
|
|
41 |
data_outputs.append(target_name)
|
42 |
shots.append(target_name)
|
43 |
|
44 |
+
video = cv2.VideoCapture(video_path)
|
45 |
+
|
46 |
+
fps = video.get(cv2.CAP_PROP_FPS)
|
47 |
+
print('frames per second =',fps)
|
48 |
+
|
49 |
+
frame_id = scene[0].get_frames()
|
50 |
+
|
51 |
+
video.set(cv2.CAP_PROP_POS_FRAMES, frame_id)
|
52 |
+
ret, frame = video.read()
|
53 |
+
|
54 |
+
# Display and save frame
|
55 |
+
#cv2.imshow('frame', frame); cv2.waitKey(0)
|
56 |
+
|
57 |
+
img = cv2.imwrite(str(frame_id) + '_screenshot.png',frame)
|
58 |
+
stills.append(img)
|
59 |
#outputs.append("video")
|
60 |
#shot_in = scene_list[1][0].get_frames() / scene_list[1][0].get_framerate()
|
61 |
#shot_out = (scene_list[1][1].get_frames() - 1) / scene_list[1][0].get_framerate()
|
|
|
63 |
|
64 |
results = fn(data_outputs)
|
65 |
print(results)
|
66 |
+
print(stills)
|
67 |
#ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname="cut.mp4")
|
68 |
|
69 |
+
return scene_list, shots
|
70 |
|
71 |
video_input=gr.Video(source="upload", format="mp4");
|
72 |
|