使用Tabcapture API捕获音频和视频

时间:2015-01-22 11:48:24

标签: google-chrome-extension webrtc

我正在构建一个chrome扩展程序,可以记录特定标签的会话(会话包括音频和视频),为此我使用 tabcapture api 来获取标签会话的流,这个然后使用MRecordRTC记录流 ,我比在本地机器上保存该录音(音频和视频作为单独的文件)视频文件确定,但音频文件非常扭曲,听起来像一个气泡的声音。下面是manifest.json和我用来记录会话的background.js文件的一部分

的manifest.json

{
  "manifest_version": 2,  

  "name": "tabcap",
  "description": "This extension captures the session of selected tab.",
  "version": "1.0",

  "permissions": [
    "tabCapture",
    "activeTab",
    "http://localhost:1615/*"
  ],  

  "browser_action": {
    "default_icon": "icon42.png",
    "default_icon": "icon64.png"
    },

  "content_scripts": [
    {
      "matches": ["http://localhost:1615/*"],
      "js": ["jquery-1.6.1.min.js","myscript.js",]
    }
  ],

  "background":{
  "scripts": ["jquery-1.6.1.min.js","recordrtc.js","background.js"]
 }

}

background.js

var recorder = new MRecordRTC();
function handleCapture(stream) {
recorder.addStream(stream);
recorder.mediaType = { video: true, audio: true };
recorder.startRecording();
}

var MediaStreamConstraint = {
audio: true,
video: true,
videoConstraints: {
    mandatory: {
        chromeMediaSource: 'tab',
        minWidth: 1920,
        maxWidth: 1920,
        minHeight: 1080,
        maxHeight: 1080
    }
}
};

function captureCurrentTab() {
chrome.tabCapture.capture(MediaStreamConstraint, handleCapture);
}

function stopCapturing() {
// stops the recording and save audio and video     
}

测试 tabcapture api

时的其他一些发现
  • 捕获标签时无法听到嵌入音频。
  • 如果仅使用tabcapture api录制音频,则保存的文件不会失真并且听起来不错

    我的manifest.jon文件中是否缺少某些内容,或者我没有按照正确的 tabcapture api序列

0 个答案:

没有答案