Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ from PIL import Image, ImageDraw
|
|
6 |
import tempfile
|
7 |
import os
|
8 |
import logging
|
9 |
-
from tqdm import tqdm
|
10 |
|
11 |
# Configuraci贸n de logging
|
12 |
logging.basicConfig(
|
@@ -50,7 +49,7 @@ def generate_video(audio_file, image_file):
|
|
50 |
points.extend([(x, y_pos), (x, y_neg)])
|
51 |
|
52 |
if len(points) > 2:
|
53 |
-
draw.polygon(points, fill=(255, 0, 0, 128))
|
54 |
|
55 |
return np.array(frame)
|
56 |
|
@@ -61,18 +60,15 @@ def generate_video(audio_file, image_file):
|
|
61 |
|
62 |
# 6. Guardar video
|
63 |
with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmpfile:
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
logger=None,
|
72 |
-
progress_callback=lambda gd: pbar.update(gd['percent'] - pbar.n)
|
73 |
-
)
|
74 |
|
75 |
-
#
|
76 |
if not os.path.exists(tmpfile.name):
|
77 |
raise Exception("Error al guardar el video temporal")
|
78 |
|
|
|
6 |
import tempfile
|
7 |
import os
|
8 |
import logging
|
|
|
9 |
|
10 |
# Configuraci贸n de logging
|
11 |
logging.basicConfig(
|
|
|
49 |
points.extend([(x, y_pos), (x, y_neg)])
|
50 |
|
51 |
if len(points) > 2:
|
52 |
+
draw.polygon(points, fill=(255, 0, 0, 128)) # Rojo semitransparente
|
53 |
|
54 |
return np.array(frame)
|
55 |
|
|
|
60 |
|
61 |
# 6. Guardar video
|
62 |
with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmpfile:
|
63 |
+
video.write_videofile(
|
64 |
+
tmpfile.name,
|
65 |
+
codec="libx264",
|
66 |
+
audio_codec="aac",
|
67 |
+
fps=24,
|
68 |
+
logger=None
|
69 |
+
)
|
|
|
|
|
|
|
70 |
|
71 |
+
# Verificar que el archivo existe
|
72 |
if not os.path.exists(tmpfile.name):
|
73 |
raise Exception("Error al guardar el video temporal")
|
74 |
|