How can i record streams from more than one canvas? ie, when i change one canvas to other it has to record the active canvas continue to the first.
I have done like this:
stream = canvas.captureStream();
mediaRecorder = new MediaRecorder(stream, options);
mediaRecorder.ondataavailable = handleDataAvailable;
mediaRecorder.start(10);
function handleDataAvailable(event) {
recordedBlobs.push(event.data);
}
But when adding another stream, only the first part is recorded. I'am pushing recorded data to a global array.
In the current implementations, you can't switch the recorded tracks of a MediaRecorder's stream.
When you try to do so, Firefox throws you in the console that
while Chrome keeps silent and records black frames instead of the second track...
Note that there is currently an open issue on the w3c github project mediacapture-record about this.
But, there is a simple workaround to this issue :
offscreen[hidden]*offscreen (the chrome bug is now fixed in latest 58 canary) canvas, only used for the recorder,This way, no problem ;-)
The same workaround could also be used to save different videos on the same MediaRecorder.