Spaces:
Sleeping
Sleeping
Cristobal commited on
Commit ·
c227bbf
1
Parent(s): e10934b
simplificar lectura video como Teshua - quitar has_mask
Browse files
app.py
CHANGED
|
@@ -109,15 +109,10 @@ def montar_video(guion, archivos, subs=None, efecto="ninguno"):
|
|
| 109 |
ic = ic.set_duration(dur_clip)
|
| 110 |
clips.append(ic)
|
| 111 |
else:
|
| 112 |
-
vclip = VC(fp
|
| 113 |
-
# Recortar a la duracion del plano (no loop, evita corrupcion)
|
| 114 |
-
if vclip.duration >= dur_clip:
|
| 115 |
-
vclip = vclip.subclip(0, dur_clip)
|
| 116 |
-
else:
|
| 117 |
-
vclip = vclip.loop(duration=dur_clip)
|
| 118 |
vclip = vclip.resize(height=1920) if vclip.w/vclip.h > 1080/1920 else vclip.resize(width=1080)
|
| 119 |
vclip = vclip.crop(x_center=vclip.w/2, y_center=vclip.h/2, width=1080, height=1920)
|
| 120 |
-
vclip = vclip.
|
| 121 |
clips.append(vclip)
|
| 122 |
except Exception as e:
|
| 123 |
log(f"Error clip {fp}: {e}")
|
|
@@ -206,24 +201,9 @@ async def ep_material(file: UploadFile = File(...)):
|
|
| 206 |
import subprocess as _sp
|
| 207 |
ext = file.filename.split(".")[-1].lower()
|
| 208 |
idx = len(ESTADO['archivos'])
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
with open(crudo,"wb") as f:
|
| 213 |
-
f.write(await file.read())
|
| 214 |
-
nombre = f"media_{idx}.mp4"
|
| 215 |
-
r = _sp.run(["ffmpeg","-y","-i",crudo,"-vf","scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,format=yuv420p","-colorspace","bt709","-color_primaries","bt709","-color_trc","bt709","-c:v","libx264","-preset","ultrafast","-pix_fmt","yuv420p","-an",nombre], capture_output=True)
|
| 216 |
-
import os as _os
|
| 217 |
-
if not (_os.path.exists(nombre) and _os.path.getsize(nombre) > 1000):
|
| 218 |
-
# Si falla la conversion, usar el crudo
|
| 219 |
-
nombre = crudo
|
| 220 |
-
else:
|
| 221 |
-
try: _os.remove(crudo)
|
| 222 |
-
except: pass
|
| 223 |
-
else:
|
| 224 |
-
nombre = f"media_{idx}.{ext}"
|
| 225 |
-
with open(nombre,"wb") as f:
|
| 226 |
-
f.write(await file.read())
|
| 227 |
ESTADO["archivos"].append(nombre)
|
| 228 |
return {"ok": True, "total": len(ESTADO["archivos"]), "nombre": nombre}
|
| 229 |
except Exception as e:
|
|
|
|
| 109 |
ic = ic.set_duration(dur_clip)
|
| 110 |
clips.append(ic)
|
| 111 |
else:
|
| 112 |
+
vclip = VC(fp).without_audio()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
vclip = vclip.resize(height=1920) if vclip.w/vclip.h > 1080/1920 else vclip.resize(width=1080)
|
| 114 |
vclip = vclip.crop(x_center=vclip.w/2, y_center=vclip.h/2, width=1080, height=1920)
|
| 115 |
+
vclip = vclip.loop(duration=dur_clip).set_duration(dur_clip)
|
| 116 |
clips.append(vclip)
|
| 117 |
except Exception as e:
|
| 118 |
log(f"Error clip {fp}: {e}")
|
|
|
|
| 201 |
import subprocess as _sp
|
| 202 |
ext = file.filename.split(".")[-1].lower()
|
| 203 |
idx = len(ESTADO['archivos'])
|
| 204 |
+
nombre = f"media_{idx}.{ext}"
|
| 205 |
+
with open(nombre,"wb") as f:
|
| 206 |
+
f.write(await file.read())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
ESTADO["archivos"].append(nombre)
|
| 208 |
return {"ok": True, "total": len(ESTADO["archivos"]), "nombre": nombre}
|
| 209 |
except Exception as e:
|