Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -87,6 +87,38 @@ def make_nearest_multiple_of_32(number):
|
|
87 |
number += 32 - remainder
|
88 |
return number
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
def run_inference(prompt, video_path, condition, video_length, seed, steps):
|
91 |
|
92 |
seed = math.floor(seed)
|
@@ -156,8 +188,9 @@ def run_inference(prompt, video_path, condition, video_length, seed, steps):
|
|
156 |
# Check generated video FPS
|
157 |
gen_fps = get_video_dimension(video_path_output)[2]
|
158 |
print(f"GEN VIDEO FPS: {gen_fps}")
|
|
|
159 |
print(f"FINISHED !")
|
160 |
-
return "done",
|
161 |
|
162 |
|
163 |
css="""
|
|
|
87 |
number += 32 - remainder
|
88 |
return number
|
89 |
|
90 |
+
def change_video_fps(input_file):
|
91 |
+
print(f"CHANGING FIANL OUTPUT FPS")
|
92 |
+
cap = cv2.VideoCapture(input_path)
|
93 |
+
# Check if the final file already exists
|
94 |
+
if os.path.exists('output_video.mp4'):
|
95 |
+
# Delete the existing file
|
96 |
+
os.remove('output_video.mp4')
|
97 |
+
output_path = 'output_video.mp4'
|
98 |
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
99 |
+
output_fps = 12
|
100 |
+
output_size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
|
101 |
+
out = cv2.VideoWriter(output_path, fourcc, output_fps, output_size)
|
102 |
+
|
103 |
+
frame_count = 0
|
104 |
+
while cap.isOpened():
|
105 |
+
ret, frame = cap.read()
|
106 |
+
if not ret:
|
107 |
+
break
|
108 |
+
|
109 |
+
# Write the current frame to the output video multiple times to increase the frame rate
|
110 |
+
for _ in range(output_fps // 8):
|
111 |
+
out.write(frame)
|
112 |
+
|
113 |
+
frame_count += 1
|
114 |
+
print(f'Processed frame {frame_count}')
|
115 |
+
|
116 |
+
cap.release()
|
117 |
+
out.release()
|
118 |
+
cv2.destroyAllWindows()
|
119 |
+
|
120 |
+
return 'output_video.mp4'
|
121 |
+
|
122 |
def run_inference(prompt, video_path, condition, video_length, seed, steps):
|
123 |
|
124 |
seed = math.floor(seed)
|
|
|
188 |
# Check generated video FPS
|
189 |
gen_fps = get_video_dimension(video_path_output)[2]
|
190 |
print(f"GEN VIDEO FPS: {gen_fps}")
|
191 |
+
final = change_video_fps(video_path_output)
|
192 |
print(f"FINISHED !")
|
193 |
+
return "done", final
|
194 |
|
195 |
|
196 |
css="""
|