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:
15
bot.py
15
bot.py
@@ -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)
|
||||||
img = Image.frombytes("RGBA", (rgba.width, rgba.height), bytes(rgba.data))
|
if rgba.width >= 64 and rgba.height >= 64:
|
||||||
buf = io.BytesIO()
|
img = Image.frombytes("RGBA", (rgba.width, rgba.height), bytes(rgba.data))
|
||||||
img.convert("RGB").save(buf, format="JPEG", quality=85)
|
buf = io.BytesIO()
|
||||||
img_b64 = base64.b64encode(buf.getvalue()).decode()
|
img.convert("RGB").save(buf, format="JPEG", quality=85)
|
||||||
image_data = (img_b64, "image/jpeg")
|
img_b64 = base64.b64encode(buf.getvalue()).decode()
|
||||||
logger.info("Captured %dx%d frame from active call for text query", rgba.width, rgba.height)
|
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:
|
except Exception as exc:
|
||||||
logger.warning("Failed to capture frame from call: %s", exc)
|
logger.warning("Failed to capture frame from call: %s", exc)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user