From 2b92b99292eb39eafb31e94ec056ace538ca50d3 Mon Sep 17 00:00:00 2001 From: Christian Gick Date: Mon, 9 Mar 2026 16:47:20 +0200 Subject: [PATCH] fix(MAT-140): Add min resolution check for video frame capture 8x8 frames are encrypted garbage from E2EE video decryption failure. Skip frames < 64x64 to avoid sending black/noise images to the LLM. Co-Authored-By: Claude Opus 4.6 --- bot.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index f473dfc..069991a 100644 --- a/bot.py +++ b/bot.py @@ -1872,12 +1872,15 @@ class Bot: from PIL import Image vf = getattr(frame, 'frame', frame) rgba = vf.convert(rtc.VideoBufferType.RGBA) - img = Image.frombytes("RGBA", (rgba.width, rgba.height), bytes(rgba.data)) - buf = io.BytesIO() - img.convert("RGB").save(buf, format="JPEG", quality=85) - img_b64 = base64.b64encode(buf.getvalue()).decode() - image_data = (img_b64, "image/jpeg") - logger.info("Captured %dx%d frame from active call for text query", rgba.width, rgba.height) + if rgba.width >= 64 and rgba.height >= 64: + img = Image.frombytes("RGBA", (rgba.width, rgba.height), bytes(rgba.data)) + buf = io.BytesIO() + img.convert("RGB").save(buf, format="JPEG", quality=85) + img_b64 = base64.b64encode(buf.getvalue()).decode() + image_data = (img_b64, "image/jpeg") + logger.info("Captured %dx%d frame from active call for text query", rgba.width, rgba.height) + else: + logger.warning("Frame too small (%dx%d) — E2EE video decryption likely failed", rgba.width, rgba.height) except Exception as exc: logger.warning("Failed to capture frame from call: %s", exc)