Cannot Encode mp3s above ~3MB
jamesstaub opened this issue · 2 comments
I cannot seem to successfully encode large mp3s. I was able to encode a buffer of around 2500000 samples, but once I try a buffer over 10000000 samples I get the following error
Uncaught (in promise) Error: Error while encoding -1
at M.encode (index.js?2521:1)
at eval (nf-webaudio.js?5ee4:2009)
Which seems to be due to this.module.enc_encode(this.ref, pcm[0].length);
returning -1
in encoder.ts
.
Please advise if there are any strategies for handling larger mp3s. I am more or less using the exact implementation of createMp3Encoder
from the readme with sample rate 44100 2 channels and 128 bitrate. The error happens the first time encoder.encode(pcmChannels)
is called.
This does not seem to be a problem for the oggvorbis encoder. It worked fine on much larger mp3s with the same settings.
Thanks for reporting. I've published version 0.6.4
which hopefully will fix this issue. Please try it out and let me know.
As a workaround for the older library versions, you can break up your input buffer into chunks smaller than 2500000 samples and call encode()
multiple times, reassembling the returned buffers afterwards.