Update api/ltx_server.py
Browse files- api/ltx_server.py +14 -10
api/ltx_server.py
CHANGED
|
@@ -416,7 +416,7 @@ class VideoService:
|
|
| 416 |
if num_latente_por_chunk >= sum_latent:
|
| 417 |
return [latents_brutos.clone()]
|
| 418 |
|
| 419 |
-
steps = (sum_latent
|
| 420 |
print("================PODA CAUSAL=================")
|
| 421 |
print(f"[DEBUG] TOTAL LATENTES = {sum_latent}")
|
| 422 |
print(f"[DEBUG] Num LATENTES por chunk = {num_latente_por_chunk}")
|
|
@@ -425,10 +425,12 @@ class VideoService:
|
|
| 425 |
for i in range(steps):
|
| 426 |
start = i * num_latente_por_chunk
|
| 427 |
end = start + num_latente_por_chunk
|
| 428 |
-
if i > 0:
|
| 429 |
-
|
| 430 |
-
if end
|
| 431 |
end = sum_latent
|
|
|
|
|
|
|
| 432 |
chunk = latents_brutos[:, :, start:end, :, :].clone()
|
| 433 |
chunks.append(chunk)
|
| 434 |
print(f"[DEBUG] chunk{i+1}[:, :, {start}:{end}, :, :] = {chunk.shape[2]}")
|
|
@@ -463,7 +465,9 @@ class VideoService:
|
|
| 463 |
video_fade_fim = None
|
| 464 |
video_fade_ini = None
|
| 465 |
nova_lista = []
|
| 466 |
-
|
|
|
|
|
|
|
| 467 |
print(f"[DEBUG] Iniciando pipeline com {total_partes} vídeos e {poda} frames de crossfade")
|
| 468 |
|
| 469 |
for i in range(total_partes):
|
|
@@ -504,13 +508,14 @@ class VideoService:
|
|
| 504 |
|
| 505 |
# --- TRANSIÇÃO ---
|
| 506 |
if video_fade_fim and video_fade_ini:
|
| 507 |
-
video_fade = os.path.join(pasta, f"transicao_{i
|
| 508 |
cmd_blend = (
|
| 509 |
f'ffmpeg -y -hide_banner -loglevel error '
|
| 510 |
f'-i "{video_fade_fim}" -i "{video_fade_ini}" '
|
| 511 |
f'-filter_complex "[0:v][1:v]blend=all_expr=\'A*(1-T/{poda})+B*(T/{poda})\',format=yuv420p" '
|
| 512 |
f'-frames:v {poda} "{video_fade}"'
|
| 513 |
)
|
|
|
|
| 514 |
subprocess.run(cmd_blend, shell=True, check=True)
|
| 515 |
nova_lista.append(video_fade)
|
| 516 |
|
|
@@ -525,13 +530,12 @@ class VideoService:
|
|
| 525 |
subprocess.run(cmd_fim, shell=True, check=True)
|
| 526 |
|
| 527 |
nova_lista.append(video_podado)
|
| 528 |
-
|
|
|
|
| 529 |
|
| 530 |
|
| 531 |
-
|
| 532 |
-
print(f"[DEBUG] Nova lista finalizada com {len(nova_lista)} partes.")
|
| 533 |
print(f"[DEBUG] {nova_lista}")
|
| 534 |
-
|
| 535 |
return nova_lista
|
| 536 |
|
| 537 |
def _concat_mp4s_no_reencode(self, mp4_list: List[str], out_path: str):
|
|
|
|
| 416 |
if num_latente_por_chunk >= sum_latent:
|
| 417 |
return [latents_brutos.clone()]
|
| 418 |
|
| 419 |
+
steps = (sum_latent -2 ) // num_latente_por_chunk
|
| 420 |
print("================PODA CAUSAL=================")
|
| 421 |
print(f"[DEBUG] TOTAL LATENTES = {sum_latent}")
|
| 422 |
print(f"[DEBUG] Num LATENTES por chunk = {num_latente_por_chunk}")
|
|
|
|
| 425 |
for i in range(steps):
|
| 426 |
start = i * num_latente_por_chunk
|
| 427 |
end = start + num_latente_por_chunk
|
| 428 |
+
#if i > 0:
|
| 429 |
+
# start = overlap # sobreposição
|
| 430 |
+
if end >= sum_latent:
|
| 431 |
end = sum_latent
|
| 432 |
+
else:
|
| 433 |
+
end = overlap
|
| 434 |
chunk = latents_brutos[:, :, start:end, :, :].clone()
|
| 435 |
chunks.append(chunk)
|
| 436 |
print(f"[DEBUG] chunk{i+1}[:, :, {start}:{end}, :, :] = {chunk.shape[2]}")
|
|
|
|
| 465 |
video_fade_fim = None
|
| 466 |
video_fade_ini = None
|
| 467 |
nova_lista = []
|
| 468 |
+
|
| 469 |
+
print("===========CONCATECAO CAUSAL=============")
|
| 470 |
+
|
| 471 |
print(f"[DEBUG] Iniciando pipeline com {total_partes} vídeos e {poda} frames de crossfade")
|
| 472 |
|
| 473 |
for i in range(total_partes):
|
|
|
|
| 508 |
|
| 509 |
# --- TRANSIÇÃO ---
|
| 510 |
if video_fade_fim and video_fade_ini:
|
| 511 |
+
video_fade = os.path.join(pasta, f"transicao_{i}_{i+1}.mp4")
|
| 512 |
cmd_blend = (
|
| 513 |
f'ffmpeg -y -hide_banner -loglevel error '
|
| 514 |
f'-i "{video_fade_fim}" -i "{video_fade_ini}" '
|
| 515 |
f'-filter_complex "[0:v][1:v]blend=all_expr=\'A*(1-T/{poda})+B*(T/{poda})\',format=yuv420p" '
|
| 516 |
f'-frames:v {poda} "{video_fade}"'
|
| 517 |
)
|
| 518 |
+
print(f"[DEBUG] transicao adicionada {i}/{i+1} {self._get_total_frames(video_fade)} frames ")
|
| 519 |
subprocess.run(cmd_blend, shell=True, check=True)
|
| 520 |
nova_lista.append(video_fade)
|
| 521 |
|
|
|
|
| 530 |
subprocess.run(cmd_fim, shell=True, check=True)
|
| 531 |
|
| 532 |
nova_lista.append(video_podado)
|
| 533 |
+
print(f"[DEBUG] Video podado {i+1} adicionado {self._get_total_frames(video_podado)} frames ")
|
| 534 |
+
|
| 535 |
|
| 536 |
|
| 537 |
+
print("===========CONCATECAO CAUSAL=============")
|
|
|
|
| 538 |
print(f"[DEBUG] {nova_lista}")
|
|
|
|
| 539 |
return nova_lista
|
| 540 |
|
| 541 |
def _concat_mp4s_no_reencode(self, mp4_list: List[str], out_path: str):
|