Tim13ekd commited on
Commit
77921b4
·
verified ·
1 Parent(s): d593d36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -7,17 +7,11 @@ import uuid
7
 
8
  allowed_medias = [".png", ".jpg", ".jpeg", ".bmp", ".gif", ".tiff"]
9
 
10
- def get_files_infos(files):
11
- """Gibt einfache Dateiinformationen zurück"""
12
- results = []
13
- for file in files:
14
- file_path = Path(file.name)
15
- info = {"name": file_path.name.replace(" ", "_"), "size": file_path.stat().st_size}
16
- results.append(info)
17
- return results
18
-
19
  def execute_ffmpeg_image_to_video(image_file):
20
  """Konvertiert ein Bild in ein 5-Sekunden-Video"""
 
 
 
21
  temp_dir = tempfile.mkdtemp()
22
  file_path = Path(image_file.name)
23
  sanitized_name = file_path.name.replace(" ", "_")
@@ -30,18 +24,18 @@ def execute_ffmpeg_image_to_video(image_file):
30
  "ffmpeg",
31
  "-y",
32
  "-loop", "1",
 
33
  "-i", str(dest_path),
34
  "-t", "5",
35
- "-c:v", "mpeg4", # funktioniert im HF-Container besser als libx264
36
  "-pix_fmt", "yuv420p",
37
  str(output_file)
38
  ]
39
 
40
- # FFmpeg ausführen
41
  try:
42
  subprocess.run(cmd, check=True, text=True, capture_output=True)
43
  except subprocess.CalledProcessError as e:
44
- return f"❌ FFmpeg Fehler:\n{e.stderr}", None
45
 
46
  return str(output_file), "✅ Video erfolgreich erstellt"
47
 
 
7
 
8
  allowed_medias = [".png", ".jpg", ".jpeg", ".bmp", ".gif", ".tiff"]
9
 
 
 
 
 
 
 
 
 
 
10
  def execute_ffmpeg_image_to_video(image_file):
11
  """Konvertiert ein Bild in ein 5-Sekunden-Video"""
12
+ if image_file is None:
13
+ return None, "❌ Keine Datei ausgewählt"
14
+
15
  temp_dir = tempfile.mkdtemp()
16
  file_path = Path(image_file.name)
17
  sanitized_name = file_path.name.replace(" ", "_")
 
24
  "ffmpeg",
25
  "-y",
26
  "-loop", "1",
27
+ "-framerate", "25",
28
  "-i", str(dest_path),
29
  "-t", "5",
30
+ "-c:v", "mpeg4",
31
  "-pix_fmt", "yuv420p",
32
  str(output_file)
33
  ]
34
 
 
35
  try:
36
  subprocess.run(cmd, check=True, text=True, capture_output=True)
37
  except subprocess.CalledProcessError as e:
38
+ return None, f"❌ FFmpeg Fehler:\n{e.stderr}"
39
 
40
  return str(output_file), "✅ Video erfolgreich erstellt"
41