Spaces:
Runtime error
Runtime error
set max length to 3 seconds and max fps to 24 to fit model limitations
Browse files
app.py
CHANGED
|
@@ -106,16 +106,16 @@ def get_frames(video_in, img_type):
|
|
| 106 |
# Cut the video to the first 5 seconds
|
| 107 |
video_out = f"{img_type}_video_cut.mp4"
|
| 108 |
|
| 109 |
-
ffmpeg_extract_subclip(video_in, t1=0, t2=
|
| 110 |
# Now, proceed with resizing the cut video
|
| 111 |
clip = VideoFileClip(video_out)
|
| 112 |
|
| 113 |
#check fps
|
| 114 |
|
| 115 |
-
if clip.fps >
|
| 116 |
-
print("vide rate is over
|
| 117 |
clip_resized = clip.resize(height=512)
|
| 118 |
-
clip_resized.write_videofile(f"{img_type}_video_resized.mp4", fps=
|
| 119 |
else:
|
| 120 |
print("video rate is OK")
|
| 121 |
clip_resized = clip.resize(height=512)
|
|
@@ -154,7 +154,7 @@ def get_matte(video_in, subject_to_remove):
|
|
| 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 |
-
|
| 158 |
f"{subject_to_remove}", # str in 'Text prompt' Textbox component
|
| 159 |
"", # str in 'Background prompt' Textbox component
|
| 160 |
api_name="/go_matte"
|
|
|
|
| 106 |
# Cut the video to the first 5 seconds
|
| 107 |
video_out = f"{img_type}_video_cut.mp4"
|
| 108 |
|
| 109 |
+
ffmpeg_extract_subclip(video_in, t1=0, t2=3, targetname=video_out)
|
| 110 |
# Now, proceed with resizing the cut video
|
| 111 |
clip = VideoFileClip(video_out)
|
| 112 |
|
| 113 |
#check fps
|
| 114 |
|
| 115 |
+
if clip.fps > 24:
|
| 116 |
+
print("vide rate is over 24, resetting to 24")
|
| 117 |
clip_resized = clip.resize(height=512)
|
| 118 |
+
clip_resized.write_videofile(f"{img_type}_video_resized.mp4", fps=24)
|
| 119 |
else:
|
| 120 |
print("video rate is OK")
|
| 121 |
clip_resized = clip.resize(height=512)
|
|
|
|
| 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 |
+
3, # 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"
|