繁体   English   中英

如何在 RecordRTC 屏幕录制中包含麦克风音频

[英]How to include mic audio in RecordRTC Screen Recording

我正在使用 RecordRTC 进行屏幕录制。

录音时如何包含我的麦克风音频?

我在下面使用 Angular 的代码:

  async startRecording() {
    let mediaConstraints = {
      video: {
      }, 
      audio: true
    };
    await this.mediaDevices.getDisplayMedia(mediaConstraints).then(this.successCallback.bind(this), this.errorCallback.bind(this));
  }

  successCallback(stream: MediaStream) {
    this.recording = true;
    var options = {
      mimeType: 'video/webm', // or video/webm\;codecs=h264 or video/webm\;codecs=vp9
      audioBitsPerSecond: 128000,
      videoBitsPerSecond: 128000,
      bitsPerSecond: 128000 // if this line is provided, skip above two
    };
    this.stream = stream;
    this.recordRTC = RecordRTC(stream, options);
    this.recordRTC.startRecording();
    let video: HTMLVideoElement = this.rtcvideo.nativeElement;
    video.src = window.URL.createObjectURL(stream);
    this.toggleControls();

  }

您需要将音轨附加到流

successCallback(stream){
    //your other code here
    //...

    navigator.mediaDevices.getUserMedia({audio:true}).then(function(mic) {
        stream.addTrack(mic.getTracks()[0]);
    });
    //
    this.recordRTC = RecordRTC(stream, options);
    this.recordRTC.startRecording();
}

这应该会有所帮助。 https://www.webrtc-experiment.com/RecordRTC/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM