fffiloni commited on
Commit
85cb9b5
1 Parent(s): 6fc3067

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -4,6 +4,8 @@ from scenedetect import open_video, SceneManager, split_video_ffmpeg
4
  from scenedetect.detectors import ContentDetector
5
  from scenedetect.video_splitter import split_video_ffmpeg
6
 
 
 
7
  def find_scenes(video_path, threshold=27.0):
8
  # Open our video, create a scene manager, and add a detector.
9
  video = open_video(video_path)
@@ -15,17 +17,14 @@ def find_scenes(video_path, threshold=27.0):
15
 
16
  #print(scene_list)
17
 
18
- #shot_in = scene_list[0][0].get_frames()
19
- #shot_out = scene_list[0][1].get_frames()
20
  #print(shot_in, shot_out)
21
 
22
- for i, scene in enumerate(scene_list):
23
- print('Scene %2d: Start %s / Frame %d, End %s / Frame %d' % (
24
- i+1,
25
- scene[0].get_timecode(), scene[0].get_frames(),
26
- scene[1].get_timecode(), scene[1].get_frames(),))
27
- return scene_list
28
 
29
  video_input=gr.Video(source="upload", format="mp4", mirror_webcam="False");
30
 
31
- gr.Interface(fn=find_scenes, inputs=video_input, outputs="json").launch()
 
4
  from scenedetect.detectors import ContentDetector
5
  from scenedetect.video_splitter import split_video_ffmpeg
6
 
7
+ from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
8
+
9
  def find_scenes(video_path, threshold=27.0):
10
  # Open our video, create a scene manager, and add a detector.
11
  video = open_video(video_path)
 
17
 
18
  #print(scene_list)
19
 
20
+ shot_in = scene_list[0][0].get_frames()
21
+ shot_out = scene_list[0][1].get_frames()
22
  #print(shot_in, shot_out)
23
 
24
+ video_out = ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname=shot_in + "_" + shot_out + "video_out.mp4")
25
+
26
+ return scene_list, video_out
 
 
 
27
 
28
  video_input=gr.Video(source="upload", format="mp4", mirror_webcam="False");
29
 
30
+ gr.Interface(fn=find_scenes, inputs=video_input, outputs=["json", "video").launch()