pcdoido2 commited on
Commit
1df1826
·
verified ·
1 Parent(s): 59b5c46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -4
app.py CHANGED
@@ -234,10 +234,76 @@ 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
-
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([
@@ -256,6 +322,7 @@ if pagina == "🎬 Gerador de Vídeo":
256
  "-c:v", "libx264", "-preset", "ultrafast", "-crf", str(crf_value),
257
  "-y", tutorial_mp4
258
  ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
 
259
  dur_proc = subprocess.run([
260
  "ffprobe", "-v", "error", "-show_entries", "format=duration",
261
  "-of", "default=noprint_wrappers=1:nokey=1", video_com_velocidade
@@ -283,7 +350,6 @@ if pagina == "🎬 Gerador de Vídeo":
283
  video_final_raw], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
284
  else:
285
  video_final_raw = video_com_velocidade
286
-
287
  # === Etapa 6 - Música e saída final ===
288
  dur_final_str = subprocess.run([
289
  "ffprobe", "-v", "error", "-show_entries", "format=duration",
 
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:
240
+ filtros_main.append(f"scale=iw*{zoom_n}:ih*{zoom_n}")
241
+ if ativar_espelhar_n:
242
+ filtros_main.append("hflip")
243
+ if remover_borda_n and tamanho_borda_n > 0:
244
+ filtros_main.append(f"crop=in_w-{tamanho_borda_n*2}:in_h-{tamanho_borda_n*2}")
245
+ if ativar_filtro_cor:
246
+ filtros_main.append("eq=contrast=1.1:saturation=1.2")
247
+ filtros_main.append("scale=trunc(iw/2)*2:trunc(ih/2)*2")
248
+ if ativar_borda_personalizada:
249
+ cor_ffmpeg = f"0x{cor_borda.lstrip('#')}FF"
250
+ filtros_main.append(f"drawbox=x=0:y=0:w=iw:h=ih:color={cor_ffmpeg}:t=5")
251
+
252
+ filtro_complex = f"[0:v]scale=720:1280:force_original_aspect_ratio=increase,crop=720:1280"
253
+ if ativar_blur_fundo_n:
254
+ filtro_complex += f",boxblur={blur_strength_n}:1"
255
+ if ativar_sepia:
256
+ filtro_complex += ",colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131"
257
+ if ativar_granulado:
258
+ filtro_complex += ",noise=alls=20:allf=t+u"
259
+ if ativar_pb:
260
+ filtro_complex += ",hue=s=0.3"
261
+ if ativar_vignette:
262
+ filtro_complex += ",vignette"
263
+ if ativar_brilho:
264
+ filtro_complex += ",eq=brightness=0.05"
265
+ if ativar_contraste:
266
+ filtro_complex += ",eq=contrast=1.3"
267
+ if ativar_colorboost:
268
+ filtro_complex += ",eq=saturation=1.5"
269
+ if ativar_azul:
270
+ filtro_complex += ",colorbalance=bs=0.5"
271
+ if ativar_quente:
272
+ filtro_complex += ",colorbalance=rs=0.3"
273
+ if ativar_desaturar:
274
+ filtro_complex += ",hue=s=0.5"
275
+ if ativar_vhs:
276
+ filtro_complex += ",noise=alls=10:allf=t+u,format=yuv420p"
277
+
278
+ filtro_complex += "[blur];"
279
+ filtro_complex += f"[1:v]{','.join(filtros_main)}[zoomed];"
280
+ filtro_complex += "[blur][zoomed]overlay=(W-w)/2:(H-h)/2[base]"
281
+
282
+ if ativar_texto and texto_personalizado.strip():
283
+ y_pos = "100" if posicao_texto == "Topo" else "(h-text_h)/2" if posicao_texto == "Centro" else "h-text_h-100"
284
+ enable = f":enable='lt(t\\,{segundos_texto})'" if duracao_texto == "Apenas primeiros segundos" else ""
285
+ texto_clean = texto_personalizado.replace(":", "\\:").replace("'", "\\'")
286
+ filtro_complex += f";[base]drawtext=text='{texto_clean}':"
287
+ filtro_complex += (
288
+ f"fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:"
289
+ f"fontcolor={cor_texto}:fontsize={tamanho_texto}:"
290
+ f"shadowcolor={cor_sombra}:shadowx=3:shadowy=3:"
291
+ f"x=(w-text_w)/2:y={y_pos}{enable}[final]"
292
+ )
293
+ else:
294
+ filtro_complex += ";[base]null[final]"
295
+
296
+ video_editado = os.path.join(temp_dir, f"video_editado_{n}.mp4")
297
+ subprocess.run([
298
+ "ffmpeg", "-i", fundo_convertido, "-i", video_raw,
299
+ "-filter_complex", filtro_complex,
300
+ "-map", "[final]",
301
+ "-c:v", "libx264", "-preset", "ultrafast", "-crf", str(crf_value),
302
+ video_editado
303
+ ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
304
+ etapa_atual += 1
305
+ atualizar_barra(n, etapa_atual, num_videos_finais, total_etapas)
306
+
307
  # === Etapa 4 - VELOCIDADE (corrigido) ===
308
  video_com_velocidade = os.path.join(temp_dir, f"video_com_velocidade_{n}.mp4")
309
  subprocess.run([
 
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
  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",