closeio / mic-recorder-to-mp3

Microphone Recorder to mp3
MIT License
238 stars 130 forks source link

Chrome on Windows 10 vs Chrome on iOS #22

Open jdmacmurtrie opened 4 years ago

jdmacmurtrie commented 4 years ago

Hello! Thank you for this package, I've found it extremely useful. I have a very specific question for you.

Have you ever experienced any difficulties in using the recorder in Chrome on a Windows 10 vs on a Mac (Catelina 10.15.5)?

I've implemented the recorder as instructed:

Mp3Recorder.stop()
    .getMp3()
    .then(([, blob]) => {
        const audioSrc = URL.createObjectURL(blob);

        this.setState(() => ({ audioSrc }));
    })

I then pass the audio to the HTML audio element:

<audio ref={audio => (this.audio = audio)} src={audioSrc} />

and get the metadata, specifically the duration, through an event listener:

this.audio.addEventListener('loadedmetadata', e => this.loadMetaData(e));

loadMetaData(e) {
  const { duration } = e
  ...
}

The issue is, when I record for one minute on a Mac, the duration ends up being 59.712 seconds, whereas when I record in chrome on a Windows, the duration is 56.189.

I can't figure out if this is a side effect of the audio element, or if it has something to do with the original audioSrc. Have you ever experienced anything like this?

buzinas commented 3 years ago

Honestly I don't have a Windows machine, so I've never tested it there.

alectrocute commented 3 years ago

I've run into this bug; I've always thought maybe it's to do with a misconfiguration of sample rate and/or sample size. Still haven't pinned it down. Will update this comment if/when I find.