WebRTC视频约束不起作用 [英] WebRTC video constraints not working

查看:386
本文介绍了WebRTC视频约束不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从网络摄像头中获得较低的分辨率

I'm trying to get a lower resolution from the webcam

navigator.getUserMedia({audio: true, 
    video: {
        "mandatory" : {maxWidth : 320},
        "optional" : []
    }
}, function(stream) {
    videoElement.src = URL.createObjectURL(stream);
}, function(error) {console.log(e)});

一切正常,但是videoElement.videoWidth仍然是640.无论我指定的视频限制是什么,这都是相同的.这仅在Firefox中发生,在Chrome中一切正常.

Everything works fine, but videoElement.videoWidth is still 640. This is the same whatever video constraints I specify. This is happening only in Firefox, in Chrome everything works fine.

有人知道为什么吗?

我也尝试指定maxFrameRate,但这也被忽略.我也尝试了不使用optional以及也使用maxHeight.

I also tried specifying maxFrameRate, but this is also ignored. I also tried without optional and with maxHeight too.

推荐答案

Firefox中有许多错误正在处理中,因为它不支持可编程的视频帧速率和分辨率更改.

There are numerous bugs that are being handled in Firefox for it not supporting programable video framerate and resolution changes.

  • Allowing the framerate to be changed in the media constraints
  • Support runtime change of video resolution
  • Support plain numbers for the video resolution in the media constraints

您应该可以通过以下方式设置约束:

You are supposedly able to set the constraints this way:

mediaConstraints = {
      "audio": true,
      "video": {
         width: {
             min: 320,
              max: 320
          },
          height: {
             min: 240,
              max: 240
          } }
    };

但是我一直无法获得视频分辨率限制,因此无法通过媒体限制使其在Firefox中正常工作.在firefox中更改about:config中的默认分辨率时,我获得的成功有限.

But I have never been able to get video resolution constraints to work it to work in Firefox through media constraints. I have had limited success with changing the default resolution in about:config in firefox.

这些问题是众所周知的,我相信许多人正在努力解决这些问题.

These issues are known and I believe that numerous people are working on them to get them resolved.

这篇关于WebRTC视频约束不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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