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

`Uncaught (in promise) RuntimeError: memory access out of bounds` when trying to convert to Opus with `-c:a libopus`

Open CrypticSignal opened this issue 1 year ago • 11 comments

Describe the bug: I get a Uncaught (in promise) RuntimeError: memory access out of bounds when trying to transcode to Opus with -c:a libopus. I don't get this error if I choose to transcode to another format such as MP3, so I doubt there's anything wrong with the code.

To Reproduce: Go to https://av-converter.vercel.app, it's a web app I made which is essentially a frontend for ffmpeg.wasm. Open the console and use the dropdown menu on my web app to select Opus as the output format. You will see the aforementioned error in the console.

Expected behavior: The file should start transcoding like it does when choosing another format to convert to.

Additional Information:

  • OS: Windows 11 Pro
  • Browser: Chrome version 117.0.5938.92 (Official Build) (64-bit)
  • @ffmpeg/core v0.12.3
  • @ffmpeg/ffmpeg v0.12.6
  • @ffmpeg/util v0.12.1

CrypticSignal avatar Sep 24 '23 12:09 CrypticSignal

@CrypticSignal Did you try to bisect this yet? Do you know if it worked with old versions?

Sean-Der avatar Sep 27 '23 18:09 Sean-Der

If not I am going to do that now

Sean-Der avatar Sep 27 '23 18:09 Sean-Der

@Sean-Der Unfortunately I don't have any pointers e.g. at which core version this issue started. I presume this hasn't been an issue in all versions of ffmpeg.wasm, because someone probably would have mentioned this by now.

Keep me updated on your findings (if any).

CrypticSignal avatar Sep 27 '23 21:09 CrypticSignal

On v0.12.4 is the same problem

doubledare704 avatar Dec 30 '23 20:12 doubledare704

@CrypticSignal, @doubledare704: You can try to use this: ffmpeg.exec(['-i','input.mp3','-strict','-2','-c:a','opus','output.ogg',])

AX9999AX avatar Apr 07 '24 16:04 AX9999AX

@CrypticSignal Did you try to bisect this yet? Do you know if it worked with old versions?

This doesn't work for versions 12 and above. As for versions 11 and below, I haven't tested it yet.

AX9999AX avatar Apr 07 '24 16:04 AX9999AX

FWIW rebuilding the current main with -sSTACK_OVERFLOW_CHECK=2 passed to emcc revealed a more informative error message than the memory out of bounds:

Aborted(stack overflow (Attempt to set SP to 0x002d8320, with stack limits [0x002d91e0 - 0x002e91e0]). If you require more stack space build with -sSTACK_SIZE=<bytes>)

And adding -sSTACK_SIZE=5MB fixed the issue for me.

teropa avatar Apr 10 '24 14:04 teropa

And adding -sSTACK_SIZE=5MB fixed the issue for me.

@teropa could you clarify where you added this exactly? I'm trying out the build process for the first time and would like to explore this.

nsitu avatar May 07 '24 14:05 nsitu

@nsitu this was in build/ffmpeg-wasm.sh in the CONF_FLAGS variable

Screenshot 2024-05-07 at 18 02 15

teropa avatar May 07 '24 15:05 teropa

Thanks @teropa , I will give this a try.

nsitu avatar May 07 '24 15:05 nsitu