0

i'm using Mediastream Recording and GetUserMedia to record audio and video from user's webcam. I couldn't find where the temporary video is stored. I want to know that to detect if there will be storage problems when recording a lot of content or if it will be stored in local in some way.

Thank you in advice.

Raúl Pérez López
  • 538
  • 1
  • 5
  • 14

1 Answers1

1

Just like any data your web page will deal with, it is not stored per se, only some live memory is being assigned the data.

From web APIs you can't know how much memory is available, even though, since you have to store the chunks gotten from MediaRecorder.ondataavailable event, you might know how much data is being used:

const canvas = document.createElement('canvas');
canvas.getContext('2d').fillRect(0,0,1,1);
const stream = canvas.captureStream(30);
const chunks = [];
const recorder = new MediaRecorder(stream);
recorder.ondataavailable = e => {
  chunks.push(e.data);
  updateCounts();
};
recorder.start(10);

function updateCounts(){
  _log.textContent = chunks.map(blob=>blob.size).reduce((sum, size)=>sum+size) + ' bytes';
}
<pre id="_log"></pre>
Kaiido
  • 123,334
  • 13
  • 219
  • 285