fffiloni commited on
Commit
b003bf2
1 Parent(s): 75a34fe

set max lenght video source to 5 sec

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -103,7 +103,12 @@ def infer(video_frames, masks_frames, project_name):
103
  def get_frames(video_in, img_type):
104
  frames = []
105
  #resize the video
106
- clip = VideoFileClip(video_in)
 
 
 
 
 
107
 
108
  #check fps
109
 
@@ -149,7 +154,7 @@ def get_matte(video_in, subject_to_remove):
149
  print("Trying to call video matting")
150
  result = matte_client.predict(
151
  f"{video_in}", # str (filepath on your computer (or URL) of file) in 'parameter_4' Video component
152
- 10, # int | float (numeric value between 0 and 10) in 'Cut video at (s)' Slider component
153
  f"{subject_to_remove}", # str in 'Text prompt' Textbox component
154
  "", # str in 'Background prompt' Textbox component
155
  api_name="/go_matte"
 
103
  def get_frames(video_in, img_type):
104
  frames = []
105
  #resize the video
106
+ # Cut the video to the first 5 seconds
107
+ video_out = f"{img_type}_video_cut.mp4"
108
+ ffmpeg_extract_subclip(video_in, start_time=0, end_time=5, targetname=video_out)
109
+
110
+ # Now, proceed with resizing the cut video
111
+ clip = VideoFileClip(video_out)
112
 
113
  #check fps
114
 
 
154
  print("Trying to call video matting")
155
  result = matte_client.predict(
156
  f"{video_in}", # str (filepath on your computer (or URL) of file) in 'parameter_4' Video component
157
+ 5, # int | float (numeric value between 0 and 10) in 'Cut video at (s)' Slider component
158
  f"{subject_to_remove}", # str in 'Text prompt' Textbox component
159
  "", # str in 'Background prompt' Textbox component
160
  api_name="/go_matte"