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

Web Worker Support [PATCH]

Open absurdprofit opened this issue 2 years ago • 6 comments

In the previous version as far as the browser was concerned there was usage of a deprecated package called resolve-url which was throwing an error document not defined as outlined in this issue. However as encouraged by the author, resolve-url was removed in favour of the browser native URL API. There still arose an issue in src/browser/getCreateFFmpegCore.js where a script import was attempted by appending a script tag to the <head> of the HTML page. In a Web Worker context this will be replaced by globalThis.importScripts; in the main thread context however the behaviour is unchanged.

absurdprofit avatar Apr 05 '22 23:04 absurdprofit

Please merge, I also want to use FFMPEG.wasm in a webworker.

richard-llmnn avatar May 13 '22 19:05 richard-llmnn

Alternatively you could clone my fork as a last resort. 😕

absurdprofit avatar May 13 '22 23:05 absurdprofit

Alternatively you could clone my fork as a last resort. confused

Yes, but the easier and cleaner way is when your changes are merged into the master and (I think) then rebased into the singleThreaded branch.

richard-llmnn avatar May 14 '22 07:05 richard-llmnn

@nxtexe Can you also add the importScripts changes from here? Edit: Sorry, I have only seen it now that you already added the importScripts

richard-llmnn avatar May 14 '22 07:05 richard-llmnn

Hi there,

Has anyone encountered issues calling ffmpeg.run() multiple times?

The first time i call ffmpeg.run() it works, the 2nd time i call ffmpeg.run() in the web worker it throws the following error; [fferr] Assertion failed: native function 'malloc' called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)

merri-ment avatar Jun 01 '22 20:06 merri-ment

ok, i just tested the transcode.worker.html example in this pull request and didn't experience the above issue. Must be the way i integrated the single-threaded solution

merri-ment avatar Jun 01 '22 23:06 merri-ment

any plans to merge this one?

0xori avatar Aug 14 '22 09:08 0xori

Thanks for the PR! This one looks awesome!

jeromewu avatar Aug 14 '22 12:08 jeromewu

Hi there,

Has anyone encountered issues calling ffmpeg.run() multiple times?

The first time i call ffmpeg.run() it works, the 2nd time i call ffmpeg.run() in the web worker it throws the following error; [fferr] Assertion failed: native function 'malloc' called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)

@merri-ment set EXIT_RUNTIME=0 in wasm/build-scripts/build-ffmpeg.sh before building ffmpeg.wasm-core

yeliulee avatar Aug 25 '22 06:08 yeliulee

Another +1 on this. Please merge as this blocks using single-threaded in a Worker context.

jimbojw avatar Dec 20 '22 21:12 jimbojw