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 <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-03-09 16:47:20 +02:00
parent 4a37f7e9ef
commit 2b92b99292

3
bot.py
View File

@@ -1872,12 +1872,15 @@ class Bot:
from PIL import Image from PIL import Image
vf = getattr(frame, 'frame', frame) vf = getattr(frame, 'frame', frame)
rgba = vf.convert(rtc.VideoBufferType.RGBA) rgba = vf.convert(rtc.VideoBufferType.RGBA)
if rgba.width >= 64 and rgba.height >= 64:
img = Image.frombytes("RGBA", (rgba.width, rgba.height), bytes(rgba.data)) img = Image.frombytes("RGBA", (rgba.width, rgba.height), bytes(rgba.data))
buf = io.BytesIO() buf = io.BytesIO()
img.convert("RGB").save(buf, format="JPEG", quality=85) img.convert("RGB").save(buf, format="JPEG", quality=85)
img_b64 = base64.b64encode(buf.getvalue()).decode() img_b64 = base64.b64encode(buf.getvalue()).decode()
image_data = (img_b64, "image/jpeg") image_data = (img_b64, "image/jpeg")
logger.info("Captured %dx%d frame from active call for text query", rgba.width, rgba.height) 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: except Exception as exc:
logger.warning("Failed to capture frame from call: %s", exc) logger.warning("Failed to capture frame from call: %s", exc)