ffmpegwasm / ffmpegwasm/ffmpeg.wasm

Not allowed to load local resource

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

Description

**Describe the bug**
Working fine locally, but when i commit to production it fails to load the 'fetchFile.js' file:

```
_app-89c14310fa418025204d.js:1 Not allowed to load local resource: file:///codebuild/output/src10319366/src/app-sls-lav/node_modules/@ffmpeg/ffmpeg/src/browser/fetchFile.js
```

I am on Nextjs 12, and my code:

```
import { createFFmpeg, fetchFile } from '@ffmpeg/ffmpeg'

const convertVideo = async (file: any) => {
const ffmpeg = createFFmpeg({
corePath: 'https://unpkg.com/@ffmpeg/core@0.10.0/dist/ffmpeg-core.js',
log: true
})

try {
await ffmpeg.load()

ffmpeg.FS('writeFile', 'input.mp4', await fetchFile(file))

await ffmpeg.run('-i', 'input.mp4', 'output.mp4')

const data = ffmpeg.FS('readFile', 'output.mp4')
const videoUrl = URL.createObjectURL(
new Blob([data.buffer], { type: 'video/mp4' })
)

setConvertedVideoSrc(videoUrl)

ffmpeg.FS('unlink', 'input.mp4')
ffmpeg.FS('unlink', 'output.mp4')
} catch (error) {
console.log('erro ffmpeg', error)
}
}
```

I have the `ffmpeg-core.js`, `ffmpeg-core.wasm` and `ffmpeg-core.worker.js` on my public folder, and it works fine if i put my domain on the `corePath` or if i am using unpkg like the example before, it doesn't complain about ffmpeg-core, but it fails on the `fetchFile` function.

I already tried moving the function to this same file, putting on the public folder or an utils folder and importing it, and i always get this error.

**To Reproduce**
Just write that code and try to use it on production.

**Expected behavior**
To properly load the function.

**Screenshots**
![Screenshot 2023-06-28 at 8 36 49 AM](https://github.com/ffmpegwasm/ffmpeg.wasm/assets/17055027/683ab1b1-91c5-4878-818b-8b28448c55b1)

**Desktop (please complete the following information):**
- OS: macOS ventura
- Browser: Chrome and Firefox have this error.
- Version: Chrome Version 114.0.5735.198 (Official Build) (x86_64), Firefox 114.0.2 (64-bit)

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.