streamproc / MediaStreamRecorder

Cross browser audio/video/screen recording. It supports Chrome, Firefox, Opera and Microsoft Edge. It even works on Android browsers. It follows latest MediaRecorder API standards and provides similar APIs.
https://www.webrtc-experiment.com/msr/
MIT License
2.62k stars 563 forks source link

Intermittent Blobs are missing when Interval is set to 100ms and cpu load is high #147

Open jsrawan-mobo opened 6 years ago

jsrawan-mobo commented 6 years ago

I've been using the StereoAudioRecorder and i have set the interval to 100ms.

self.mediaRecorder = new MediaStreamRecorder.StereoAudioRecorder(audioStream);
self.mediaRecorder.mimeType = 'audio/wav';
self.mediaRecorder.audioChannels = 1;

This works reasonably well in most cases, the ondataavailable gets called appropriately :

Recieved Blobs: 100 audio_segment total_size(bytes): 1182500 avg_size: 11825 last size: 11006 in Total_Seconds: 0
16:16:10.905 video_index.jsx:71 Recieved Blobs: 200 audio_segment total_size(bytes): 1187960 avg_size: 11879.6 last size: 11006 in Total_Seconds: 10
16:16:20.905 video_index.jsx:71 Recieved Blobs: 300 audio_segment total_size(bytes): 1182500 avg_size: 11825 last size: 11006 in Total_Seconds: 10
16:16:30.905 video_index.jsx:71 Recieved Blobs: 400 audio_segment total_size(bytes): 1182500 avg_size: 11825 last size: 11006 in Total_Seconds: 10
16:16:40.905 video_index.jsx:71 Recieved Blobs: 500 audio_segment total_size(bytes): 1187960 avg_size: 11879.6 last size: 11006 in Total_Seconds: 10
16:16:50.905 video_index.jsx:71 Recieved Blobs: 600 audio_segment total_size(bytes): 1182496 avg_size: 11824.96 last size: 11006 in Total_Seconds: 10

However, i've noticed on some lower power laptops (i.e Macbook Air), the ondatavailable gets delayed and ultimately i hear "popping" in the audio, which usually means packets are missing

See logs below, its taking longer to acquired 100 packets (greater then 10s) and also data seems to be missing

Recieved Blobs: 700 audio_segment total_size(bytes): 1182500 avg_size: 11825 last size: 11006 in Total_Seconds: 10.049999952316284
16:17:11.038 video_index.jsx:71 Recieved Blobs: 800 audio_segment total_size(bytes): 1198836 avg_size: 11988.36 last size: 11006 in Total_Seconds: 10.083000183105469
16:17:21.245 video_index.jsx:71 Recieved Blobs: 900 audio_segment total_size(bytes): 1209776 avg_size: 12097.76 last size: 11006 in Total_Seconds: 10.206999778747559
16:17:31.559 video_index.jsx:71 Recieved Blobs: 1000 audio_segment total_size(bytes): 1198848 avg_size: 11988.48 last size: 16466 in Total_Seconds: 10.314000129699707

In this same environment, i can run RecordRTC, and i get back the audio file back perfectly if i don't stream it. I used timeslice of 100ms to mimic what MSR is doing

const options = {
    type: 'audio',
    mimeType: 'audio/wav',
    leftChannel: false,
    disableLogs: true,
    sampleRate: 44100,
    bufferSize: 4096,
    recorderType: RecordRTC.StereoAudioRecorder,
    numberOfAudioChannels: 1,
    ignoreMutedMedia: 1,
    timeSlice: 100
};

To reproduce Go to chrome debug tools->performance->cpu throttle->20x