Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -97,11 +97,33 @@ async def procesar_video(video_input, texto_tts, voz_seleccionada):
|
|
97 |
audio_original
|
98 |
)
|
99 |
|
100 |
-
#
|
101 |
-
|
|
|
|
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
# Combinar video con audio
|
104 |
-
video_con_audio =
|
105 |
|
106 |
# Concatenar intro + video + outro SIN alteraciones
|
107 |
video_final = concatenate_videoclips(
|
@@ -118,6 +140,7 @@ async def procesar_video(video_input, texto_tts, voz_seleccionada):
|
|
118 |
audio_codec="aac",
|
119 |
fps=video_original.fps, # Mantener FPS original
|
120 |
threads=4,
|
|
|
121 |
verbose=False
|
122 |
)
|
123 |
eliminar_archivo_tiempo(tmp.name)
|
|
|
97 |
audio_original
|
98 |
)
|
99 |
|
100 |
+
# Redimensionar el video a 1280x720 manteniendo la relaci贸n de aspecto
|
101 |
+
target_width = 1280
|
102 |
+
target_height = 720
|
103 |
+
video_resized = video_original.resize(height=target_height) # Ajustar altura a 720p
|
104 |
|
105 |
+
# Si el video es m谩s ancho o m谩s estrecho que 1280, ajustar m谩rgenes o recortar
|
106 |
+
current_width = video_resized.w
|
107 |
+
current_height = video_resized.h
|
108 |
+
|
109 |
+
if current_width < target_width:
|
110 |
+
# Centrar el video horizontalmente con m谩rgenes negros
|
111 |
+
margin_left = (target_width - current_width) // 2
|
112 |
+
margin_right = target_width - current_width - margin_left
|
113 |
+
video_final = video_resized.margin(
|
114 |
+
left=margin_left,
|
115 |
+
right=margin_right,
|
116 |
+
color=(0, 0, 0) # Negro
|
117 |
+
)
|
118 |
+
else:
|
119 |
+
# Recortar el video horizontalmente si es m谩s ancho que 1280
|
120 |
+
video_final = video_resized.crop(
|
121 |
+
x1=(current_width - target_width) // 2,
|
122 |
+
x2=current_width - (current_width - target_width) // 2
|
123 |
+
)
|
124 |
+
|
125 |
# Combinar video con audio
|
126 |
+
video_con_audio = video_final.set_audio(audio_final)
|
127 |
|
128 |
# Concatenar intro + video + outro SIN alteraciones
|
129 |
video_final = concatenate_videoclips(
|
|
|
140 |
audio_codec="aac",
|
141 |
fps=video_original.fps, # Mantener FPS original
|
142 |
threads=4,
|
143 |
+
ffmpeg_params=["-aspect", "16:9"], # Forzar relaci贸n de aspecto 16:9
|
144 |
verbose=False
|
145 |
)
|
146 |
eliminar_archivo_tiempo(tmp.name)
|