Spaces:
Paused
Paused
make sure video input is not greater than 24 fps
Browse files
app.py
CHANGED
@@ -170,6 +170,26 @@ def get_matte(video_in, subject_to_remove):
|
|
170 |
def infer_auto(project_name, video_in, subject_to_remove):
|
171 |
timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
172 |
print(video_in)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
matte_video = get_matte(video_in, subject_to_remove)
|
174 |
|
175 |
# Cut the video to the first 3 seconds
|
|
|
170 |
def infer_auto(project_name, video_in, subject_to_remove):
|
171 |
timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
172 |
print(video_in)
|
173 |
+
|
174 |
+
# Load the video clip
|
175 |
+
video_clip = VideoFileClip(video_in)
|
176 |
+
|
177 |
+
# Check the original FPS of the video
|
178 |
+
original_fps = video_clip.fps
|
179 |
+
|
180 |
+
# Set the target FPS to 24
|
181 |
+
target_fps = 24
|
182 |
+
|
183 |
+
# Check if the original FPS is greater than 24
|
184 |
+
if original_fps > target_fps:
|
185 |
+
# Convert the video to the target FPS
|
186 |
+
video_clip = video_clip.set_duration(video_clip.duration * (target_fps / original_fps))
|
187 |
+
video_clip = video_clip.set_fps(target_fps)
|
188 |
+
|
189 |
+
# Write the new video to an output file
|
190 |
+
video_clip.write_videofile(f"retimed_clip_in_{timestamp}.mp4", codec='libx264')
|
191 |
+
video_in = f"retimed_clip_in_{timestamp}.mp4"
|
192 |
+
|
193 |
matte_video = get_matte(video_in, subject_to_remove)
|
194 |
|
195 |
# Cut the video to the first 3 seconds
|