在websocket上使用broadway.js和raspi摄像头时出现问题

在websocket上使用broadway.js和raspi摄像头时出现问题,websocket,camera,stream,raspberry-pi3,h.264,Websocket,Camera,Stream,Raspberry Pi3,H.264,我想做的是用PI来控制我造的一辆小车。我想通过网络界面来控制这一点,还想在开车时使用PI摄像头来获取实时流 我在PI上使用nodejs和这个模块:从PI摄像机获取流。这是我的nodejs代码: var raspividStream = require('raspivid-stream'); var stream = raspividStream(); wss.on('connection', function connection(ws) { ws.on('message', functi

我想做的是用PI来控制我造的一辆小车。我想通过网络界面来控制这一点,还想在开车时使用PI摄像头来获取实时流

我在PI上使用nodejs和这个模块:从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...

有人知道如何解决这个问题吗?

百老汇最新版本中有一个静态文件资产,名为
avc.wasm
。您需要让服务器提供正确的MIME内容类型,
application/wasm
,以便解码器可以加载它

或者,您也可以使用asm.js而不是WebAssembly尝试旧版本的百老汇。是的

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.