Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ from pydub import AudioSegment
|
|
9 |
from PIL import Image
|
10 |
import numpy as np
|
11 |
import os
|
12 |
-
import
|
13 |
import uuid
|
14 |
import time
|
15 |
from concurrent.futures import ThreadPoolExecutor
|
@@ -87,16 +87,14 @@ def fn(vid, bg_type="Color", bg_image=None, bg_video=None, color="#00FF00", fps=
|
|
87 |
|
88 |
processed_video = mp.ImageSequenceClip(processed_frames, fps=fps)
|
89 |
processed_video = processed_video.set_audio(audio)
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
buf.seek(0)
|
95 |
|
96 |
elapsed_time = time.time() - start_time
|
97 |
yield gr.update(visible=False), gr.update(visible=True), f"Processing complete! Elapsed time: {elapsed_time:.2f} seconds"
|
98 |
-
|
99 |
-
yield processed_frames[-1], buf, f"Processing complete! Elapsed time: {elapsed_time:.2f} seconds"
|
100 |
|
101 |
except Exception as e:
|
102 |
print(f"Error: {e}")
|
|
|
9 |
from PIL import Image
|
10 |
import numpy as np
|
11 |
import os
|
12 |
+
import tempfile
|
13 |
import uuid
|
14 |
import time
|
15 |
from concurrent.futures import ThreadPoolExecutor
|
|
|
87 |
|
88 |
processed_video = mp.ImageSequenceClip(processed_frames, fps=fps)
|
89 |
processed_video = processed_video.set_audio(audio)
|
90 |
+
|
91 |
+
with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as temp_file:
|
92 |
+
temp_filepath = temp_file.name
|
93 |
+
processed_video.write_videofile(temp_filepath, codec="libx264")
|
|
|
94 |
|
95 |
elapsed_time = time.time() - start_time
|
96 |
yield gr.update(visible=False), gr.update(visible=True), f"Processing complete! Elapsed time: {elapsed_time:.2f} seconds"
|
97 |
+
yield processed_frames[-1], temp_filepath, f"Processing complete! Elapsed time: {elapsed_time:.2f} seconds"
|
|
|
98 |
|
99 |
except Exception as e:
|
100 |
print(f"Error: {e}")
|