Update app.py
Browse files
app.py
CHANGED
@@ -54,9 +54,6 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
54 |
duracao_corte_min = st.slider("Duração mínima (s)", 1, 10, 3)
|
55 |
duracao_corte_max = st.slider("Duração máxima (s)", duracao_corte_min + 1, 20, 5)
|
56 |
|
57 |
-
# 🔥 Nova opção: posição do corte
|
58 |
-
posicao_corte = st.selectbox("Posição do corte", ["Centro", "Esquerda", "Direita"])
|
59 |
-
|
60 |
zoom = st.slider("Zoom", 1.0, 2.0, 1.0, 0.1)
|
61 |
blur_strength = st.slider("Blur no fundo", 1, 50, 10)
|
62 |
velocidade_final = st.slider("Velocidade final", 0.5, 2.0, 1.0, 0.1)
|
@@ -197,23 +194,11 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
197 |
if repetido:
|
198 |
continue
|
199 |
out = os.path.join(temp_dir, f"cut_{random.randint(1000,9999)}.mp4")
|
200 |
-
|
201 |
-
# 🔥 Define filtro de crop conforme posição escolhida
|
202 |
-
if posicao_corte == "Centro":
|
203 |
-
crop_filter = "crop=720:1280:(in_w-720)/2:(in_h-1280)/2"
|
204 |
-
elif posicao_corte == "Esquerda":
|
205 |
-
crop_filter = "crop=720:1280:0:(in_h-1280)/2"
|
206 |
-
elif posicao_corte == "Direita":
|
207 |
-
crop_filter = "crop=720:1280:(in_w-720):(in_h-1280)/2"
|
208 |
-
else:
|
209 |
-
crop_filter = "scale=trunc(iw/2)*2:trunc(ih/2)*2"
|
210 |
-
|
211 |
subprocess.run([
|
212 |
"ffmpeg", "-ss", str(ini), "-i", c, "-t", str(duracao_aleatoria),
|
213 |
-
"-vf",
|
214 |
"-an", "-c:v", "libx264", "-preset", "ultrafast", "-crf", "30", out
|
215 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
216 |
-
|
217 |
cortes_prontos.append(out)
|
218 |
cortes_usados.append((c, ini, duracao_aleatoria))
|
219 |
tempo_total += duracao_aleatoria
|
@@ -234,6 +219,7 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
234 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
235 |
etapa_atual += 1
|
236 |
atualizar_barra(n, etapa_atual, num_videos_finais, total_etapas)
|
|
|
237 |
# === Etapa 3 - Filtros ===
|
238 |
filtros_main = ["scale=720:1280:force_original_aspect_ratio=decrease"]
|
239 |
if zoom_n != 1.0:
|
@@ -322,7 +308,6 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
322 |
"-c:v", "libx264", "-preset", "ultrafast", "-crf", str(crf_value),
|
323 |
"-y", tutorial_mp4
|
324 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
325 |
-
|
326 |
dur_proc = subprocess.run([
|
327 |
"ffprobe", "-v", "error", "-show_entries", "format=duration",
|
328 |
"-of", "default=noprint_wrappers=1:nokey=1", video_com_velocidade
|
@@ -350,6 +335,7 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
350 |
video_final_raw], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
351 |
else:
|
352 |
video_final_raw = video_com_velocidade
|
|
|
353 |
# === Etapa 6 - Música e saída final ===
|
354 |
dur_final_str = subprocess.run([
|
355 |
"ffprobe", "-v", "error", "-show_entries", "format=duration",
|
|
|
54 |
duracao_corte_min = st.slider("Duração mínima (s)", 1, 10, 3)
|
55 |
duracao_corte_max = st.slider("Duração máxima (s)", duracao_corte_min + 1, 20, 5)
|
56 |
|
|
|
|
|
|
|
57 |
zoom = st.slider("Zoom", 1.0, 2.0, 1.0, 0.1)
|
58 |
blur_strength = st.slider("Blur no fundo", 1, 50, 10)
|
59 |
velocidade_final = st.slider("Velocidade final", 0.5, 2.0, 1.0, 0.1)
|
|
|
194 |
if repetido:
|
195 |
continue
|
196 |
out = os.path.join(temp_dir, f"cut_{random.randint(1000,9999)}.mp4")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
subprocess.run([
|
198 |
"ffmpeg", "-ss", str(ini), "-i", c, "-t", str(duracao_aleatoria),
|
199 |
+
"-vf", "scale=trunc(iw/2)*2:trunc(ih/2)*2",
|
200 |
"-an", "-c:v", "libx264", "-preset", "ultrafast", "-crf", "30", out
|
201 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
|
202 |
cortes_prontos.append(out)
|
203 |
cortes_usados.append((c, ini, duracao_aleatoria))
|
204 |
tempo_total += duracao_aleatoria
|
|
|
219 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
220 |
etapa_atual += 1
|
221 |
atualizar_barra(n, etapa_atual, num_videos_finais, total_etapas)
|
222 |
+
|
223 |
# === Etapa 3 - Filtros ===
|
224 |
filtros_main = ["scale=720:1280:force_original_aspect_ratio=decrease"]
|
225 |
if zoom_n != 1.0:
|
|
|
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
|
|
|
335 |
video_final_raw], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
336 |
else:
|
337 |
video_final_raw = video_com_velocidade
|
338 |
+
|
339 |
# === Etapa 6 - Música e saída final ===
|
340 |
dur_final_str = subprocess.run([
|
341 |
"ffprobe", "-v", "error", "-show_entries", "format=duration",
|