-
-
Notifications
You must be signed in to change notification settings - Fork 845
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
Any plans to have a version without SharedArrayBuffer? #137
Comments
sharedarraybuffer support is still available in firefox and chrome. and will soon be enabled by default in both again as the security issues have been mitigated (see coop/cope) I believe chrome desktop has enabled it already, snd chrome mobile is working on it Basically, there is no need infact if you follow the guide it should work on updated firefox and chrome no? |
That’s good to know, however my target is cross-platform so iOS, Android, PC... without that just simply doesn’t work use ffmpeg as a base framework. I was wondering if can be like a temporal workaround using other method instead of that🤔 |
again shared buffer array is comming to mobiles (im not sure about IOS but im sure it wouldn't be too hard to find out), firefox nightly on android starts it but crashes before it starts encoding suggesting the issues something else |
Any other alternate way to achieve trimming video on mobile web app browser? |
For the version without SharedArrayBuffer, I would suggest to use ffmpeg.js (https://github.com/Kagami/ffmpeg.js/), right now ffmpeg.wasm doesn't have plan to do that. |
Can i build my own ffmpeg.wasm without SharedArrayBuffer(using ffmpeg.wasm-core)? Where is SharedArrayBuffer used ?Thank you @jeromewu |
@seminelee I would suggest you use ffmpeg.js instead, it doesn't use SharedArrayBuffer. SharedArrayBuffer in ffmpeg is used to enable multi-threading, it makes it faster when transcoding media. |
@jeromewu thank you. But I can't find |
You can find it here: https://unpkg.com/@ffmpeg/core@0.10.0/dist/ffmpeg-core.js |
Unfortunately ffmpeg.js doesn't support libtheora (I need encoding), and Firefox addons are supporting SharedArrayBuffers only for "privileged addons" (and I wanted to use it for an addon). Is there really no way to build it without SAB? I don't really mind being it single-threaded. |
Acutually you can build it on your own by removing all pthread support in build script, so it is totally possible but takes time to develop. https://github.com/ffmpegwasm/ffmpeg.wasm-core/tree/n4.3.1-wasm/wasm/build-scripts Currently I don't have plan to do that as single thread version is slow and conflicts with ffmpeg.js. |
I'm trying to build a version with pthreads removed, as I need to target ios. Speed is not important, as my use case is to extract audio from a user video upload. Normally I would do this with audioContext.decodeAudioData, but safari doesn't support decoding their own MOV codec. FFmpeg.js does not recognize a video file recorded from iPhone, but this project contains the libraries to work with a MOV file. So using wasm.core I removed all the pthread references from the build script, and removed the -j flag from the MAKE commands. However the build does not produce a dist folder with the wasm files. The terminal log is very long, and there is no immediate error's at the end so I'm not sure where to start debugging. Any advice how to debug building this project, or anything else I should look for that could cause the build to fail? I would even consider paying someone to help build this project, as I really need it for my use case. |
Maybe I can help to build the single thread version and put it somewhere, but to use it, you still need to write a Will update here once I build the single-thread version. |
That would be amazing! Like to the 10th degree of awesome. As for the wrapper, would there be significant changes from the utils.js file provided in the core example? I was looking through the browser examples, and I didn't see anything in particular that looks like it had to change to support a single thread. Unless the calls utils makes to the 'createFFmpegCore' function would require different parameters. |
@jeromewu May I ask is there any updates on the latest single-thread version? |
I plan to release it after updating ffmpeg.wasm, but if you are in a hurry, you can download the singled threaded version here: https://github.com/ffmpegwasm/ffmpeg.wasm-core/actions/runs/1050801687 (You can download it in artifacts section) And you can check here for how to use it: https://github.com/ffmpegwasm/ffmpeg.wasm-core/tree/n4.3.1-wasm/wasm/tests/utils/st (Sorry I only write a node.js version for testing, but it shouldn't be too hard to write a web worker version on your own) |
Does that means once you update the ffmpeg.wasm we could directly use it in the browser with ffmpeg.wasm? |
I have build a version without SharedArrayBuffer by this build script: https://github.com/seminelee/ffmpeg.wasm-core/blob/n4.3.1-wasm/build1.sh By the way, is |
Do you have a example for browser version? |
@ZYMoridae Yes, that is the plan, but I haven't got enough time to complete it. |
@seminelee Nope, I don't think |
can i build a version with |
I would suggest you write your own web worker script, it is actually easier than building one. |
If I write a web worker script, can I still use this project |
Nope, in that case you cannot use @ffmpeg/ffmpeg as it is not compatible. |
Hi @jeromewu, do you have an example of how to use the single thread ffmpeg build? I spend some time trying to use the ffmpeg-core single-thread version but I can't make it work. I already read the test files 20 times but I don't really understand it. Thanks for your help :) |
The key is , in I have written an article about it, but in Chinese: https://juejin.cn/post/6998876488451751973 |
The shard buffer issue is a blocker for this code. |
@seminelee @Aeroxander
EDIT: I sorted above error by removing libx264@seminelee Do you know how to add support for
This is the updated |
Not true. You can compile a single core wasm yourself. I've done that, and it works fine in prod, as long as you can accept average speeds. |
If I set headers for cross origin isolation which is needed to enable shared array buffer, I cannot download things from other site. Could anyone has a solution to that problem? |
@channyeintun You can build your own ffmpeg.wasm single thread that doesn't need shared array buffer. @seminelee made some comments above about how to do it. I shared the |
After seeing so many replies with the same subject, I am going to publish here how to deal with this and how you can compile ffmpeg yourself (some might be afraid or lazy). Because of the nature of ffmpeg, it is better to have multi-threading to have a better performance. This requires SharedArrayBuffer though, which is the reason many complain it doesn't work / it is not production ready. @jeromewu already added support to single-thread in the main branch of Build
|
I usually vendor the libs used on my Chrome Extensions, so if anyone is looking for compiled versions of the I've written a post with the tricks and caveats around implementing FFmpeg in an extension. Mainly a bit of pain on Firefox, due to the missing SharedArrayBuffer, but I had my way: https://brunoluiz.net/blog/2022/jan/gif-sane-playback-control-ffmpegwasm/ |
Hi @brunoluiz Thanks for putting together the post. I have followed it step-by-step (and also tried your vendor files), but i keep coming up against this error when running the single threaded version (Chrome emulator, v98);
and similar, yet differently worded error on Safari v15.3 ;
My implementation;
Have you encountered this? Any help appreciated, |
Ok, managed to resolve it. |
Hello @brunoluiz
Sorry for maybe noob question. After changing createFFmpeg.js acording to #235 I should build a package, from this point could you explane more detaily? How to build the package? Can I build it via workflows/main.yml? If so could you share your yml script? |
To build the package, you need to:
This will generate a new JS package. The caveat is that, if you want to install in other projects through npm, you might need to publish in |
What's the conclusion for this? Are we still patching and building ourselves, or is there a simple way to disable the dependency on SharedArrayBuffer? |
I added |
Looks like the problem is that this fix is in |
Update: Yes, if you fetch the |
Any news about a potential easier way instead of having to build ourselves ? |
@FrenchGithubUser The unreleased v0.12.0-alpha works in non-SharedArrayBuffer mode. Code: https://github.com/ffmpegwasm/ffmpeg.wasm/tree/v0.12.0-alpha.1 You can install it from npm: However, note that the API is pretty different, and there aren't good docs yet. |
I'm having an issue trying to run the latest beta version. Could someone help me figuring out what is wrong with what I did ? Versions used :
Here is my code :
And I'm getting these errors :
|
@FrenchGithubUser, you might want to file a different bug report to make sure the team sees it and clearly indicate the alpha version you are using @jimbojw we are excited to give the new alpha a spin today 😁 |
It seems that you no longer need to build any of the libraries or to rely on the alpha version as there is a hosted single threaded version on unkpg.
I'm still looking for ways to have the corePath take a local path, but it seems to raise issues that are for another thread. So for now I'll just rely on the above solution. I hope this can help someone out there. |
I can confirm this is THE Solution |
Correct me if I'm wrong, but I believe it's now just https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.4/ without the "-st." Could be something else though. |
Wouldn't that be the multithreading version? Aka |
But this is the multithreading version: https://cdn.jsdelivr.net/npm/@ffmpeg/core-mt@0.12.4/ |
Is your feature request related to a problem? Please describe.
It's a known problem that SharedArrayBuffer was removed due to Spectre and Meldown hacks.
Describe the solution you'd like
A safe version without SharedArrayBuffer
Describe alternatives you've considered
I don't have the knowledge in Emcripten nor how you transpile the code to know if it's possible.
Additional context
To be able to run this amazing project everywhere we need a version without SharedArrayBuffer!
The text was updated successfully, but these errors were encountered: