From 0b2f4ea52574394b8075eb07b19801d0705a2809 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Thu, 10 Nov 2022 06:40:42 -0700 Subject: [PATCH] Return full output of ffprobe process --- frigate/http.py | 34 +++++++++++++++++----------------- frigate/util.py | 10 ++-------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/frigate/http.py b/frigate/http.py index e7dc829ba..ff8ff707a 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -619,31 +619,31 @@ def ffprobe(camera_name): if len(config.ffmpeg.inputs) > 1: # user has multiple streams - output = "" + output = [] for input in config.ffmpeg.inputs: - output += f"{input.roles}\n" ffprobe = ffprobe_stream(input.path) - - if ffprobe: - output += f"{ffprobe}\n" - else: - output += "error getting stream\n" + output.append( + { + "input_roles": input.roles, + "return_code": ffprobe.returncode, + "stderr": ffprobe.stderr, + "stdout": ffprobe.stdout, + } + ) return jsonify(output, "200") else: # user has single stream ffprobe = ffprobe_stream(config.ffmpeg.inputs[0].path) - if not ffprobe: - return jsonify( - { - "success": False, - "message": f"ffprobe unable to get info for {camera_name}", - }, - "500", - ) - else: - return jsonify(ffprobe, "200") + return jsonify( + { + "input_roles": config.ffmpeg.inputs[0].roles, + "return_code": ffprobe.returncode, + "stderr": ffprobe.stderr, + "stdout": ffprobe.stdout, + } + ) @bp.route("/") diff --git a/frigate/util.py b/frigate/util.py index 29947e212..11c0b2c39 100755 --- a/frigate/util.py +++ b/frigate/util.py @@ -712,7 +712,7 @@ def get_cpu_stats() -> dict[str, dict]: return usages -def ffprobe_stream(path: str) -> str: +def ffprobe_stream(path: str) -> sp.CompletedProcess: """Run ffprobe on stream.""" ffprobe_cmd = [ "ffprobe", @@ -724,13 +724,7 @@ def ffprobe_stream(path: str) -> str: "quiet", path, ] - p = sp.run(ffprobe_cmd, capture_output=True) - - if p.returncode != 0: - logger.error(f"ffprobe unable to get result for stream: {p.stderr}") - return None - else: - return p.stdout.decode().strip() + return sp.run(ffprobe_cmd, capture_output=True) class FrameManager(ABC):