navigator.mediaDevices.getUserMedia视频质量和面临模式限制

时间:2017-08-25 06:58:28

标签: javascript html webrtc

我无法一起指定视频质量面向相机约束。 有没有办法结合以下约束?

{
  audio: true,
  video: { width: 1280, height: 720 }
}

{ audio: true, video: { facingMode: "user" } }

1 个答案:

答案 0 :(得分:2)

navigator.mediaDevices.getUserMedia({audio:true,video:getConstraints(1280,720)})

function getConstraints(videowidth, videoheight) {
constraints = {
              facingMode: { exact: "environment" },
              width: { min: videowidth, ideal: videowidth, max: videowidth},    
              height: { min: videoheight, ideal: videoheight, max: 
              frameRate : {min: 5, max: 8 }
              };

return constraints;
}