Spaces:
Running
Running
Tu Nombre commited on
Commit 路
d4cb333
1
Parent(s): 4705133
reglas tecnicas: max 58s, bitrate 1500k, planos max 4s
Browse files- cliente_template.py +12 -5
cliente_template.py
CHANGED
|
@@ -138,9 +138,14 @@ async def pipeline():
|
|
| 138 |
voz = AC("voz.mp3")
|
| 139 |
if TIPO_VIDEO == "short":
|
| 140 |
clips_lista = []
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
try:
|
| 145 |
es_img = fp.lower().endswith((".jpg",".jpeg",".png",".webp"))
|
| 146 |
if es_img:
|
|
@@ -172,7 +177,9 @@ async def pipeline():
|
|
| 172 |
log(f"Error clip {fp}: {e_c}")
|
| 173 |
log(f"Clips OK: {len(clips_lista)}/{len(fondos)}")
|
| 174 |
clip = concatenate_videoclips(clips_lista, method="compose")
|
| 175 |
-
|
|
|
|
|
|
|
| 176 |
else:
|
| 177 |
clips_lista = []
|
| 178 |
for fp in fondos:
|
|
@@ -193,7 +200,7 @@ async def pipeline():
|
|
| 193 |
size=(clip.w*0.8,None)).set_start(i*t_f).set_duration(t_f).set_pos(("center", {"arriba":0.15,"centro":0.5,"abajo":0.75}.get(CONFIG.get("posicion_subtitulos","abajo"),0.75)), relative=True)
|
| 194 |
for i,t in enumerate(frases)]
|
| 195 |
final = CompositeVideoClip([clip]+txts).set_audio(voz)
|
| 196 |
-
final.write_videofile("out.mp4", fps=30, codec="libx264", preset="
|
| 197 |
log("Video renderizado")
|
| 198 |
STATUS = "Esperando conexi贸n YouTube..."
|
| 199 |
while not os.path.exists("token.json"):
|
|
|
|
| 138 |
voz = AC("voz.mp3")
|
| 139 |
if TIPO_VIDEO == "short":
|
| 140 |
clips_lista = []
|
| 141 |
+
dur_total_real = min(voz.duration, 58)
|
| 142 |
+
# Cada plano max 4s, calcular cuantos planos necesitamos
|
| 143 |
+
num_planos = max(int(dur_total_real / 4) + 1, len(fondos))
|
| 144 |
+
# Repetir fondos si hace falta
|
| 145 |
+
fondos_loop = (fondos * ((num_planos // len(fondos)) + 1))[:num_planos]
|
| 146 |
+
dur_clip = dur_total_real / num_planos
|
| 147 |
+
log(f"Planos: {num_planos}, dur_clip: {dur_clip:.1f}s")
|
| 148 |
+
for fp in fondos_loop:
|
| 149 |
try:
|
| 150 |
es_img = fp.lower().endswith((".jpg",".jpeg",".png",".webp"))
|
| 151 |
if es_img:
|
|
|
|
| 177 |
log(f"Error clip {fp}: {e_c}")
|
| 178 |
log(f"Clips OK: {len(clips_lista)}/{len(fondos)}")
|
| 179 |
clip = concatenate_videoclips(clips_lista, method="compose")
|
| 180 |
+
dur_final = min(voz.duration, 58)
|
| 181 |
+
clip = clip.subclip(0, dur_final)
|
| 182 |
+
voz = voz.subclip(0, dur_final)
|
| 183 |
else:
|
| 184 |
clips_lista = []
|
| 185 |
for fp in fondos:
|
|
|
|
| 200 |
size=(clip.w*0.8,None)).set_start(i*t_f).set_duration(t_f).set_pos(("center", {"arriba":0.15,"centro":0.5,"abajo":0.75}.get(CONFIG.get("posicion_subtitulos","abajo"),0.75)), relative=True)
|
| 201 |
for i,t in enumerate(frases)]
|
| 202 |
final = CompositeVideoClip([clip]+txts).set_audio(voz)
|
| 203 |
+
final.write_videofile("out.mp4", fps=30, codec="libx264", bitrate="1500k", preset="medium", logger=None, threads=2, audio_codec="aac", audio_bitrate="128k")
|
| 204 |
log("Video renderizado")
|
| 205 |
STATUS = "Esperando conexi贸n YouTube..."
|
| 206 |
while not os.path.exists("token.json"):
|