fffiloni commited on
Commit
4a23dca
1 Parent(s): e8e1113

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -16
app.py CHANGED
@@ -4,7 +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
- from moviepy.editor import *
 
8
 
9
  def find_scenes(video_path, threshold=27.0):
10
  # Open our video, create a scene manager, and add a detector.
@@ -17,26 +18,16 @@ def find_scenes(video_path, threshold=27.0):
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
  #input_video_path = video_path
25
  #output_video_path = 'video_out.mp4'
26
- # Import everything needed to edit video clips
27
-
28
-
29
- # loading video gfg
30
- clip = VideoFileClip(video_path)
31
- # getting only first 5 seconds
32
- clip = clip.subclip(shot_in, shot_out)
33
- # showing clip
34
- clip.ipython_display(width = 360)
35
- clip.write_videofile("clip.mp4")
36
-
37
- output_video_path = ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname="output_video.mp4")
38
  print(output_video_path)
39
- return scene_list, "clip.mp4"
40
 
41
  video_input=gr.Video(source="upload", format="mp4", mirror_webcam="False");
42
 
 
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
 
10
  def find_scenes(video_path, threshold=27.0):
11
  # Open our video, create a scene manager, and add a detector.
 
18
 
19
  #print(scene_list)
20
 
21
+ shot_in = scene_list[0][0].get_timecode()
22
+ shot_out = scene_list[0][1].get_timecode()
23
  #print(shot_in, shot_out)
24
 
25
  #input_video_path = video_path
26
  #output_video_path = 'video_out.mp4'
27
+ # ffmpeg_extract_subclip("full.mp4", start_seconds, end_seconds, targetname="cut.mp4")
28
+ ffmpeg_extract_subclip(video_path, shot_in, shot_out, targetname="cut.mp4")
 
 
 
 
 
 
 
 
 
 
29
  print(output_video_path)
30
+ return scene_list, "cut.mp4"
31
 
32
  video_input=gr.Video(source="upload", format="mp4", mirror_webcam="False");
33