ffmpegwasm / ffmpegwasm/ffmpeg.wasm

Export ffmpeg-core.worker.js for core package

Open
#767 2 comments 7 reactions 0 assignees View on GitHub
Dominant language
C
Stars
17.8k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

In order to run the single threaded worker, we need to either serve the built worker.js file and its dependencies on the domain where the worker will be instantiated OR blobify (via `toBlobURL()`) a compiled worker asset.

The `core-mt` package makes this possible via:

```
const baseURL = 'https://unpkg.com/@ffmpeg/core-mt@0.12.6/dist/esm'
ffmpeg = new FFmpeg();
const [coreURL, wasmURL, workerURL] = await Promise.all([
toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
toBlobURL(`${baseURL}/ffmpeg-core.worker.js`, 'text/javascript'),
]);
await ffmpeg.load({ coreURL, wasmURL, workerURL, classWorkerURL: workerURL });
```

but since the `core` package does not produce this `ffmpeg-core.worker.js` artifact, we have to create our own (basically a concatenation of [worker.js](https://github.com/ffmpegwasm/ffmpeg.wasm/blob/main/packages/ffmpeg/src/worker.ts) + [const.js](https://github.com/ffmpegwasm/ffmpeg.wasm/blob/main/packages/ffmpeg/src/const.ts) + [errors.js](https://github.com/ffmpegwasm/ffmpeg.wasm/blob/main/packages/ffmpeg/src/errors.ts) -> ffmpeg-core.worker.js)

**Describe the solution you'd like**
Like you're already doing with the `core-mt` package, create and publish a `ffmpeg-core.worker.js` artifact for the single threaded `core` package.

**Describe alternatives you've considered**
1. We're not ready to try the multithreaded solution
2. The workaround noted [here](https://www.linkedin.com/pulse/web-based-video-conversion-from-webm-mp4-ffmpegwasm-hladchenko-wfejf/) about hosting the `worker.js`, `const.js` and `errors.js` files on the our domain is error prone

**Additional context**
We think this is a reasonable alternative to perhaps bigger refactors proposed elsewhere: https://github.com/ffmpegwasm/ffmpeg.wasm/issues/617

Thank you for this great library and for your time and attention!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.