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

Ffmpeg.wasm not working in Chrome extension due to SharedArrayBuffer

Open ZarcoV opened this issue 4 years ago • 5 comments

Describe the bug I can't seem to be able to use ffmpeg.wasm in a chrome extension anymore.

To Reproduce I simply used the example from https://github.com/ffmpegwasm/chrome-extension-app and loaded it into my chrome as an extension, this now throws an Uncaught (in promise) ReferenceError: SharedArrayBuffer is not defined error. I've also attempted to run ffmpeg.wasm from the sanbox environment of a chrome extension, but it resulted in the same error.

Expected behavior A working example of ffmpeg.wasm running inside of a chrome extension (preferably locally hosted).

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome & Brave
  • Version: Chrome 92.0.4515.107 & Brave 1.27.109

ZarcoV avatar Aug 02 '21 13:08 ZarcoV

You need to enable Cross Origin Isolation for that : https://web.dev/cross-origin-isolation-guide/

I don't know how to set headers in my local environnement, my workaround is to launch Chrome with this command :

--enable-features=SharedArrayBuffer

Check this link to know how to launch Chrome with a command : https://www.chromium.org/developers/how-tos/run-chromium-with-flags

If you upload your website, you will need to set the headers according to the tutorial above, but I don't know how to do it for chrome extensions.

julienbeisel avatar Aug 03 '21 15:08 julienbeisel

Hello, I want to ask about the progress for single-thread

jzwb avatar Aug 11 '21 03:08 jzwb

Here is the latest update for the single-thread version: https://github.com/ffmpegwasm/ffmpeg.wasm/issues/137#issuecomment-890510355

jeromewu avatar Aug 11 '21 03:08 jeromewu

You need to enable Cross Origin Isolation for that : https://web.dev/cross-origin-isolation-guide/

I don't know how to set headers in my local environnement, my workaround is to launch Chrome with this command :

--enable-features=SharedArrayBuffer

Check this link to know how to launch Chrome with a command : https://www.chromium.org/developers/how-tos/run-chromium-with-flags

If you upload your website, you will need to set the headers according to the tutorial above, but I don't know how to do it for chrome extensions.

This works fine for a website, but it does not resolve the issue with the chrome extension as far as I can tell.

ZarcoV avatar Aug 17 '21 10:08 ZarcoV

I went through the process of implementing FFmpeg.wasm in an extension... There are a few caveats, but it is possible.

An example extension with a possible implementation on Manifest V2 (both on Chrome and Firefox): https://github.com/brunoluiz/gifsane-extension Post explaining some of the implementation details: https://brunoluiz.net/blog/2022/jan/gif-sane-playback-control-ffmpegwasm/

brunoluiz avatar Jan 24 '22 15:01 brunoluiz