有没有一种已知的方法可以将视频流从浏览器返回到 WebAssembly?我知道您可以使用 HTML 画布进行帧捕获,但我不知道如何获取整个流(音频/视频)并将其发送到我的 WebAssembly 应用程序。
2 回答
看一下“WebAssembly Video Editor”示例的内部结构:
WebAssembly has a very simple interface, with only 4 types (two integeres, two floating points), the ability to import or export functions, and memory. It doesn't have any APIs for accessing the DOM, fetching data, etc ... therefore you have to provide this data to your WebAssembly module from the hosting JavaScript.
Are you trying to decode a video stream from a WebAssembly module? In that case, I'd expect the WebAssembly code to export a function, e.g. decode
, that your JavaScript code invokes as data arrives from the stream. You'll likely need to write the data to the WebAssembly memory, invoking this decode
function with the memory address and length of data that has been supplied.