Update app.py
Browse files
app.py
CHANGED
|
@@ -110,7 +110,6 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
| 110 |
cortes_names = cortes_files.copy()
|
| 111 |
tutorials_salvos = tutoriais_files.copy()
|
| 112 |
musicas_salvas = musicas_files.copy()
|
| 113 |
-
|
| 114 |
for n in range(num_videos_finais):
|
| 115 |
total_etapas = 6
|
| 116 |
etapa_atual = 0
|
|
@@ -172,6 +171,7 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
| 172 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 173 |
etapa_atual += 1
|
| 174 |
atualizar_barra(n, etapa_atual, num_videos_finais, total_etapas)
|
|
|
|
| 175 |
# === Etapa 2 - Cortes ===
|
| 176 |
tentativas = 0
|
| 177 |
while tempo_total < duracao_final and tentativas < 100:
|
|
@@ -290,11 +290,11 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
| 290 |
etapa_atual += 1
|
| 291 |
atualizar_barra(n, etapa_atual, num_videos_finais, total_etapas)
|
| 292 |
|
| 293 |
-
# === Etapa 4 - VELOCIDADE (
|
| 294 |
video_com_velocidade = os.path.join(temp_dir, f"video_com_velocidade_{n}.mp4")
|
| 295 |
subprocess.run([
|
| 296 |
"ffmpeg", "-y", "-i", video_editado, "-an",
|
| 297 |
-
"-filter:v", f"setpts=PTS/{velocidade_final_n}",
|
| 298 |
"-c:v", "libx264", "-preset", "ultrafast", "-crf", str(crf_value),
|
| 299 |
video_com_velocidade
|
| 300 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
@@ -308,13 +308,12 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
| 308 |
"-c:v", "libx264", "-preset", "ultrafast", "-crf", str(crf_value),
|
| 309 |
"-y", tutorial_mp4
|
| 310 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 311 |
-
|
| 312 |
dur_proc = subprocess.run([
|
| 313 |
"ffprobe", "-v", "error", "-show_entries", "format=duration",
|
| 314 |
"-of", "default=noprint_wrappers=1:nokey=1", video_com_velocidade
|
| 315 |
], stdout=subprocess.PIPE)
|
| 316 |
dur_f = float(dur_proc.stdout.decode().strip() or 0)
|
| 317 |
-
pt = dur_f / 2 if dur_f < 10 else random.uniform(5, dur_f - 5)
|
| 318 |
|
| 319 |
part1 = os.path.join(temp_dir, f"part1_{n}.mp4")
|
| 320 |
part2 = os.path.join(temp_dir, f"part2_{n}.mp4")
|
|
|
|
| 110 |
cortes_names = cortes_files.copy()
|
| 111 |
tutorials_salvos = tutoriais_files.copy()
|
| 112 |
musicas_salvas = musicas_files.copy()
|
|
|
|
| 113 |
for n in range(num_videos_finais):
|
| 114 |
total_etapas = 6
|
| 115 |
etapa_atual = 0
|
|
|
|
| 171 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 172 |
etapa_atual += 1
|
| 173 |
atualizar_barra(n, etapa_atual, num_videos_finais, total_etapas)
|
| 174 |
+
|
| 175 |
# === Etapa 2 - Cortes ===
|
| 176 |
tentativas = 0
|
| 177 |
while tempo_total < duracao_final and tentativas < 100:
|
|
|
|
| 290 |
etapa_atual += 1
|
| 291 |
atualizar_barra(n, etapa_atual, num_videos_finais, total_etapas)
|
| 292 |
|
| 293 |
+
# === Etapa 4 - VELOCIDADE (corrigido) ===
|
| 294 |
video_com_velocidade = os.path.join(temp_dir, f"video_com_velocidade_{n}.mp4")
|
| 295 |
subprocess.run([
|
| 296 |
"ffmpeg", "-y", "-i", video_editado, "-an",
|
| 297 |
+
"-filter:v", f"setpts=PTS/{velocidade_final_n},fps=30",
|
| 298 |
"-c:v", "libx264", "-preset", "ultrafast", "-crf", str(crf_value),
|
| 299 |
video_com_velocidade
|
| 300 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
|
|
| 308 |
"-c:v", "libx264", "-preset", "ultrafast", "-crf", str(crf_value),
|
| 309 |
"-y", tutorial_mp4
|
| 310 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
|
|
| 311 |
dur_proc = subprocess.run([
|
| 312 |
"ffprobe", "-v", "error", "-show_entries", "format=duration",
|
| 313 |
"-of", "default=noprint_wrappers=1:nokey=1", video_com_velocidade
|
| 314 |
], stdout=subprocess.PIPE)
|
| 315 |
dur_f = float(dur_proc.stdout.decode().strip() or 0)
|
| 316 |
+
pt = dur_f / 2 if dur_f < 10 else random.uniform(5, max(6, dur_f - 5))
|
| 317 |
|
| 318 |
part1 = os.path.join(temp_dir, f"part1_{n}.mp4")
|
| 319 |
part2 = os.path.join(temp_dir, f"part2_{n}.mp4")
|