我在将两个音轨合并成一个时遇到了问题,以便将整个合并后的音频添加到视频轨道中。
this.promises = [navigator.mediaDevices.getUserMedia({ audio: true, video: true })];
if (navigator['getDisplayMedia']) {
this.promises.push(navigator['getDisplayMedia'](this.streamConstraints));
}
else if (navigator.mediaDevices['getDisplayMedia']) {
this.promises.push(navigator.mediaDevices['getDisplayMedia'](this.streamConstraints));
}
else {
this.promises.push(navigator.mediaDevices.getUserMedia({ video: { mediaSource: 'screen' } as any }));
}
Promise.all(this.promises)
.then((streams) => {
// so here is the microphone audio and webcam video
const avTracks = streams[0].getTracks();
// here is the screen video and audio
const screenRecordTracks = streams[1].getTracks();
const firstAudioTrack = new MediaStream(avTracks).getAudioTracks();
const secondAudioTrack= new MediaStream(screenRecordTracks ).getAudioTracks();
// so here I want to merge these two audio tracks, and them to add this final track to the first video track like so..
const wholeRecord = new MediaStream(avTracks).getVideoTracks(); + the merged audio track
我该如何将它们合并成一条轨道,有人可以帮助我吗?