Search code examples
angularwebrtcrecordrtc

Webrtc conference call recording using recordrtc


I'm building new application using Angular 7 and WebRTC,and I use recordRTC.js to recording (audio&video) my issue is when I record multiple streams only audio of first stream is recorded.

public addStreamToRecorder(stream: MediaStream) 
{

  if (!this.recorder) 
     {
      this.recorder = RecordRTC([stream],{type: "video"});
      this.recorder.startRecording();
     } 
  else 
     {
      this.recorder.getInternalRecorder().addStreams([stream]);
     }
 }

after investigation i found that appendStreams function in reocrdrtc not mix audios


Solution

  • I fixed this issue by updating appendStreams function in recordRTC with latest version in i got it from MultiStreamRecorder (https://github.com/streamproc/MediaStreamRecorder)

    replace appendStreams in recordRTC with

    this.appendStreams = function (streams) {
        if (!streams) {
            throw 'First parameter is required.';
        }
    
        if (!(streams instanceof Array)) {
            streams = [streams];
        }
    
        arrayOfMediaStreams.concat(streams);
        streams.forEach(stream => {
            if (stream.getTracks().filter(function (t) {
                return t.kind === 'video';
            }).length) {
                var video = getVideo(stream);
                video.stream = stream;
                videos.push(video);
            }
    
            if (stream.getTracks().filter(function (t) {
                return t.kind === 'audio';
            }).length && this.audioContext) {
                var audioSource = this.audioContext.createMediaStreamSource(stream);
                audioSource.connect(this.audioDestination);
                self.audioSources.push(audioSource);
            }
        });
    };