ffmpegwasm / ffmpeg.wasm

FFmpeg for browser, powered by WebAssembly
https://ffmpegwasm.netlify.app
MIT License
13.46k stars 776 forks source link

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

Open CrypticSignal opened 9 months ago

CrypticSignal commented 9 months ago

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:

Sean-Der commented 9 months ago

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

Sean-Der commented 9 months ago

If not I am going to do that now

CrypticSignal commented 9 months ago

@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).

doubledare704 commented 6 months ago

On v0.12.4 is the same problem

AX9999AX commented 2 months ago

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

AX9999AX commented 2 months ago

@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.

teropa commented 2 months ago

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.

nsitu commented 1 month ago

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.

teropa commented 1 month ago

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

Screenshot 2024-05-07 at 18 02 15
nsitu commented 1 month ago

Thanks @teropa , I will give this a try.