From c670a2bdc889351b1c27af556245a56fe8e91cd8 Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Fri, 18 Oct 2024 07:03:27 -0700 Subject: [PATCH] fix(camera): don't use scale filter if angle is zero (#1485) scale filter seems to be expensive even with angle=0. On my CB1 having vf=rotate:0.0 in mpv arguments results in KlipperScreen using 100% of a single core vs 30% when it's omitted. --- panels/camera.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/panels/camera.py b/panels/camera.py index a305ebaa..216407fb 100644 --- a/panels/camera.py +++ b/panels/camera.py @@ -59,7 +59,12 @@ class Panel(ScreenPanel): vf += "hflip," if cam["flip_vertical"]: vf += "vflip," - vf += f"rotate:{cam['rotation'] * 3.14159 / 180}" + # Rotation filter is expensive. Omit it if angle is 0 + if cam["rotation"] != 0: + vf += f"rotate:{cam['rotation'] * 3.14159 / 180}" + # Remove trailing comma is there is any + if len(vf) > 0 and vf[-1] == ',': + vf = vf[:-1] logging.info(f"video filters: {vf}") if self.mpv: