Update app.py
Browse files
app.py
CHANGED
|
@@ -21,6 +21,8 @@ for cat in CATEGORIAS:
|
|
| 21 |
os.makedirs(os.path.join(BASE_ASSETS, cat, "cortes"), exist_ok=True)
|
| 22 |
os.makedirs(os.path.join(BASE_ASSETS, cat, "tutoriais"), exist_ok=True)
|
| 23 |
os.makedirs(os.path.join(BASE_SALVOS, cat), exist_ok=True)
|
|
|
|
|
|
|
| 24 |
if pagina == "🎬 Gerador de Vídeo":
|
| 25 |
st.title("🎥 TikTok Video Generator - PRO")
|
| 26 |
|
|
@@ -79,7 +81,26 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
| 79 |
with st.expander("🎨 Filtros Avançados"):
|
| 80 |
ativar_brilho = st.checkbox("Brilho extra")
|
| 81 |
ativar_contraste = st.checkbox("Contraste forte")
|
| 82 |
-
ativar_colorboost = st.checkbox("Cores
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
if st.button("Gerar Vídeo(s)", key="gerar_video_usuario"):
|
| 84 |
with st.spinner("🎬 Processando..."):
|
| 85 |
progresso = st.progress(0)
|
|
@@ -100,6 +121,7 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
| 100 |
cortes_prontos = []
|
| 101 |
cortes_usados = []
|
| 102 |
|
|
|
|
| 103 |
if aleatorizar:
|
| 104 |
duracao_corte_min_n = random.randint(1, 5)
|
| 105 |
duracao_corte_max_n = random.randint(duracao_corte_min_n + 1, 8)
|
|
@@ -203,6 +225,64 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
| 203 |
atualizar_barra(n, etapa_atual, num_videos_finais, total_etapas)
|
| 204 |
|
| 205 |
# ======================== ETAPA 3 - Filtros e Efeitos ========================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
video_editado = os.path.join(temp_dir, f"video_editado_{n}.mp4")
|
| 207 |
subprocess.run([
|
| 208 |
"ffmpeg", "-i", fundo_convertido, "-i", video_raw,
|
|
@@ -223,6 +303,7 @@ if pagina == "🎬 Gerador de Vídeo":
|
|
| 223 |
"-c:v", "libx264", "-preset", "veryfast", "-crf", "18",
|
| 224 |
video_editado_speed
|
| 225 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
|
|
| 226 |
# ======================== ETAPA 4 - Tutorial ========================
|
| 227 |
if usar_tutorial and tutorials_salvos:
|
| 228 |
tutorial_path = random.choice(tutorials_salvos)
|
|
@@ -341,6 +422,7 @@ elif pagina == "📂 Gerenciador de Arquivos":
|
|
| 341 |
os.remove(file_path)
|
| 342 |
st.success(f"❌ Arquivo '{file}' excluído.")
|
| 343 |
st.rerun()
|
|
|
|
| 344 |
# ======================== ADMIN ========================
|
| 345 |
elif pagina == "🔐 Admin":
|
| 346 |
st.title("🔐 Área de Administração")
|
|
|
|
| 21 |
os.makedirs(os.path.join(BASE_ASSETS, cat, "cortes"), exist_ok=True)
|
| 22 |
os.makedirs(os.path.join(BASE_ASSETS, cat, "tutoriais"), exist_ok=True)
|
| 23 |
os.makedirs(os.path.join(BASE_SALVOS, cat), exist_ok=True)
|
| 24 |
+
|
| 25 |
+
# ======================== GERADOR DE VÍDEO ========================
|
| 26 |
if pagina == "🎬 Gerador de Vídeo":
|
| 27 |
st.title("🎥 TikTok Video Generator - PRO")
|
| 28 |
|
|
|
|
| 81 |
with st.expander("🎨 Filtros Avançados"):
|
| 82 |
ativar_brilho = st.checkbox("Brilho extra")
|
| 83 |
ativar_contraste = st.checkbox("Contraste forte")
|
| 84 |
+
ativar_colorboost = st.checkbox("Cores intensas")
|
| 85 |
+
ativar_azul = st.checkbox("Filtro Azul")
|
| 86 |
+
ativar_quente = st.checkbox("Filtro Quente")
|
| 87 |
+
ativar_desaturar = st.checkbox("Desaturar")
|
| 88 |
+
ativar_vhs = st.checkbox("Efeito VHS")
|
| 89 |
+
|
| 90 |
+
st.write("## Outros efeitos")
|
| 91 |
+
ativar_espelhar = st.checkbox("Espelhar", True)
|
| 92 |
+
ativar_filtro_cor = st.checkbox("Ajuste de cor", True)
|
| 93 |
+
remover_borda = st.checkbox("Remover borda")
|
| 94 |
+
tamanho_borda = st.slider("Tamanho da borda (px)", 0, 200, 0, 5)
|
| 95 |
+
|
| 96 |
+
ativar_borda_personalizada = st.checkbox("Borda personalizada")
|
| 97 |
+
if ativar_borda_personalizada:
|
| 98 |
+
cor_borda = st.color_picker("Cor da borda", "#FF0000")
|
| 99 |
+
animacao_borda = st.selectbox("Animação", ["Nenhuma", "Pulsante", "Cor Animada", "Neon", "Ondulada"])
|
| 100 |
+
|
| 101 |
+
salvar_no_gerenciador = st.checkbox("Salvar no gerenciador de arquivos")
|
| 102 |
+
|
| 103 |
+
# ======================== GERAÇÃO DOS VÍDEOS ========================
|
| 104 |
if st.button("Gerar Vídeo(s)", key="gerar_video_usuario"):
|
| 105 |
with st.spinner("🎬 Processando..."):
|
| 106 |
progresso = st.progress(0)
|
|
|
|
| 121 |
cortes_prontos = []
|
| 122 |
cortes_usados = []
|
| 123 |
|
| 124 |
+
# configs aleatórias ou fixas
|
| 125 |
if aleatorizar:
|
| 126 |
duracao_corte_min_n = random.randint(1, 5)
|
| 127 |
duracao_corte_max_n = random.randint(duracao_corte_min_n + 1, 8)
|
|
|
|
| 225 |
atualizar_barra(n, etapa_atual, num_videos_finais, total_etapas)
|
| 226 |
|
| 227 |
# ======================== ETAPA 3 - Filtros e Efeitos ========================
|
| 228 |
+
filtros_main = ["scale=720:1280:force_original_aspect_ratio=decrease"]
|
| 229 |
+
if zoom_n != 1.0:
|
| 230 |
+
filtros_main.append(f"scale=iw*{zoom_n}:ih*{zoom_n}")
|
| 231 |
+
if ativar_espelhar_n:
|
| 232 |
+
filtros_main.append("hflip")
|
| 233 |
+
if remover_borda_n and tamanho_borda_n > 0:
|
| 234 |
+
filtros_main.append(f"crop=in_w-{tamanho_borda_n*2}:in_h-{tamanho_borda_n*2}")
|
| 235 |
+
if ativar_filtro_cor:
|
| 236 |
+
filtros_main.append("eq=contrast=1.1:saturation=1.2")
|
| 237 |
+
filtros_main.append("scale=trunc(iw/2)*2:trunc(ih/2)*2")
|
| 238 |
+
if ativar_borda_personalizada:
|
| 239 |
+
cor_ffmpeg = f"0x{cor_borda.lstrip('#')}FF"
|
| 240 |
+
filtros_main.append(f"drawbox=x=0:y=0:w=iw:h=ih:color={cor_ffmpeg}:t=5")
|
| 241 |
+
|
| 242 |
+
filtro_complex = f"[0:v]scale=720:1280:force_original_aspect_ratio=increase,crop=720:1280"
|
| 243 |
+
if ativar_blur_fundo_n:
|
| 244 |
+
filtro_complex += f",boxblur={blur_strength_n}:1"
|
| 245 |
+
if ativar_sepia:
|
| 246 |
+
filtro_complex += ",colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131"
|
| 247 |
+
if ativar_granulado:
|
| 248 |
+
filtro_complex += ",noise=alls=20:allf=t+u"
|
| 249 |
+
if ativar_pb:
|
| 250 |
+
filtro_complex += ",hue=s=0.3"
|
| 251 |
+
if ativar_vignette:
|
| 252 |
+
filtro_complex += ",vignette"
|
| 253 |
+
if ativar_brilho:
|
| 254 |
+
filtro_complex += ",eq=brightness=0.05"
|
| 255 |
+
if ativar_contraste:
|
| 256 |
+
filtro_complex += ",eq=contrast=1.3"
|
| 257 |
+
if ativar_colorboost:
|
| 258 |
+
filtro_complex += ",eq=saturation=1.5"
|
| 259 |
+
if ativar_azul:
|
| 260 |
+
filtro_complex += ",colorbalance=bs=0.5"
|
| 261 |
+
if ativar_quente:
|
| 262 |
+
filtro_complex += ",colorbalance=rs=0.3"
|
| 263 |
+
if ativar_desaturar:
|
| 264 |
+
filtro_complex += ",hue=s=0.5"
|
| 265 |
+
if ativar_vhs:
|
| 266 |
+
filtro_complex += ",noise=alls=10:allf=t+u,format=yuv420p"
|
| 267 |
+
|
| 268 |
+
filtro_complex += "[blur];"
|
| 269 |
+
filtro_complex += f"[1:v]{','.join(filtros_main)}[zoomed];"
|
| 270 |
+
filtro_complex += "[blur][zoomed]overlay=(W-w)/2:(H-h)/2[base]"
|
| 271 |
+
|
| 272 |
+
if ativar_texto and texto_personalizado.strip():
|
| 273 |
+
y_pos = "100" if posicao_texto == "Topo" else "(h-text_h)/2" if posicao_texto == "Centro" else "h-text_h-100"
|
| 274 |
+
enable = f":enable='lt(t\\,{segundos_texto})'" if duracao_texto == "Apenas primeiros segundos" else ""
|
| 275 |
+
texto_clean = texto_personalizado.replace(":", "\\:").replace("'", "\\'")
|
| 276 |
+
filtro_complex += f";[base]drawtext=text='{texto_clean}':"
|
| 277 |
+
filtro_complex += (
|
| 278 |
+
f"fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:"
|
| 279 |
+
f"fontcolor={cor_texto}:fontsize={tamanho_texto}:"
|
| 280 |
+
f"shadowcolor={cor_sombra}:shadowx=3:shadowy=3:"
|
| 281 |
+
f"x=(w-text_w)/2:y={y_pos}{enable}[final]"
|
| 282 |
+
)
|
| 283 |
+
else:
|
| 284 |
+
filtro_complex += ";[base]null[final]"
|
| 285 |
+
|
| 286 |
video_editado = os.path.join(temp_dir, f"video_editado_{n}.mp4")
|
| 287 |
subprocess.run([
|
| 288 |
"ffmpeg", "-i", fundo_convertido, "-i", video_raw,
|
|
|
|
| 303 |
"-c:v", "libx264", "-preset", "veryfast", "-crf", "18",
|
| 304 |
video_editado_speed
|
| 305 |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 306 |
+
|
| 307 |
# ======================== ETAPA 4 - Tutorial ========================
|
| 308 |
if usar_tutorial and tutorials_salvos:
|
| 309 |
tutorial_path = random.choice(tutorials_salvos)
|
|
|
|
| 422 |
os.remove(file_path)
|
| 423 |
st.success(f"❌ Arquivo '{file}' excluído.")
|
| 424 |
st.rerun()
|
| 425 |
+
|
| 426 |
# ======================== ADMIN ========================
|
| 427 |
elif pagina == "🔐 Admin":
|
| 428 |
st.title("🔐 Área de Administração")
|