ffmpeg.js icon indicating copy to clipboard operation
ffmpeg.js copied to clipboard

Multithreading

Open krogank9 opened this issue 6 years ago • 7 comments

Currently I am using the ffmpeg.js file ripped out of videoconverter.js. Which I don't think makes use of multiple cores.

krogank9 avatar Oct 01 '18 15:10 krogank9

pthread support using SharedArrayBuffers using web workers is planned in emscripten, but currently it is disabled due to the spectre bug in nearly all browsers. See https://kripken.github.io/emscripten-site/docs/porting/pthreads.html

CodeFetch avatar Jan 09 '19 04:01 CodeFetch

It was re-enabled in Chrome and Edge, but still disabled in Firefox and Safari. Not sure if I want to enable it now. Maybe will experiment later.

Kagami avatar Apr 19 '20 13:04 Kagami

Threading is only supported in wasm builds, and there can not be a wasm build having threading support and a fallback if no threading is available. The idea of wasm is to have multiple builds and choose at runtime which one to load. As threading is currently only supported by chrome enabling SharedArrayBuffers only for the threading build would be no problem. In fact every browser which will support wasm threading will have to reactivate SharedArrayBuffers.

tpetry avatar Apr 20 '20 10:04 tpetry

@Kagami are you able to build ffmpeg with emcc without the --disable-thread configure option? I am trying but I have a lot of errors I don't understand...

damien-monni avatar May 11 '20 18:05 damien-monni

@damien-monni No, please read tpetry's comment. First it needs to be modularized, which I did some time ago, but people were not willing to pay a 100 bucks for it (which is less than my hourly rate). So I wasn't interested in sharing it. Don't think I'm an asshole, but open-source developers are being treated like assholes. You ask Kagami for help for something you could find an answer to in the comment above yours...

CodeFetch avatar May 11 '20 19:05 CodeFetch

Actually I did read tpetry comment or I wouldn't have asked. I'm more comfortable with Javascript than C compilation so I am not sure I understand.

I understand that threading is only supported in wasm and need SharedArrayBuffer. This is actually why I need threading on ffmpeg so I can enable shared memory between multiple wasm. But I am a bit confused on why ffmeg does not compile with emcc if I remove the --disable-thread option. What do you mean by modularized ? Does it means that we should edit ffmpeg source code so it only works with threading enabled and then we should be able to compile it with emcc?

damien-monni avatar May 12 '20 05:05 damien-monni

@damien-monni Oh damn it. Sorry for my rudeness. I've thought the issue was clear. To make a proper WASM build work, it needs to be modularized first.

CodeFetch avatar May 12 '20 12:05 CodeFetch