I am using MediaRecorder to record the screen on a browser.
At the end of the session the video is uploaded to the server.
To make the process more error-proof I would like to upload partial videos on intervals instead of only one big file at the end.
I have tried something like this:
const handleRecord = function ({stream}) {
const mediaRecorder = new MediaRecorder(stream);
mediaRecorder.ondataavailable = function (e) {
uploadVideoPart(e.data); // Upload to server
};
mediaRecorder.start(10000); // 10 seconds
};
But the upload videos are corrupted.
The first one is possible to be reproduced but there is warning:
[matroska,webm @ 0x7fa5e580ec00] File ended prematurely at pos. 1060573 (0x102edd)
The rest of the videos are totally corrupted.
Looks like there is a special blob at the beginning and at the end that prevents me to do upload partial videos.
How can I handle partial videos using MediaRecorder
?