Skip to content

Export ffmpeg-core.worker.js for core package #767

Description

@higgins

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 + const.js + errors.js -> 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 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: #617

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions