Add error handling for ffprobe

This commit is contained in:
Esa Kataja
2025-04-17 13:19:22 +03:00
parent 404b61aa00
commit 65777071f4
+9
View File
@@ -59,7 +59,16 @@ def main(
"-show_streams",
filename,
]
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: