Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -109,22 +109,18 @@ def infer(video_frames, masks_frames, project_name):
|
|
109 |
def get_frames(video_in, img_type):
|
110 |
frames = []
|
111 |
#resize the video
|
112 |
-
|
113 |
-
#video_out = f"{img_type}_video_cut.mp4"
|
114 |
-
|
115 |
-
#ffmpeg_extract_subclip(video_in, t1=0, t2=3, targetname=video_out)
|
116 |
-
# Now, proceed with resizing the cut video
|
117 |
clip = VideoFileClip(video_in)
|
118 |
|
119 |
#check fps
|
120 |
|
121 |
if clip.fps > 30:
|
122 |
print("vide rate is over 30, resetting to 30")
|
123 |
-
clip_resized = clip.resize(
|
124 |
clip_resized.write_videofile(f"{img_type}_video_resized.mp4", fps=30)
|
125 |
else:
|
126 |
print("video rate is OK")
|
127 |
-
clip_resized = clip.resize(
|
128 |
clip_resized.write_videofile(f"{img_type}_video_resized.mp4", fps=clip.fps)
|
129 |
|
130 |
|
@@ -175,7 +171,10 @@ def infer_auto(project_name, video_in, subject_to_remove):
|
|
175 |
print(video_in)
|
176 |
matte_video = get_matte(video_in, subject_to_remove)
|
177 |
|
178 |
-
|
|
|
|
|
|
|
179 |
print(video_frames[0])
|
180 |
|
181 |
masks_frames = get_frames(matte_video, "mask")
|
|
|
109 |
def get_frames(video_in, img_type):
|
110 |
frames = []
|
111 |
#resize the video
|
112 |
+
|
|
|
|
|
|
|
|
|
113 |
clip = VideoFileClip(video_in)
|
114 |
|
115 |
#check fps
|
116 |
|
117 |
if clip.fps > 30:
|
118 |
print("vide rate is over 30, resetting to 30")
|
119 |
+
clip_resized = clip.resize(height=512)
|
120 |
clip_resized.write_videofile(f"{img_type}_video_resized.mp4", fps=30)
|
121 |
else:
|
122 |
print("video rate is OK")
|
123 |
+
clip_resized = clip.resize(height=512)
|
124 |
clip_resized.write_videofile(f"{img_type}_video_resized.mp4", fps=clip.fps)
|
125 |
|
126 |
|
|
|
171 |
print(video_in)
|
172 |
matte_video = get_matte(video_in, subject_to_remove)
|
173 |
|
174 |
+
# Cut the video to the first 3 seconds
|
175 |
+
video_cut = f"video_cut.mp4"
|
176 |
+
ffmpeg_extract_subclip(video_in, t1=0, t2=3, targetname=video_cut)
|
177 |
+
video_frames = get_frames(video_cut, "source")
|
178 |
print(video_frames[0])
|
179 |
|
180 |
masks_frames = get_frames(matte_video, "mask")
|