muaz-khan / RecordRTC

RecordRTC is WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows.
https://www.webrtc-experiment.com/RecordRTC/
MIT License
6.61k stars 1.76k forks source link

record media local+ remote #405

Open ghost opened 6 years ago

ghost commented 6 years ago

Is it possible to record both remote and local video+audio at a time to node js folder

muaz-khan commented 6 years ago
var recorder = RecordRTC([localStream], {
    type: 'video'
});

recorder.startRecording();

// now call "appendRemoteVideo" whenever you have remote video
function appendRemoteVideo(stream) {
    recorder.getInternalRecorder().addStreams([stream]);
}

First Step

Pass array of streams to RecordRTC. E.g.

var recorder = RecordRTC([localStream], {
    type: 'video'
});

Second & Last Step

Call getInternalRecorder method to access MultiStreamRecorder which has addStreams method:

peer.onaddstream = function(event) {
     recorder.getInternalRecorder().addStreams([event.stream]);
};
huhaibing commented 6 years ago

image recorder.getInternalRecorder() don't have the property 'addStreams' image

giorgioma commented 6 years ago

Just came across the same issue while using MRecordRTC, I used: recorder.videoRecorder.getInternalRecorder().addStreams([stream]); I don't know if it's the same for RecordRTC

muaz-khan commented 6 years ago

For RecordRTC

recorder.getInternalRecorder().addStreams([stream]);

For MRecordRTC

recorder.videoRecorder.getInternalRecorder().addStreams([stream]);
lcavero commented 6 years ago

Hi, I am using MRecordRTC and I can't add more streams, I need some help, please

controller.onLocalStream = function (stream){
recorder = new MRecordRTC();
recorder.mediaType = {
      audio: true, // or StereoAudioRecorder
      video: true, // or WhammyRecorder
};
recorder.mimeType = {
      audio: 'audio/wav',
      video: 'video/webm',
};
// This works
recorder.addStream(stream);

recorder.startRecording();

// This not works, Error recorder.videoRecorder.getInternalRecorder().addStreams is not a function (yes, I know I am adding the same stream one more time, it's just a test)
recorder.videoRecorder.getInternalRecorder().addStreams([stream]);
}

If I "console.log" my recorder.videoRecorder.getInternalRecorder() object, I get:

MediaStreamRecorder blob: null clearRecordedData: ƒ () getAllStates: ƒ () getArrayOfBlobs: ƒ () getInternalRecorder: ƒ () getState: ƒ () name: "MediaStreamRecorder" pause: ƒ () record: ƒ () resume: ƒ () stop: ƒ (callback) timestamps: [] toString: ƒ () proto: Object

Thanks for any help

rahimmashkraft commented 1 year ago

Use RecordRTC function MultiStreamRecorder, this will be work.

let options = {

mimeType: 'video/mp4', }; let arrayOfStreams = [this.localStream.data, this.remoteStream.data]; this.recorder = new RecordRTC.MultiStreamRecorder(arrayOfStreams, options); this.recorder.record();