From 7208d7e81084425455121d1295c603d55f9f305a Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 18 Nov 2026 15:30:09 -0600 Subject: [PATCH] fix stream checks missing non-aac audio The ffprobe API never asked ffprobe for codec_type, so the stream checks could only spot audio and video by codec name. G.711, Opus, and other non-AAC audio showed as no audio, and H.265 detect streams showed an unknown resolution. ffprobe_stream now requests codec_type, and the stream check matches tracks on it alone. --- frigate/test/http_api/test_http_ffprobe.py | 18 +++++++++++++++++- frigate/util/services.py | 2 +- web/src/utils/streamIssues.ts | 14 ++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/frigate/test/http_api/test_http_ffprobe.py b/frigate/test/http_api/test_http_ffprobe.py index 5038c07c85..4d537452df 100644 --- a/frigate/test/http_api/test_http_ffprobe.py +++ b/frigate/test/http_api/test_http_ffprobe.py @@ -1,11 +1,13 @@ -"""Tests for credential scrubbing in the ffprobe API.""" +"""Tests for the ffprobe API.""" +import unittest from types import SimpleNamespace from unittest.mock import patch from fastapi.testclient import TestClient from frigate.test.http_api.base_http_test import AuthTestClient, BaseTestHttp +from frigate.util.services import ffprobe_stream class TestHttpFfprobe(BaseTestHttp): @@ -35,3 +37,17 @@ class TestHttpFfprobe(BaseTestHttp): self.assertEqual(len(lines), 2) self.assertNotIn("hunter2", " ".join(lines)) self.assertEqual(lines[1], "rtsp://*:*@10.0.0.1:554/video: Connection refused") + + +class TestFfprobeStream(unittest.TestCase): + def test_requests_codec_type(self): + ffmpeg = SimpleNamespace(ffprobe_path="ffprobe") + done = SimpleNamespace(returncode=0, stdout=b"{}", stderr=b"") + + for detailed in (False, True): + with patch("frigate.util.services.sp.run", return_value=done) as run: + ffprobe_stream(ffmpeg, "rtsp://10.0.0.1/live", detailed=detailed) + + cmd = run.call_args.args[0] + entries = cmd[cmd.index("-show_entries") + 1] + self.assertIn("codec_type", entries.removeprefix("stream=").split(",")) diff --git a/frigate/util/services.py b/frigate/util/services.py index dcb0a5b289..03eb61782d 100644 --- a/frigate/util/services.py +++ b/frigate/util/services.py @@ -1365,7 +1365,7 @@ def ffprobe_stream(ffmpeg, path: str, detailed: bool = False) -> sp.CompletedPro clean_path = escape_special_characters(path) # Base entries that are always included - stream_entries = "codec_long_name,width,height,bit_rate,duration,display_aspect_ratio,avg_frame_rate" + stream_entries = "codec_type,codec_long_name,width,height,bit_rate,duration,display_aspect_ratio,avg_frame_rate" # Additional detailed entries if detailed: diff --git a/web/src/utils/streamIssues.ts b/web/src/utils/streamIssues.ts index f763cc9c6d..2d05849d76 100644 --- a/web/src/utils/streamIssues.ts +++ b/web/src/utils/streamIssues.ts @@ -57,18 +57,8 @@ export function ffprobeToTestResult( } const streams = entry.stdout?.streams ?? []; - const videoStream = streams.find( - (s) => - s.codec_type === "video" || - s.codec_name?.includes("h264") || - s.codec_name?.includes("h265"), - ); - const audioStream = streams.find( - (s) => - s.codec_type === "audio" || - s.codec_name?.includes("aac") || - s.codec_name?.includes("mp3"), - ); + const videoStream = streams.find((s) => s.codec_type === "video"); + const audioStream = streams.find((s) => s.codec_type === "audio"); const resolution = videoStream ? `${videoStream.width}x${videoStream.height}`