From 65777071f4fcb95c33057615eeda654f2d4886c5 Mon Sep 17 00:00:00 2001 From: Esa Kataja Date: Thu, 17 Apr 2025 13:19:22 +0300 Subject: [PATCH] Add error handling for ffprobe --- src/app.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app.py b/src/app.py index 1c02d89..d5d9e95 100644 --- a/src/app.py +++ b/src/app.py @@ -59,7 +59,16 @@ def main( "-show_streams", filename, ] - result = subprocess.run(cmd, capture_output=True, check=True) + try: + result = subprocess.run(cmd, capture_output=True, check=True) + except FileNotFoundError: + typer.secho("Error: ffprobe not found. Please install FFmpeg.", fg="red", err=True) + raise typer.Exit(code=1) + except subprocess.CalledProcessError as e: + typer.secho("Error: ffprobe failed to probe the file.", fg="red", err=True) + error_output = e.stderr.decode() if e.stderr else str(e) + typer.secho(error_output, fg="red", err=True) + raise typer.Exit(code=1) data = parse_streams(json.loads(result.stdout), video_details) data.original_media_type = original_media_type for stream in data.video_streams: