无法使用chrome.desktopCapture和RecortRTC使用扬声器+麦克风音频 [英] Can't get speaker + microphone audio working with chrome.desktopCapture and RecortRTC

查看:225
本文介绍了无法使用chrome.desktopCapture和RecortRTC使用扬声器+麦克风音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个Chrome扩展程序,以其扬声器音频(计算机音频)和麦克风音频捕获用户屏幕.使用RecordRTC的示例将以下内容拼凑在一起,但是当我打开录制的.webm文件时,我根本听不到任何声音.

I am trying to build a chrome extension that captures a users screen with their speaker audio (computer audio) and their microphone audio. Using the examples from RecordRTC I have pieced the below together, however when I open the recorded .webm file I am unable to hear any sounds at all.

我还应该做些其他事情来获取音频吗?

Is there something else I should be doing to get audio?

下面是我的后台脚本的代码,其中一些部分已删除,以使其更加清晰.当某人单击开始记录按钮时,将调用startRecording()函数.

Below is the code for my background script with some sections removed to make it more clear. When someone clicks the start record button, the startRecording() function is called.

const OPTIONS = {
  type: 'video',
  disableLogs: false,
  mimeType: 'video/webm'
}

const captureUserMedia = callback => {
  chrome.desktopCapture.chooseDesktopMedia(['screen', 'window', 'audio'], chromeMediaSourceId => {
    const options = {
      audio: {
        mandatory: {
          chromeMediaSource: 'desktop',
          chromeMediaSourceId: chromeMediaSourceId,
          echoCancellation: true
        },
        optional: []
      },
      video: {
        mandatory: {
          chromeMediaSource: 'desktop',
          chromeMediaSourceId: chromeMediaSourceId
        },
        optional: []
      }
    };
    navigator.mediaDevices.getUserMedia(options)
      .then(callback)
      .catch(err => new Error(err));
    });
};

const startRecording = () => {
  captureUserMedia(mediaStream => {
    state.recordData = RecordRTC(mediaStream, OPTIONS);
    state.mediaStream = mediaStream;
    state.recordData.startRecording();
  });
}

const stopRecording = () => {
  state.recordData.stopRecording(function(videoURL) {
    chrome.tabs.create({ url: 'show-video.html?video=' + videoURL });
  });
  state.mediaStream.getTracks().forEach(track => track.stop());
}

推荐答案

显然,这不是bug,而是MacOS本身的问题. Chrome知道了它,但似乎没有任何修复它的计划:

Apparently this is not a bug and an issue with MacOS itself. Chrome are aware of it but don't seem to have any plans to fix it: bugs.chromium.org/issue/603259

这篇关于无法使用chrome.desktopCapture和RecortRTC使用扬声器+麦克风音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆