Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,12 @@ from scenedetect.detectors import ContentDetector
|
|
7 |
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
|
8 |
|
9 |
outputs = []
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
def find_scenes(video_path, threshold=27.0):
|
12 |
# Open our video, create a scene manager, and add a detector.
|
@@ -18,27 +24,27 @@ def find_scenes(video_path, threshold=27.0):
|
|
18 |
scene_list = scene_manager.get_scene_list()
|
19 |
|
20 |
outputs.append("json")
|
|
|
21 |
#print(scene_list)
|
22 |
-
|
23 |
|
24 |
for i, scene in enumerate(scene_list):
|
25 |
shot_in = scene[0].get_frames() / scene[0].get_framerate()
|
26 |
shot_out = (scene[1].get_frames() - 1) / scene[0].get_framerate()
|
27 |
target_name = str(i)+"_cut.mp4"
|
28 |
ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname=target_name)
|
29 |
-
|
30 |
outputs.append("video")
|
31 |
#shot_in = scene_list[1][0].get_frames() / scene_list[1][0].get_framerate()
|
32 |
#shot_out = (scene_list[1][1].get_frames() - 1) / scene_list[1][0].get_framerate()
|
33 |
#print(shot_in, shot_out)
|
34 |
|
35 |
-
|
36 |
-
print(outputs)
|
37 |
|
38 |
#ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname="cut.mp4")
|
39 |
|
40 |
-
return
|
41 |
-
|
42 |
video_input=gr.Video(source="upload", format="mp4");
|
43 |
|
44 |
gr.Interface(fn=find_scenes, inputs=video_input, outputs=outputs).launch()
|
|
|
7 |
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
|
8 |
|
9 |
outputs = []
|
10 |
+
data_outputs = []
|
11 |
+
|
12 |
+
def fn(list):
|
13 |
+
return tuple(list);
|
14 |
+
|
15 |
+
|
16 |
|
17 |
def find_scenes(video_path, threshold=27.0):
|
18 |
# Open our video, create a scene manager, and add a detector.
|
|
|
24 |
scene_list = scene_manager.get_scene_list()
|
25 |
|
26 |
outputs.append("json")
|
27 |
+
data_outputs.append(scene_list)
|
28 |
#print(scene_list)
|
29 |
+
|
30 |
|
31 |
for i, scene in enumerate(scene_list):
|
32 |
shot_in = scene[0].get_frames() / scene[0].get_framerate()
|
33 |
shot_out = (scene[1].get_frames() - 1) / scene[0].get_framerate()
|
34 |
target_name = str(i)+"_cut.mp4"
|
35 |
ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname=target_name)
|
36 |
+
data_outputs.append(target_name)
|
37 |
outputs.append("video")
|
38 |
#shot_in = scene_list[1][0].get_frames() / scene_list[1][0].get_framerate()
|
39 |
#shot_out = (scene_list[1][1].get_frames() - 1) / scene_list[1][0].get_framerate()
|
40 |
#print(shot_in, shot_out)
|
41 |
|
42 |
+
results = fn(data_outputs)
|
|
|
43 |
|
44 |
#ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname="cut.mp4")
|
45 |
|
46 |
+
return results
|
47 |
+
|
48 |
video_input=gr.Video(source="upload", format="mp4");
|
49 |
|
50 |
gr.Interface(fn=find_scenes, inputs=video_input, outputs=outputs).launch()
|