ffmpegwasm / ffmpegwasm/ffmpeg.wasm

About Work.js import Blob URL Error

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

Description

The problem is:
**"Uncaught (in promise) Error: Cannot find module 'blob:http://my.com/d9dabdb5-c1d8-41d0-a691-8ee7f9bc7ad1'"**
in Chrome Browser.
_"my.com" is my local host name..._

I use webpack and esm module core.

**Here is my code:**
```javascript
const load = async () => {
const baseURL = "https://unpkg.com/@ffmpeg/core-mt@0.12.4/dist/esm";

await ffmpeg.load({
coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
workerURL: await toBlobURL(`${baseURL}/ffmpeg-core.worker.js`, 'text/javascript')
};

const transcode = async ({ target: { files } }) => {

await load();

// some code....
}

const elm = document.querySelector('input#uploader');
elm.addEventListener('change', transcode);
```
**webpack.config.js**
```javascript
return {
entry: './src/js/index.js',
output: {
filename: '[name].js',
},
experiments: {
asyncWebAssembly: true,
},
mode: env.production ? 'production' : 'development',
devtool: 'source-map',
}
```

After debugging, I found that the problem lies in this piece of code:
**work.js**
```javascript
try {
// when web worker type is `classic`.
importScripts(coreURL);
}
catch {
// when web worker type is `module`.
self.createFFmpegCore = (await import(
/* @vite-ignore */ coreURL)).default;
if (!self.createFFmpegCore) {
throw ERROR_IMPORT_FAILURE;
}
}
```
**But, I don`t kown how to fix it ! HELP !**

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.