mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-13 18:47:36 +03:00
improve ffprobe error reporting
This commit is contained in:
parent
f388b4c45a
commit
33aae8c4e9
@ -199,19 +199,30 @@ def ffprobe(request: Request, paths: str = "", detailed: bool = False):
|
|||||||
request.app.frigate_config.ffmpeg, path.strip(), detailed=detailed
|
request.app.frigate_config.ffmpeg, path.strip(), detailed=detailed
|
||||||
)
|
)
|
||||||
|
|
||||||
result = {
|
if ffprobe.returncode != 0:
|
||||||
"return_code": ffprobe.returncode,
|
try:
|
||||||
"stderr": (
|
stderr_decoded = ffprobe.stderr.decode("utf-8")
|
||||||
ffprobe.stderr.decode("unicode_escape").strip()
|
except UnicodeDecodeError:
|
||||||
if ffprobe.returncode != 0
|
try:
|
||||||
else ""
|
stderr_decoded = ffprobe.stderr.decode("unicode_escape")
|
||||||
),
|
except Exception:
|
||||||
"stdout": (
|
stderr_decoded = str(ffprobe.stderr)
|
||||||
json.loads(ffprobe.stdout.decode("unicode_escape").strip())
|
|
||||||
if ffprobe.returncode == 0
|
stderr_lines = [
|
||||||
else ""
|
line.strip() for line in stderr_decoded.split("\n") if line.strip()
|
||||||
),
|
]
|
||||||
}
|
|
||||||
|
result = {
|
||||||
|
"return_code": ffprobe.returncode,
|
||||||
|
"stderr": stderr_lines,
|
||||||
|
"stdout": "",
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
result = {
|
||||||
|
"return_code": ffprobe.returncode,
|
||||||
|
"stderr": [],
|
||||||
|
"stdout": json.loads(ffprobe.stdout.decode("unicode_escape").strip()),
|
||||||
|
}
|
||||||
|
|
||||||
# Add detailed metadata if requested and probe was successful
|
# Add detailed metadata if requested and probe was successful
|
||||||
if detailed and ffprobe.returncode == 0 and result["stdout"]:
|
if detailed and ffprobe.returncode == 0 and result["stdout"]:
|
||||||
|
|||||||
@ -577,7 +577,7 @@ def ffprobe_stream(ffmpeg, path: str, detailed: bool = False) -> sp.CompletedPro
|
|||||||
if detailed and format_entries:
|
if detailed and format_entries:
|
||||||
ffprobe_cmd.extend(["-show_entries", f"format={format_entries}"])
|
ffprobe_cmd.extend(["-show_entries", f"format={format_entries}"])
|
||||||
|
|
||||||
ffprobe_cmd.extend(["-loglevel", "quiet", clean_path])
|
ffprobe_cmd.extend(["-loglevel", "error", clean_path])
|
||||||
|
|
||||||
return sp.run(ffprobe_cmd, capture_output=True)
|
return sp.run(ffprobe_cmd, capture_output=True)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user