Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -51,6 +51,9 @@ def resize_video(clip, target_width=1920, target_height=1080):
|
|
51 |
if abs(current_aspect_ratio - target_aspect_ratio) < 0.1:
|
52 |
return clip.resize((target_width, target_height))
|
53 |
|
|
|
|
|
|
|
54 |
# Redimensionar el video original para mantener su proporci贸n
|
55 |
if current_aspect_ratio < target_aspect_ratio: # Video vertical
|
56 |
new_height = target_height
|
@@ -63,8 +66,7 @@ def resize_video(clip, target_width=1920, target_height=1080):
|
|
63 |
y_center = (target_height - new_height) / 2
|
64 |
resized_clip = clip.resize(height=new_height).set_position((0, y_center))
|
65 |
|
66 |
-
#
|
67 |
-
background = ColorClip(size=(target_width, target_height), color=[0, 0, 0]).set_duration(clip.duration)
|
68 |
return CompositeVideoClip([background, resized_clip], size=(target_width, target_height))
|
69 |
except Exception as e:
|
70 |
print(f"Error en resize_video: {e}")
|
|
|
51 |
if abs(current_aspect_ratio - target_aspect_ratio) < 0.1:
|
52 |
return clip.resize((target_width, target_height))
|
53 |
|
54 |
+
# Crear un fondo negro con las dimensiones objetivo
|
55 |
+
background = ColorClip(size=(target_width, target_height), color=[0, 0, 0]).set_duration(clip.duration)
|
56 |
+
|
57 |
# Redimensionar el video original para mantener su proporci贸n
|
58 |
if current_aspect_ratio < target_aspect_ratio: # Video vertical
|
59 |
new_height = target_height
|
|
|
66 |
y_center = (target_height - new_height) / 2
|
67 |
resized_clip = clip.resize(height=new_height).set_position((0, y_center))
|
68 |
|
69 |
+
# Combinar el fondo negro con el video redimensionado
|
|
|
70 |
return CompositeVideoClip([background, resized_clip], size=(target_width, target_height))
|
71 |
except Exception as e:
|
72 |
print(f"Error en resize_video: {e}")
|