From 87e28107259487512dee5494097145da9790f2ea Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Sun, 4 Dec 2022 12:46:03 -0300 Subject: [PATCH] Do not apply -user_agent for rtmp streams (#4596) --- docs/docs/configuration/index.md | 2 +- frigate/config.py | 8 +------- frigate/ffmpeg_presets.py | 26 ++++++++++++++++++++------ frigate/test/test_ffmpeg_presets.py | 5 +++-- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index 501f198f6..c35950da2 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -142,7 +142,7 @@ birdseye: # Optional: ffmpeg configuration ffmpeg: # Optional: global ffmpeg args (default: shown below) - global_args: -hide_banner -loglevel warning -user_agent "FFmpeg Frigate" + global_args: -hide_banner -loglevel warning # Optional: global hwaccel args (default: shown below) # NOTE: See hardware acceleration docs for your specific device hwaccel_args: [] diff --git a/frigate/config.py b/frigate/config.py index 2e19a526f..3e31b1fcb 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -359,13 +359,7 @@ class BirdseyeCameraConfig(BaseModel): ) -FFMPEG_GLOBAL_ARGS_DEFAULT = [ - "-hide_banner", - "-loglevel", - "warning", - "-user_agent", - f"FFmpeg Frigate/{VERSION}", -] +FFMPEG_GLOBAL_ARGS_DEFAULT = ["-hide_banner", "-loglevel", "warning"] FFMPEG_INPUT_ARGS_DEFAULT = [ "-avoid_negative_ts", "make_zero", diff --git a/frigate/ffmpeg_presets.py b/frigate/ffmpeg_presets.py index 3e7f0ef54..af6d86337 100644 --- a/frigate/ffmpeg_presets.py +++ b/frigate/ffmpeg_presets.py @@ -2,6 +2,12 @@ from typing import Any +from frigate.version import VERSION + +_user_agent_args = [ + "-user_agent", + f"FFmpeg Frigate/{VERSION}", +] PRESETS_HW_ACCEL = { "preset-rpi-32-h264": ["-c:v", "h264_v4l2m2m"], @@ -39,7 +45,8 @@ def parse_preset_hardware_acceleration(arg: Any) -> list[str]: PRESETS_INPUT = { - "preset-http-jpeg-generic": [ + "preset-http-jpeg-generic": _user_agent_args + + [ "-r", "{}", "-stream_loop", @@ -59,7 +66,8 @@ PRESETS_INPUT = { "-use_wallclock_as_timestamps", "1", ], - "preset-http-mjpeg-generic": [ + "preset-http-mjpeg-generic": _user_agent_args + + [ "-avoid_negative_ts", "make_zero", "-fflags", @@ -73,7 +81,8 @@ PRESETS_INPUT = { "-use_wallclock_as_timestamps", "1", ], - "preset-http-reolink": [ + "preset-http-reolink": _user_agent_args + + [ "-avoid_negative_ts", "make_zero", "-fflags", @@ -107,7 +116,8 @@ PRESETS_INPUT = { "-f", "live_flv", ], - "preset-rtsp-generic": [ + "preset-rtsp-generic": _user_agent_args + + [ "-avoid_negative_ts", "make_zero", "-fflags", @@ -119,7 +129,8 @@ PRESETS_INPUT = { "-use_wallclock_as_timestamps", "1", ], - "preset-rtsp-udp": [ + "preset-rtsp-udp": _user_agent_args + + [ "-avoid_negative_ts", "make_zero", "-fflags", @@ -131,7 +142,10 @@ PRESETS_INPUT = { "-use_wallclock_as_timestamps", "1", ], - "preset-rtsp-blue-iris": [ + "preset-rtsp-blue-iris": _user_agent_args + + [ + "-user_agent", + f"FFmpeg Frigate/{VERSION}", "-avoid_negative_ts", "make_zero", "-flags", diff --git a/frigate/test/test_ffmpeg_presets.py b/frigate/test/test_ffmpeg_presets.py index 4ace9c496..e08af44a9 100644 --- a/frigate/test/test_ffmpeg_presets.py +++ b/frigate/test/test_ffmpeg_presets.py @@ -76,8 +76,9 @@ class TestFfmpegPresets(unittest.TestCase): frigate_config.cameras["back"].create_ffmpeg_cmds() frigate_preset_config.cameras["back"].create_ffmpeg_cmds() assert ( - frigate_preset_config.cameras["back"].ffmpeg_cmds[0]["cmd"] - == frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"] + # Ignore global and user_agent args in comparison + frigate_preset_config.cameras["back"].ffmpeg_cmds[0]["cmd"][6::] + == frigate_config.cameras["back"].ffmpeg_cmds[0]["cmd"][4::] ) def test_ffmpeg_input_preset(self):