fffiloni commited on
Commit
cafc0a7
1 Parent(s): c2f9f7c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -4,7 +4,7 @@ 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
- 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.
@@ -21,9 +21,14 @@ def find_scenes(video_path, threshold=27.0):
21
  shot_out = scene_list[0][1].get_frames()
22
  #print(shot_in, shot_out)
23
 
24
- ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname="video_out.mp4")
 
 
 
 
 
25
 
26
- return scene_list, "video_out.mp4"
27
 
28
  video_input=gr.Video(source="upload", format="mp4", mirror_webcam="False");
29
 
 
4
  from scenedetect.detectors import ContentDetector
5
  from scenedetect.video_splitter import split_video_ffmpeg
6
 
7
+ from moviepy.video.io.VideoFileClip import VideoFileClip
8
 
9
  def find_scenes(video_path, threshold=27.0):
10
  # Open our video, create a scene manager, and add a detector.
 
21
  shot_out = scene_list[0][1].get_frames()
22
  #print(shot_in, shot_out)
23
 
24
+ input_video_path = video_path
25
+ output_video_path = 'video_out.mp4'
26
+
27
+ with VideoFileClip(input_video_path) as video:
28
+ new = video.subclip(shot_in, shot_out)
29
+ new.write_videofile(output_video_path, audio_codec='aac')
30
 
31
+ return scene_list, output_video_path
32
 
33
  video_input=gr.Video(source="upload", format="mp4", mirror_webcam="False");
34