Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -37,24 +37,33 @@ def get_video_dimension(filepath):
|
|
37 |
video.release()
|
38 |
return width, height, fps
|
39 |
|
40 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
# Load the video clip
|
42 |
-
clip = VideoFileClip(
|
43 |
|
44 |
-
# Calculate the
|
45 |
-
|
46 |
-
|
|
|
|
|
47 |
|
48 |
# Resize the video clip
|
49 |
-
resized_clip = clip.resize(width=
|
50 |
|
51 |
-
# Write the resized video to
|
52 |
-
resized_clip.write_videofile(
|
53 |
|
54 |
# Close the video clip
|
55 |
clip.close()
|
56 |
|
57 |
-
return
|
58 |
|
59 |
def run_inference(prompt, video_path, condition, video_length):
|
60 |
|
|
|
37 |
video.release()
|
38 |
return width, height, fps
|
39 |
|
40 |
+
def adjust_to_multiple_of_12(number):
|
41 |
+
remainder = number % 12
|
42 |
+
if remainder != 0:
|
43 |
+
adjustment = 12 - remainder
|
44 |
+
number += adjustment
|
45 |
+
return number
|
46 |
+
|
47 |
+
def resize_video(input_file, output_file, new_width):
|
48 |
# Load the video clip
|
49 |
+
clip = VideoFileClip(input_file)
|
50 |
|
51 |
+
# Calculate the aspect ratio
|
52 |
+
ratio = new_width / clip.size[0]
|
53 |
+
new_height = int(clip.size[1] * ratio)
|
54 |
+
new_height_adjusted = adjust_to_multiple_of_12(new_height)
|
55 |
+
print(f"OLD H: {new_height} | NEW H: {new_height_adjusted}")
|
56 |
|
57 |
# Resize the video clip
|
58 |
+
resized_clip = clip.resize(width=new_width, height=new_height_adjusted)
|
59 |
|
60 |
+
# Write the resized video to a file
|
61 |
+
resized_clip.write_videofile(output_file, codec="libx264")
|
62 |
|
63 |
# Close the video clip
|
64 |
clip.close()
|
65 |
|
66 |
+
return output_file
|
67 |
|
68 |
def run_inference(prompt, video_path, condition, video_length):
|
69 |
|