websocket - fastest way to stream image over web-socket
问题描述
i'm trying to broadcast a image to any client that connect to websocket, the problem is : something the speed aren't enough to achieve 10FPS+
// img are from ~11ms process
png.Encode(&b, img)
// jpeg.Encode(&b, img, nil)
sEnc := base64.StdEncoding.EncodeToString(b.Bytes())
message := Message{
Type: "frame",
Frame: sEnc,
Device: "pap99",
Width: 320,
Height: 240,
}
encoded, _ := json.Marshal(message)
err = c.WriteMessage(websocket.BinaryMessage, encoded)
if err != nil {
log.Println("write:", err)
return
}
the client :
conn.onmessage = function (evt) {
var data = JSON.parse(evt.data);
frame.src = `data:image/png;base64,${data["frame"]}`
}
is there any way to achieve 10FPS+ with current code ? thankyou
解决方案
推荐阅读
- arrays - 如何将默认值分配给 ansible ARRAY 变量
- excel - Excel VBA 跳过同一行代码,我真的希望它没有
- java - 如何在 BroadcastReceiver 中修复 [Found: 'android.content.Context', required: 'androidx.lifecycle.LifecycleOwner' ]?
- django - 在同一 VM 不同的虚拟环境中在生产环境中运行多个 celery 实例
- oauth - ADFS 3.0 和无效的 JWT
- javascript - XMLHttpRequest:实现拦截器问题
- swift - 观察从 Cell 到 ViewController Swift 的值变化
- python-3.x - 如何使用 LSTM 对图像进行时间序列预测?
- algorithm - 算法 - 找到具有重复元素的排列中间
- android - SAF - 监听云端文件夹中的事件