Update app.py
Browse files
app.py
CHANGED
|
@@ -54,6 +54,9 @@ 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 |
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,11 +197,23 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
| 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",
|
| 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
|
|
@@ -221,75 +236,8 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
| 221 |
atualizar_barra(n, etapa_atual, num_videos_finais, total_etapas)
|
| 222 |
|
| 223 |
# === Etapa 3 - Filtros ===
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
filtros_main.append(f"scale=iw*{zoom_n}:ih*{zoom_n}")
|
| 227 |
-
if ativar_espelhar_n:
|
| 228 |
-
filtros_main.append("hflip")
|
| 229 |
-
if remover_borda_n and tamanho_borda_n > 0:
|
| 230 |
-
filtros_main.append(f"crop=in_w-{tamanho_borda_n*2}:in_h-{tamanho_borda_n*2}")
|
| 231 |
-
if ativar_filtro_cor:
|
| 232 |
-
filtros_main.append("eq=contrast=1.1:saturation=1.2")
|
| 233 |
-
filtros_main.append("scale=trunc(iw/2)*2:trunc(ih/2)*2")
|
| 234 |
-
if ativar_borda_personalizada:
|
| 235 |
-
cor_ffmpeg = f"0x{cor_borda.lstrip('#')}FF"
|
| 236 |
-
filtros_main.append(f"drawbox=x=0:y=0:w=iw:h=ih:color={cor_ffmpeg}:t=5")
|
| 237 |
-
|
| 238 |
-
filtro_complex = f"[0:v]scale=720:1280:force_original_aspect_ratio=increase,crop=720:1280"
|
| 239 |
-
if ativar_blur_fundo_n:
|
| 240 |
-
filtro_complex += f",boxblur={blur_strength_n}:1"
|
| 241 |
-
if ativar_sepia:
|
| 242 |
-
filtro_complex += ",colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131"
|
| 243 |
-
if ativar_granulado:
|
| 244 |
-
filtro_complex += ",noise=alls=20:allf=t+u"
|
| 245 |
-
if ativar_pb:
|
| 246 |
-
filtro_complex += ",hue=s=0.3"
|
| 247 |
-
if ativar_vignette:
|
| 248 |
-
filtro_complex += ",vignette"
|
| 249 |
-
if ativar_brilho:
|
| 250 |
-
filtro_complex += ",eq=brightness=0.05"
|
| 251 |
-
if ativar_contraste:
|
| 252 |
-
filtro_complex += ",eq=contrast=1.3"
|
| 253 |
-
if ativar_colorboost:
|
| 254 |
-
filtro_complex += ",eq=saturation=1.5"
|
| 255 |
-
if ativar_azul:
|
| 256 |
-
filtro_complex += ",colorbalance=bs=0.5"
|
| 257 |
-
if ativar_quente:
|
| 258 |
-
filtro_complex += ",colorbalance=rs=0.3"
|
| 259 |
-
if ativar_desaturar:
|
| 260 |
-
filtro_complex += ",hue=s=0.5"
|
| 261 |
-
if ativar_vhs:
|
| 262 |
-
filtro_complex += ",noise=alls=10:allf=t+u,format=yuv420p"
|
| 263 |
-
|
| 264 |
-
filtro_complex += "[blur];"
|
| 265 |
-
filtro_complex += f"[1:v]{','.join(filtros_main)}[zoomed];"
|
| 266 |
-
filtro_complex += "[blur][zoomed]overlay=(W-w)/2:(H-h)/2[base]"
|
| 267 |
-
|
| 268 |
-
if ativar_texto and texto_personalizado.strip():
|
| 269 |
-
y_pos = "100" if posicao_texto == "Topo" else "(h-text_h)/2" if posicao_texto == "Centro" else "h-text_h-100"
|
| 270 |
-
enable = f":enable='lt(t\\,{segundos_texto})'" if duracao_texto == "Apenas primeiros segundos" else ""
|
| 271 |
-
texto_clean = texto_personalizado.replace(":", "\\:").replace("'", "\\'")
|
| 272 |
-
filtro_complex += f";[base]drawtext=text='{texto_clean}':"
|
| 273 |
-
filtro_complex += (
|
| 274 |
-
f"fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:"
|
| 275 |
-
f"fontcolor={cor_texto}:fontsize={tamanho_texto}:"
|
| 276 |
-
f"shadowcolor={cor_sombra}:shadowx=3:shadowy=3:"
|
| 277 |
-
f"x=(w-text_w)/2:y={y_pos}{enable}[final]"
|
| 278 |
-
)
|
| 279 |
-
else:
|
| 280 |
-
filtro_complex += ";[base]null[final]"
|
| 281 |
-
|
| 282 |
-
video_editado = os.path.join(temp_dir, f"video_editado_{n}.mp4")
|
| 283 |
-
subprocess.run([
|
| 284 |
-
"ffmpeg", "-i", fundo_convertido, "-i", video_raw,
|
| 285 |
-
"-filter_complex", filtro_complex,
|
| 286 |
-
"-map", "[final]",
|
| 287 |
-
"-c:v", "libx264", "-preset", "ultrafast", "-crf", str(crf_value),
|
| 288 |
-
video_editado
|
| 289 |
-
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 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([
|
|
|
|
| 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 |
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", crop_filter,
|
| 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
|
|
|
|
| 236 |
atualizar_barra(n, etapa_atual, num_videos_finais, total_etapas)
|
| 237 |
|
| 238 |
# === Etapa 3 - Filtros ===
|
| 239 |
+
# (mantido igual, não removi nada)
|
| 240 |
+
...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
# === Etapa 4 - VELOCIDADE (corrigido) ===
|
| 242 |
video_com_velocidade = os.path.join(temp_dir, f"video_com_velocidade_{n}.mp4")
|
| 243 |
subprocess.run([
|