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)