我想做的是使用PI控制我制造的小型车辆。我想通过Web界面对此进行控制,还希望在驾驶时使用PI摄像机获取直播。
我正在通过以下模块在PI上使用nodejs:https://www.npmjs.com/package/raspivid-stream,以从PI摄像机获取流。这是我的nodejs代码:
var raspividStream = require('raspivid-stream');
var stream = raspividStream();
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
stream.on('data', (data) => {
ws.send(data, { binary: true }, (error) => { if (error) console.error(error);
});
});
,这里是index.html:
...htmlstuff...
<canvas id="stream"></canvas>
<script src="decoder.js"></script>
<script src="player.js"></script>
<script>
var connection = new WebSocket('ws://raspberrypi:8443');
var p = new Player();
p.canvas = document.getElementById("stream"); // the canvas - p$
connection.onopen = function () {
connection.send('Ping'); // Send the message 'Ping' to $
};
connection.onerror = function (error) {
console.log('WebSocket Error ' + error);
};
connection.onmessage = function (e) {
console.log(e.data);
p.decode(e);
};
</script>
...htmlstuff...
到目前为止,我在浏览器控制台中遇到此错误:
wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.
falling back to ArrayBuffer instantiation
failed to asynchronously prepare wasm: CompileError: AsyncCompile: Wasm decoding failed: expected magic word 00 61 73 6d, found 3c 21 44 4f @+0
CompileError: AsyncCompile: Wasm decoding failed: expected magic word 00 61 73 6d, found 3c 21 44 4f @+0
Uncaught (in promise) abort({}). Build with -s ASSERTIONS=1 for more info.
有人知道如何解决这个问题吗?
答案 0 :(得分:0)
最新版本的Broadway中有一个名为avc.wasm
的静态文件资产。您需要让服务器以正确的MIME内容类型application/wasm
交付它,以便解码器可以加载它。
或者您可以使用asm.js而不是WebAssembly尝试较旧版本的Broadway。是here。