Tim13ekd commited on
Commit
ea75fd0
·
verified ·
1 Parent(s): 1b78077

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -14,7 +14,7 @@ def generate_slideshow(images, duration):
14
  filelist_path = Path(temp_dir) / "filelist.txt"
15
  output_file = Path(temp_dir) / f"slideshow_{uuid.uuid4().hex}.mp4"
16
 
17
- # Einzelne Bilder als temporäre Videos erstellen
18
  clips = []
19
  for i, img_path in enumerate(images):
20
  clip_path = Path(temp_dir) / f"clip_{i}.mp4"
@@ -30,19 +30,20 @@ def generate_slideshow(images, duration):
30
  subprocess.run(cmd, check=True)
31
  clips.append(clip_path)
32
 
33
- # Filelist für concat
34
  with open(filelist_path, "w") as f:
35
  for clip in clips:
36
  f.write(f"file '{clip}'\n")
37
 
38
- # Clips zusammenfügen
39
  cmd_concat = [
40
  "ffmpeg",
41
  "-y",
42
  "-f", "concat",
43
  "-safe", "0",
44
  "-i", str(filelist_path),
45
- "-c", "copy",
 
46
  str(output_file)
47
  ]
48
  subprocess.run(cmd_concat, check=True)
@@ -54,7 +55,7 @@ def generate_slideshow(images, duration):
54
 
55
  # Gradio UI
56
  with gr.Blocks() as demo:
57
- gr.Markdown("# Stabile Slideshow Generator (HF-kompatibel)")
58
 
59
  img_input = gr.Files(label="Bilder auswählen (mehrere)", file_types=allowed_medias)
60
  duration_input = gr.Number(value=3, label="Dauer pro Bild in Sekunden", precision=1)
 
14
  filelist_path = Path(temp_dir) / "filelist.txt"
15
  output_file = Path(temp_dir) / f"slideshow_{uuid.uuid4().hex}.mp4"
16
 
17
+ # Einzelne Bilder in Clips umwandeln
18
  clips = []
19
  for i, img_path in enumerate(images):
20
  clip_path = Path(temp_dir) / f"clip_{i}.mp4"
 
30
  subprocess.run(cmd, check=True)
31
  clips.append(clip_path)
32
 
33
+ # Filelist erstellen
34
  with open(filelist_path, "w") as f:
35
  for clip in clips:
36
  f.write(f"file '{clip}'\n")
37
 
38
+ # Clips zusammenfügen und neu kodieren
39
  cmd_concat = [
40
  "ffmpeg",
41
  "-y",
42
  "-f", "concat",
43
  "-safe", "0",
44
  "-i", str(filelist_path),
45
+ "-c:v", "libx264",
46
+ "-pix_fmt", "yuv420p",
47
  str(output_file)
48
  ]
49
  subprocess.run(cmd_concat, check=True)
 
55
 
56
  # Gradio UI
57
  with gr.Blocks() as demo:
58
+ gr.Markdown("# Stabile Slideshow Generator (funktioniert jetzt korrekt)")
59
 
60
  img_input = gr.Files(label="Bilder auswählen (mehrere)", file_types=allowed_medias)
61
  duration_input = gr.Number(value=3, label="Dauer pro Bild in Sekunden", precision=1)