Spaces:
Running
on
L40S
Running
on
L40S
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
|
|
3 |
import torch
|
4 |
import gc
|
5 |
from diffusers import AutoencoderKLCogVideoX, CogVideoXImageToVideoPipeline, CogVideoXTransformer3DModel
|
@@ -109,16 +110,20 @@ def infer(image_path, prompt, orbit_type, progress=gr.Progress(track_tqdm=True))
|
|
109 |
export_to_video(video.frames[0], temp_path, fps=8)
|
110 |
|
111 |
try:
|
112 |
-
# Use ffmpeg
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
122 |
raise e
|
123 |
finally:
|
124 |
if os.path.exists(temp_path):
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
import subprocess
|
4 |
import torch
|
5 |
import gc
|
6 |
from diffusers import AutoencoderKLCogVideoX, CogVideoXImageToVideoPipeline, CogVideoXTransformer3DModel
|
|
|
110 |
export_to_video(video.frames[0], temp_path, fps=8)
|
111 |
|
112 |
try:
|
113 |
+
# Use ffmpeg via subprocess
|
114 |
+
cmd = [
|
115 |
+
'ffmpeg',
|
116 |
+
'-i', temp_path,
|
117 |
+
'-vf', f'scale={target_width}:{target_height}',
|
118 |
+
'-c:v', 'libx264',
|
119 |
+
'-preset', 'medium',
|
120 |
+
'-crf', '23',
|
121 |
+
'-y', # Overwrite output file if it exists
|
122 |
+
final_path
|
123 |
+
]
|
124 |
+
subprocess.run(cmd, check=True, capture_output=True)
|
125 |
+
except subprocess.CalledProcessError as e:
|
126 |
+
print(f"FFmpeg error: {e.stderr.decode()}")
|
127 |
raise e
|
128 |
finally:
|
129 |
if os.path.exists(temp_path):
|