getUserMedia / RecordRTC性能问题在720p

时间:2014-08-07 14:26:34

标签: javascript webrtc getusermedia

我正在使用RecordRTC脚本录制视频/音频。

一切都很好,直到我需要720p。

如果您访问RecordRTC网站并为视频和画布选项选择1280x720,则与较小尺寸(预期)相比,您会发现速度相当慢。

如果我只录制视频,它可以完美运行,但我需要两者。

$('.btn.record').on('click',function() {
!window.stream && navigator.getUserMedia(
  {
    audio: true,
    video: {
      optional: [],
      mandatory: {
        minWidth: 1280,
        minHeight: 720,
        maxWidth: 1280,
        maxHeight: 720,
        minAspectRatio: 1.7777777778,
        maxAspectRatio: 1.7777777778,
      }
    }
  },
  function(stream) {
    window.stream = stream;
    onstream();
  },
  function(error) {
    alert(error);
  }
);

window.stream && onstream();

function onstream() {
    preview.src = window.URL.createObjectURL(stream);
    preview.play();
    preview.muted = true;

    recordAudio = RecordRTC(stream, {
        onAudioProcessStarted: function() {
            if(!isFirefox) {
                recordVideo.startRecording();
            }
        }
    });

    recordVideo = RecordRTC(stream, {
        type: 'video',
        video: {
          width: 1280,
          height: 720
        },
        canvas: {
          width: 1280,
          height: 720
        }
    });

    recordAudio.startRecording(); // DISABLE THIS AND VIDEO IS PERFECT
}

1 个答案:

答案 0 :(得分:0)

尽可能使用<canvas>宽度/高度; 320*240是建议值:

recordVideo = RecordRTC(stream, {
    type: 'video',
    video: {
        width: 1280, // redundant because offsetWidth/videoWidth   will be 1280
        height: 720  // redundant because offsetHeight/videoHeight will be 720
    },
    canvas: {
        width: 320,   // suggested width
        height: 240   // suggested height
    }
});