omarbajouk commited on
Commit
f0ab94e
·
verified ·
1 Parent(s): ca0e393

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -9,6 +9,15 @@ from typing import Optional
9
  import gradio as gr
10
  from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageOps
11
 
 
 
 
 
 
 
 
 
 
12
  # ---------- Config statique ----------
13
  ROOT = os.getcwd()
14
  OUT_DIR = os.path.join(ROOT, "export")
@@ -312,7 +321,6 @@ def make_background(titre, sous_titre, texte_ecran, theme, logo_path, logo_pos,
312
  # ============================================================
313
  # SUPPRESSION DE LA PARTIE SADTALKER (plus nécessaire)
314
  # ============================================================
315
-
316
  def _prepare_video_presentateur(video_path, audio_duration, position, plein_ecran=False):
317
  """Prépare la vidéo du présentateur avec la bonne durée et position."""
318
  from moviepy.editor import VideoFileClip
@@ -335,12 +343,15 @@ def _prepare_video_presentateur(video_path, audio_duration, position, plein_ecra
335
  print(f"[Video] Découpage nécessaire ({v.duration}s -> {audio_duration}s)")
336
  v = v.subclip(0, audio_duration)
337
 
338
- # Ajuster la taille et la position
339
  if plein_ecran:
340
  print(f"[Video] Mode plein écran")
341
- v = v.resize((W, H)).set_position(("center", "center"))
 
 
342
  else:
343
  print(f"[Video] Mode incrustation, position: {position}")
 
344
  v = v.resize(width=520)
345
  pos_map = {
346
  "bottom-right": ("right", "bottom"),
 
9
  import gradio as gr
10
  from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageOps
11
 
12
+ # ============================================================
13
+ # PATCH MOVIEPY - Correction ANTIALIAS
14
+ # ============================================================
15
+
16
+ import PIL.Image
17
+ # Remplacer ANTIALIAS par LANCZOS (nouveau nom dans Pillow >= 10.0.0)
18
+ if not hasattr(PIL.Image, 'ANTIALIAS'):
19
+ PIL.Image.ANTIALIAS = PIL.Image.LANCZOS
20
+
21
  # ---------- Config statique ----------
22
  ROOT = os.getcwd()
23
  OUT_DIR = os.path.join(ROOT, "export")
 
321
  # ============================================================
322
  # SUPPRESSION DE LA PARTIE SADTALKER (plus nécessaire)
323
  # ============================================================
 
324
  def _prepare_video_presentateur(video_path, audio_duration, position, plein_ecran=False):
325
  """Prépare la vidéo du présentateur avec la bonne durée et position."""
326
  from moviepy.editor import VideoFileClip
 
343
  print(f"[Video] Découpage nécessaire ({v.duration}s -> {audio_duration}s)")
344
  v = v.subclip(0, audio_duration)
345
 
346
+ # Ajuster la taille et la position - AVEC RESIZE SÉCURISÉ
347
  if plein_ecran:
348
  print(f"[Video] Mode plein écran")
349
+ # Utiliser resize avec méthode moderne
350
+ v = v.resize(newsize=(W, H))
351
+ v = v.set_position(("center", "center"))
352
  else:
353
  print(f"[Video] Mode incrustation, position: {position}")
354
+ # Redimensionner avec méthode moderne
355
  v = v.resize(width=520)
356
  pos_map = {
357
  "bottom-right": ("right", "bottom"),