python - 使用 websocket 实现更快的 Python 屏幕共享
问题描述
我的带有 websockets 的 python 屏幕共享程序非常慢,看起来它每秒只有 1 或 2 帧
客户端使用mss截图
sct = mss.mss()
moniter = sct.monitors[1]
sct.compression_level = 7
im = sct.grab(moniter)
raw_bytes = mss.tools.to_png(im.rgb, im.size)
return base64.encodebytes(raw_bytes) # the bytes are directly sent through the websocket
服务器端接收图像
img_bytes = base64.decodebytes(await self.ws.recv()) # receive bytes and decode base64
img = Image.open(io.BytesIO(img_bytes))
我怎样才能使这个屏幕共享更快?谢谢