ffmpeg.wasm icon indicating copy to clipboard operation
ffmpeg.wasm copied to clipboard

ffmpeg.exit() throws error form within and breaks its internals

Open nomagick opened this issue 4 years ago • 5 comments
trafficstars

Running ffmpeg.exit() breaks the ffmpeg instance. All ffmpeg.run calls after ffmpeg.exit() would stall with ffmpeg.isLoaded() left true, not able to ffmpeg.load().

To Reproduce Steps to reproduce the behavior:

  1. Run ffmpeg normally
  2. During execution, run ffmpeg.exit()
  3. Run the same ffmpeg instance again
  4. See the program stall

While executing ffmpeg.exit(), an error was thrown. Which is odd but tolerable.

After executing ffmpeg.exit(), the ffmpeg instance broke. Which is a Bug.

https://github.com/ffmpegwasm/ffmpeg.wasm/blob/2d6fae83888950f98483d0f7dfcde6745a34ac92/src/createFFmpeg.js#L176-L186

It seems the error thrown from https://github.com/ffmpegwasm/ffmpeg.wasm/blob/ea760ac892e943b0ee406ee1c7421d610c28dfae/src/createFFmpeg.js#L181 prevented the rest of the code be executed.

nomagick avatar Aug 11 '21 10:08 nomagick

It turned out running ffmpeg.exit() during execution is not required to reproduce this issue. Just ffmpeg.exit() and reuse the same instance.

nomagick avatar Aug 11 '21 10:08 nomagick

Moving the Core.exit(1); to last line may solve this issue while retaining its bizarre throwing behavior.

But I think we need ffmpeg.exit() not throw any error

And related behavior be tested.

nomagick avatar Aug 11 '21 10:08 nomagick

If the current behavior that the ffmpeg instance after exit would not be useable again is expected, then it should be renamed to destroy

nomagick avatar Aug 11 '21 10:08 nomagick

Any chance of merging this fix soon?

If I understand correctly I need to run exit to free up memory and atm running exit throws an error.

orangecoloured avatar Oct 19 '21 11:10 orangecoloured

  1. remove node_moudules;
  2. modify your package.json file: "dependencies": { "@ffmpeg/core": "^0.10.0", "@ffmpeg/ffmpeg": "git+ssh://[email protected]:xiaofei1996/ffmpeg.wasm.git", // better fork it into your repo ... },
  3. npm install

[email protected]:xiaofei1996/ffmpeg.wasm.git is my repo which i fix the bug on the top of #274

xiaofei-2020 avatar Feb 18 '22 09:02 xiaofei-2020