I want to record local and remote stream at the interval of 2 seconds and upload it to the server with Ajax. But the problem is, the method ondataavailable is called twice so the same video is uploaded to the server twice. The first video is playable and proper, while the rest of the videos are either corrupted or very small (less than one second). The size of all the videos is almost the same!
I've tried with MediaRecorder API also but the problem is the same. I've tried with 5 seconds of the interval but still no luck!
This is how I get the local stream:
navigator.mediaDevices.getUserMedia({
video: false,
audio: true
}).then(function (myStream) {
localStream = myStream;
localStream.getTracks().forEach(function (track) {
yourConn.addTrack(track, localStream);
});
}).catch(function (error) {
streamAdded = false;
console.warn('Could not detect microphone');
return false;
});
This is how I perform recording:
yourConn.ontrack = function (e) {
remoteVideo.srcObject = e.streams[0];
let recorder = RecordRTC([localStream, e.streams[0]], {
mimeType: 'video/webm;codecs=h264',
type: 'video',
timeSlice: 5000,
ondataavailable: function(blob) {
uploadBlob(blob);
},
});
recorder.startRecording();
}
uploadBlob function:
var formData = new FormData();
formData.append('recorded_file', mp4File);
$.ajax({
url: myURL,
data: formData,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function (response) {
console.log(response);
}
});
How can I record both the streams without any issues?
Index:269 Uncaught ReferenceError: callInfo is not defined
error on!callInfo.isCallActive
. May you please suggest a quick fix? I have already searched the issue online with no success. – Fagin