我正在用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();
}发布于 2021-11-12 17:23:40
您需要将音轨附加到流
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://stackoverflow.com/questions/69946060
复制相似问题