admin管理员组文章数量:1313807
I need to decode h264 data at browser side for that I am using openh264 library build in web Assembly using emscripten. I have build it successfully and tried to use it in java script to decode the h264 data. But I am getting one error for following line,
var open_decoder = Module.cwrap('open_decoder', 'number', null);
Error is: Uncaught TypeError: Module.cwrap is not a function
If anyone has has build openh264 with emscripten please help me to figure out issue.
Following steps I have used to build openh264 with emscripten.
- $ source emsdk_env.sh
- $./emsdk activate latest
- cd openh264-js-master
- make
Note : The code for openh264 has been downloaded from github( ttyridal) and already has make file with emscripten petent.
I need to decode h264 data at browser side for that I am using openh264 library build in web Assembly using emscripten. I have build it successfully and tried to use it in java script to decode the h264 data. But I am getting one error for following line,
var open_decoder = Module.cwrap('open_decoder', 'number', null);
Error is: Uncaught TypeError: Module.cwrap is not a function
If anyone has has build openh264 with emscripten please help me to figure out issue.
Following steps I have used to build openh264 with emscripten.
- $ source emsdk_env.sh
- $./emsdk activate latest
- cd openh264-js-master
- make
Note : The code for openh264 has been downloaded from github( ttyridal) and already has make file with emscripten petent.
Share Improve this question asked May 8, 2019 at 11:53 Kuldeep MoreKuldeep More 1384 silver badges14 bronze badges2 Answers
Reset to default 6-s EXTRA_EXPORTED_RUNTIME_METHODS=["cwrap"]
Include above in mand line while piling your source
emcc source.c -s EXPORTED_FUNCTIONS=['_my_add'] -s EXTRA_EXPORTED_RUNTIME_METHODS=["cwrap"]
Probably you are trying to use Module
before the Emscripten runtime has been initialized, so Module.cwrap
is undefined.
To make sure the runtime is ready, place your code inside of Module.onRuntimeInitialized
, as in the following example:
<!doctype html>
<html>
<body>
<script>
var Module = {
onRuntimeInitialized: function() {
my_add = Module.cwrap('my_add', 'number', ['number', 'number'])
alert('1 + 2 = ' + my_add(1, 2));
},
};
</script>
<script async type="text/javascript" src="index.js"></script>
</body>
</html>
See full example in this github repo
本文标签: javascriptUncaught TypeError Modulecwrap is not a functionStack Overflow
版权声明:本文标题:javascript - Uncaught TypeError: Module.cwrap is not a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741955102a2406942.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论