From 8a97c3c7c274382324ced83853d6ba0a260cee09 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Mon, 6 Apr 2026 12:08:42 +0200 Subject: [PATCH] fix: ffmpeg command type hint, -ss comment, FileNotFoundError handler --- main.py | 6 +++++- tests/test_utils.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index eaf5ade..4122e3e 100644 --- a/main.py +++ b/main.py @@ -16,7 +16,9 @@ def format_time(seconds: float) -> str: return f"{m}:{s:04.1f}" -def build_ffmpeg_command(input_path: str, start: float, output_path: str) -> list: +def build_ffmpeg_command(input_path: str, start: float, output_path: str) -> list[str]: + # -ss before -i: fast input-seeking. Safe here because we always re-encode + # (libx264/aac), so there is no keyframe-alignment issue from pre-input seek. return [ "ffmpeg", "-y", "-ss", str(start), @@ -46,6 +48,8 @@ class ExportWorker(QThread): self.finished.emit(self._output) else: self.error.emit(result.stderr[-500:]) + except FileNotFoundError: + self.error.emit("ffmpeg not found — is it installed and on PATH?") except Exception as e: self.error.emit(str(e)) diff --git a/tests/test_utils.py b/tests/test_utils.py index 3a62349..4ad872e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -26,6 +26,7 @@ def test_format_time_no_sixty_rollover(): def test_ffmpeg_command(): cmd = build_ffmpeg_command("/in/video.mp4", 12.5, "/out/clip_001.mp4") assert cmd[0] == "ffmpeg" + assert "-y" in cmd assert "-ss" in cmd assert str(12.5) in cmd assert "-t" in cmd