FFmpeg-wasm/FFmpeg.wasm

Bus Error

Closed this issue · 15 comments

wesbos commented

Hello, thank you for this library.

I'm having an issue with the following code in Node.js v20.1.0, but also appears on LTS v18.17.0

test.js:

import { FFmpeg } from "@ffmpeg.wasm/main";
const ffmpeg = await FFmpeg.create()

running node test.js I get "bus error".

I'm not able to catch any errors, nor see whats causing this. Any idea how to debug?

Screenshot 2023-08-03 at 2 43 59 PM

package.json:

{
  "name": "ffmpeg-delete-me",
  "version": "0.0.1",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "Wes Bos (https://wesbos.com/)",
  "license": "MIT",
  "dependencies": {
    "@ffmpeg.wasm/core-mt": "^0.13.2",
    "@ffmpeg.wasm/main": "^0.13.0"
  },
  "type": "module"
}
wesbos commented

Seems to be happening when requiring the core in importCore function. Both core-mt and core-st create a bus error

wesbos commented

Dug a bit deeper - its this line:

      let core = yield (yield importCore(options.core, logger))({
        arguments: VERSION_ARGS,

VERSION_ARGS is ["ffmpeg", "-version"] and I guess when it runs that, it chokes? Replacing it with ["echo", "hello"] still breaks, so when the command is run its throwing a bus error

wesbos commented

Reverting the core to "@ffmpeg.wasm/core-mt": "0.12.0", seems to not be throwing the error. Still on latest for the main package.

wesbos commented

Sorry for all the comments. They don't seem to work together. this.core._free is not a function

You can add log: true to the options of FFmpeg.create(), this should log some useful information

wesbos commented

I tried that,this code:

import { FFmpeg } from "@ffmpeg.wasm/main"
const ffmpeg = FFmpeg.create({
  log: true,
  logger: (level, message) => console.log(level, message),
});

Gives me:

node test.js
debug Import '@ffmpeg.wasm/core-mt' with cjs require()
[1]    39199 bus error  node test.js

Cloud you provide a more detailed system and environment info?
I can't reproduce this problem with nodejs v18.17.0 under Windows10 or Debian12.

wesbos commented

Macbook Pro, 2021 Apple M1 Max.

Node v18.17.0
npm 9.6.7

    "@ffmpeg.wasm/core-mt": "0.13.2",
    "@ffmpeg.wasm/core-st": "0.13.2",
    "@ffmpeg.wasm/main": "0.13.0"

I tried to replicate it here, but it does work. So maybe it's an apple silicon issue? https://codesandbox.io/p/sandbox/jolly-mccarthy-pmw9gd?file=%2Findex.js%3A8%2C1

wesbos commented

I'm collecting data over here: wesbos/ff-me#1

So far it seems to happen only on Mac OS, both intel and silicon chips.

evayde commented

The tests of the project also fail on Mac. Same error message.

Have you tried core-st? Will there still be the same error?

You can clone DreamOfIce/ffmpeg.wasm-core and uncomment this line:

https://github.com/DreamOfIce/ffmpeg.wasm-core/blob/6690593aa6b014dad266efa97293e32d27499c0c/wasm/bu ild-scripts/var.sh#L32

Then run ./build.sh to build debug version of the core.

Switch to the local core through pnpm add -D /path/to/ffmpeg.wasm-core /packages/core-mt/.

Then run the test again, and you should be able to see more detailed output.

It looks like this issue has been fixed in the latest v20.5.0
But not yet fixed in v18.17.0 LTS
wesbos/ff-me#1 (comment)

evayde commented

It looks like this issue has been fixed in the latest v20.5.0 But not yet fixed in v18.17.0 LTS wesbos/ff-me#1 (comment)

Confirmed! This issue doesn't exist in Node 20.5.0 on Mac

wesbos commented

looks like it's working on 20.5.0 - thank you everyone!