yusitnikov / fix-webm-duration

navigator.mediaDevices.getUserMedia + MediaRecorder create WEBM files without duration metadata. This library appends missing metadata section right to the file blob.
MIT License
248 stars 48 forks source link

Duration section is missing #19

Closed themire closed 1 month ago

themire commented 5 months ago

I've been getting the message [fix-webm-duration] Duration section is missing when trying to add this to my app. On the latest Chrome on desktop Mac. I've tried both methods but it doesn't add the duration.

I've played around with it a fair bit but can't get it to work. Any tips on what I might be doing wrong?

const options = {
  mimeType: this.mimeType, // audio/webm;codecs=opus
  bitsPerSecond: 64000, // For video-only recording
  audioBitsPerSecond: 64000, // For audio recording
  numberOfAudioChannels: 1, // Mono
  audioBitrateMode: "variable", // For variable bitrate
}

this.mediaRecorder = new MediaRecorder(this.stream, options)

this.mediaRecorder.onstop = (e) => {
  const blob = new Blob(this.chunks, { type: this.mimeType })

  ysFixWebmDuration(blob, 10000, (fixedBlob) => {
    console.log(fixedBlob, "after1")
  })

  ysFixWebmDuration(blob, 10000, { logger: true }).then((fixedBlob) => {
    console.log(fixedBlob, "after2")
  })
}

The log looks like

Blob {size: 38123, type: 'audio/webm;codecs=opus'} 
yusitnikov commented 5 months ago

Didn't test the library with audio-only files... I'll check it

TasseDeCafe commented 3 months ago

Also getting this error with recorded audio files. This isn't really a big issue because you can set logger:false, but I'm not sure why the duration is not being set correctly.

yusitnikov commented 1 month ago

"Duration section is missing" is not an error, it's just a debugging info. It means that the library will add the missing duration section after logging that. The logger could be silenced by providing logger: false option if the output is not desirable. I also could change the default logger from console.log to console.debug