fix: bundle FFmpeg offline, fix NoneType write crash in windowed apps, fallback to system PATH
This commit is contained in:
@@ -16,14 +16,36 @@ import static_ffmpeg
|
||||
from .metadata import apply_id3_tags
|
||||
|
||||
|
||||
import sys
|
||||
import io
|
||||
import shutil
|
||||
|
||||
def _ensure_ffmpeg() -> tuple[str, str]:
|
||||
"""Stellt sicher, dass ffmpeg und ffprobe verfügbar sind.
|
||||
|
||||
Returns:
|
||||
(ffmpeg_path, ffprobe_path)
|
||||
"""
|
||||
ffmpeg_path, ffprobe_path = static_ffmpeg.run.get_or_fetch_platform_executables_else_raise()
|
||||
return ffmpeg_path, ffprobe_path
|
||||
# 1. Behebe NoneType 'write' Fehler, wenn App im windowed-Modus gestartet wurde
|
||||
if sys.stdout is None:
|
||||
sys.stdout = io.StringIO()
|
||||
if sys.stderr is None:
|
||||
sys.stderr = io.StringIO()
|
||||
|
||||
# 2. Versuch 1: static_ffmpeg (jetzt direkt in der App gebündelt)
|
||||
try:
|
||||
ffmpeg_path, ffprobe_path = static_ffmpeg.run.get_or_fetch_platform_executables_else_raise()
|
||||
return ffmpeg_path, ffprobe_path
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 3. Versuch 2: System-FFmpeg (z.B. über winget, apt, brew) als Fallback
|
||||
sys_ffmpeg = shutil.which("ffmpeg")
|
||||
sys_ffprobe = shutil.which("ffprobe")
|
||||
if sys_ffmpeg and sys_ffprobe:
|
||||
return sys_ffmpeg, sys_ffprobe
|
||||
|
||||
raise RuntimeError("FFmpeg konnte weder im Bundle noch im System gefunden werden.")
|
||||
|
||||
|
||||
def get_duration(file_path: Path, ffprobe_path: str) -> float:
|
||||
|
||||
Reference in New Issue
Block a user