samhirtarif/react-audio-recorder

Corrupt "mp3" audio is really webm

theDanielJLewis opened this issue · 7 comments

Using the sample code, when I set downloadFileExtension="mp3", something is downloaded with a .mp3 file extension, but it's not an MP3. Attempting to play it yields only a loud corrupt sound.

The file is actually still a .webm and changing the extension to .webm makes it playable.

So what's the point of setting the extension to MP3 or WAV if it doesn't actually give an MP3 or WAV? Or is this simply broken?

@theDanielJLewis - That is strange, this is something I had thoroughly tested. Thanks for bringing this up though.
Could you please share which browser and OS you were using when this happened?

I guess I was wrong in assuming the downloaded files actually are mp3 and wav just because they played successfully on windows, android and iOS. They are indeed in webm format, despite creating a new blob with the appropriate audio mime type for downloading.
I'll have to spend some time on this.

I'm guessing it's simply because that's how modern browsers now capture audio.

That I now know it records only in webm means I can find a way to handle the conversion to MP3. In my use case, the audio will be downloaded by someone other than the person who records it.

Ah, I see. Sorry for the trouble caused.
I would be interested in knowing if you use some existing package/library for the webm to mp3 conversion.

Fixed by Pull request #59
Would require the website to be cross-origin isolated. Otherwise, only webm format can be downloaded

@samhirtarif can you include an example of how to make say my website built in say Next JS, cross-origin isolated?

@samhirtarif can you include an example of how to make say my website built in say Next JS, cross-origin isolated?

https://vercel.com/guides/fix-shared-array-buffer-not-defined-nextjs-react