MediaStreamRecorder icon indicating copy to clipboard operation
MediaStreamRecorder copied to clipboard

ondataavailable called twice

Open acroca opened this issue 8 years ago • 9 comments

Hi,

Sometimes the callback mediaRecorder.ondataavailable is being called twice. Is this expected? If so, what's the recommended way to handle it?

I'm using chrome 51.0.2704.84 on mac, if that helps.

So far this is just a testing page, but here some of the code:

<button id="b1" onclick="mediaRecorder.start(DT);">start</button>
<button id="b2" onclick="mediaRecorder.stop();">stop</button>
var mediaRecorder;
navigator.getUserMedia({audio: true, video: true}, function(stream){
  mediaRecorder = new MediaStreamRecorder(stream);
  mediaRecorder.mimeType = 'video/webm';
  mediaRecorder.ondataavailable = function(blob) {
    console.log('blob: ', blob);
  };
}, function(err) {
  console.error(err);
});

acroca avatar Jun 20 '16 17:06 acroca

What version did you use @acroca ?

noahjerreel avatar Jun 21 '16 02:06 noahjerreel

1.3.2 from npm

acroca avatar Jun 21 '16 14:06 acroca

Tried 1.2.9 and doesn't seem to be happening.

acroca avatar Jun 21 '16 22:06 acroca

Looking at the code I've found this: https://github.com/streamproc/MediaStreamRecorder/blob/62ab10e75c3b6d64160f0c263c2be9ff656e5ee1/AudioStreamRecorder/MediaRecorderWrapper.js#L93

The blobs I'm getting have a size of around 300. Maybe ignoring blobs smaller than ~500 would make sense? What's the reason of using 100?

acroca avatar Jun 22 '16 00:06 acroca

I'm not sure if 1.3.2 is stable enough? @muaz-khan

If you want to ignore blobs less than 500, then you can manipulate it on your end. But I think, @muaz-khan returns any possible / useable audio blobs. 100 could be a second on your recording.

noahjerreel avatar Jun 22 '16 00:06 noahjerreel

I think 1.2.9 works because it uses Whammy instead of MediaRecorderWrapper.

acroca avatar Jun 22 '16 16:06 acroca

Any update on this issue I am facing the same issue

vignestion avatar Jul 01 '19 15:07 vignestion

I am facing the same issue in v 1.3.4 MultiStreamRecorder

ykmo-VIRNECT avatar May 21 '20 06:05 ykmo-VIRNECT

Hi, I have the same issue. Does anyone resolve it?

t104360088 avatar Aug 02 '21 09:08 t104360088