Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

作者您好,一个编译问题 #5

Open
wusopp opened this issue Jul 9, 2020 · 7 comments
Open

作者您好,一个编译问题 #5

wusopp opened this issue Jul 9, 2020 · 7 comments

Comments

@wusopp
Copy link

wusopp commented Jul 9, 2020

您好,请教一个编译问题。我这边按照示例说明,编译了ffmpeg4.1.6版本,但总是提示。编译其他版本也是一样的,编译环境采用的是Ubuntu18.04

当载入H264或者H265后,总是出现报错,如下
libffmpeg_265.js:1 Uncaught TypeError: Cannot read property 'slice' of undefined
at convertJsFunctionToWasm (libffmpeg_265.js:1)
at addFunctionWasm (libffmpeg_265.js:1)
at Object.addFunction (libffmpeg_265.js:1)
at decode_seq (video.js:30)
at handleVideoFiles (video.js:14)
at HTMLInputElement.onchange (main.html:11)

音频播放无问题

但使用从源程序中下载的libffmpeg_265.js 和 libffmpeg_265.wasm 却不会报错,是编译上哪里出问题了么?还是需要代码进行调整?

@wusopp
Copy link
Author

wusopp commented Jul 9, 2020

版本信息如下,编译ffmpeg4.1 ,ffmpeg4.2 版本均有此问题。其中禁用了--disable-pthreads ,否则编译无法通过

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.39.18
clang version 11.0.0 (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-llvm-llvm--project 613c4a87ba9bb39d1927402f4dd4c1ef1f9a02f7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/emscripten/emsdk/upstream/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
shared:INFO: (Emscripten: Running sanity checks)

@snxly
Copy link
Collaborator

snxly commented Jul 13, 2020

我们用的编译代码就是github上的版本,没有额外的更改,也没有设置--disable-pthreads。
看emcc的版本,你的好像还要更新一些
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.38.45
clang version 6.0.1 (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-emscripten--core-emscripten--fastcomp--clang 98df4be387dde3e3918fa5bbb5fc43e1a0e1daac) (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-emscripten--core-emscripten--fastcomp 6c7e775325067e33fa60611e619a8b987b6d0c35) (emscripten 1.38.31 : 1.38.31)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /data/github/emsdk/fastcomp/fastcomp/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
shared:INFO: (Emscripten: Running sanity checks)

另外,之前碰到了一些编译问题,gcc是单独安装的
[root@player1-15f477ac5 ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/9.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --enable-checking=release --enable-language=c,c++ --disable-multilib
Thread model: posix
gcc version 9.1.0 (GCC)

@wusopp
Copy link
Author

wusopp commented Jul 13, 2020

我们用的编译代码就是github上的版本,没有额外的更改,也没有设置--disable-pthreads。
看emcc的版本,你的好像还要更新一些
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.38.45
clang version 6.0.1 (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-emscripten--core-emscripten--fastcomp--clang 98df4be387dde3e3918fa5bbb5fc43e1a0e1daac) (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-emscripten--core-emscripten--fastcomp 6c7e775325067e33fa60611e619a8b987b6d0c35) (emscripten 1.38.31 : 1.38.31)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /data/github/emsdk/fastcomp/fastcomp/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
shared:INFO: (Emscripten: Running sanity checks)

另外,之前碰到了一些编译问题,gcc是单独安装的
[root@player1-15f477ac5 ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/9.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --enable-checking=release --enable-language=c,c++ --disable-multilib
Thread model: posix
gcc version 9.1.0 (GCC)

好的,我这边先尝试下

@lantf
Copy link

lantf commented Oct 16, 2020

@wusopp 请教一下,这问题解决了么?我现在也遇到这问题,谢谢!

@wusopp
Copy link
Author

wusopp commented Oct 16, 2020

@wusopp 请教一下,这问题解决了么?我现在也遇到这问题,谢谢!

你可以试试 1.38.45 版本的,我当时是这个问题,仅供参考。

@smilemoon
Copy link

@wusopp 请教一下,这问题解决了么?我现在也遇到这问题,谢谢!

你可以试试 1.38.45 版本的,我当时是这个问题,仅供参考。

用1.38以上的版本,就会出现以上的问题吗?

@vincentxuc
Copy link

var videoCallback = Module.addFunction(function (addr_y, addr_u, addr_v, stride_y, stride_u, stride_v, width, height, pts) {
        console.log("[%d]In video callback, size = %d * %d, pts = %d", ++videoSize, width, height, pts)
        let size = width * height + (width / 2)  * (height / 2) + (width / 2)  * (height / 2)
        let data = new Uint8Array(size)
        let pos = 0
        for(let i=0; i< height; i++) {
            let src = addr_y + i * stride_y
            let tmp = HEAPU8.subarray(src, src + width)
            tmp = new Uint8Array(tmp)
            data.set(tmp, pos)
            pos += tmp.length
        }
        for(let i=0; i< height / 2; i++) {
            let src = addr_u + i * stride_u
            let tmp = HEAPU8.subarray(src, src + width / 2)
            tmp = new Uint8Array(tmp)
            data.set(tmp, pos)
            pos += tmp.length
        }
        for(let i=0; i< height / 2; i++) {
            let src = addr_v + i * stride_v
            let tmp = HEAPU8.subarray(src, src + width / 2)
            tmp = new Uint8Array(tmp)
            data.set(tmp, pos)
            pos += tmp.length
        }
        var obj = {
            data: data,
            width,
            height
        }
        displayVideoFrame(obj);
    }, 'viiiiiiiii');

这里改成这样,新的版本https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#calling-javascript-functions-as-function-pointers-from-c 需要传函数的返回还有参数类型

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants