Add error handling for ffprobe
This commit is contained in:
+10
-1
@@ -59,7 +59,16 @@ def main(
|
|||||||
"-show_streams",
|
"-show_streams",
|
||||||
filename,
|
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 = parse_streams(json.loads(result.stdout), video_details)
|
||||||
data.original_media_type = original_media_type
|
data.original_media_type = original_media_type
|
||||||
for stream in data.video_streams:
|
for stream in data.video_streams:
|
||||||
|
|||||||
Reference in New Issue
Block a user