fix: ffmpeg command type hint, -ss comment, FileNotFoundError handler
This commit is contained in:
@@ -16,7 +16,9 @@ def format_time(seconds: float) -> str:
|
|||||||
return f"{m}:{s:04.1f}"
|
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 [
|
return [
|
||||||
"ffmpeg", "-y",
|
"ffmpeg", "-y",
|
||||||
"-ss", str(start),
|
"-ss", str(start),
|
||||||
@@ -46,6 +48,8 @@ class ExportWorker(QThread):
|
|||||||
self.finished.emit(self._output)
|
self.finished.emit(self._output)
|
||||||
else:
|
else:
|
||||||
self.error.emit(result.stderr[-500:])
|
self.error.emit(result.stderr[-500:])
|
||||||
|
except FileNotFoundError:
|
||||||
|
self.error.emit("ffmpeg not found — is it installed and on PATH?")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.error.emit(str(e))
|
self.error.emit(str(e))
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ def test_format_time_no_sixty_rollover():
|
|||||||
def test_ffmpeg_command():
|
def test_ffmpeg_command():
|
||||||
cmd = build_ffmpeg_command("/in/video.mp4", 12.5, "/out/clip_001.mp4")
|
cmd = build_ffmpeg_command("/in/video.mp4", 12.5, "/out/clip_001.mp4")
|
||||||
assert cmd[0] == "ffmpeg"
|
assert cmd[0] == "ffmpeg"
|
||||||
|
assert "-y" in cmd
|
||||||
assert "-ss" in cmd
|
assert "-ss" in cmd
|
||||||
assert str(12.5) in cmd
|
assert str(12.5) in cmd
|
||||||
assert "-t" in cmd
|
assert "-t" in cmd
|
||||||
|
|||||||
Reference in New Issue
Block a user