【问题标题】:Configure Frame Format using getUserMedia API使用 getUserMedia API 配置帧格式
【发布时间】:2018-10-11 11:22:13
【问题描述】:

我有以下代码可以在我的 Google Chrome 浏览器中流式传输连接的视频源。 WebRTC 的getUserMedia 就是这样做的。以下代码 sn -p 用于配置我的外接摄像头设备的分辨率和帧率。

function configureVideo()
{
      const video_constraints ={};

      //Create the following keys for Constraint
      video_constraints.video = {};

      //set camera name
      video_constraints.video.deviceId = {};
      video_constraints.video.deviceId.exact = <device_id_comes_here>

      //set resolution Width
      video_constraints.video.width = {};
      video_constraints.video.width.exact = 640;

      //set resolution height
      video_constraints.video.height = 480;
      video_constraints.video.height.exact = streamHeight;

      //set fps
      video_constraints.video.frameRate = 60;
      video_constraints.video.frameRate.exact = streamFps;

      console.log("Selected Contraints is :", video_constraints);

      navigator.mediaDevices.getUserMedia(video_constraints).then(streamCallback).catch(handleError);
}

是的,我成功地能够从我的外部相机设备流式传输视频。相机提供 2 种帧格式 YUYV 和 BY8。但我真的不知道目前正在流式传输什么帧格式。

有什么方法可以在 WebRTC 中配置我感兴趣的视频帧格式。

【问题讨论】:

  • 谁能帮我解决这个问题。我仍在寻找解决方案。
  • 我在下面添加了一个答案。希望对你有帮助

标签: javascript video-streaming webrtc getusermedia


【解决方案1】:

回答您的问题“有什么方法可以在 WebRTC 中配置我感兴趣的视频帧格式。”答案是否定的……这很令人沮丧!

您必须获取流并将其渲染到画布以获取数据,然后进行转换...这主要是由于 MediaCapture 的功能和框架可能经历的转换(取决于浏览器实现) .您可以使用ImageCapture 来获得更多相机属性(并将其作为ImageBitmap 获得),但现在的支持非常薄弱。

请阅读下面我的答案,其中更深入地了解 MediaCapture 和 ImageCapture 的用例以获取更多信息。

Why the difference in native camera resolution -vs- getUserMedia on iPad / iOS?

Take photo when the camera is automatically focused

【讨论】:

  • 感谢您对这个问题的贡献。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-28
  • 1970-01-01
  • 2018-05-11
相关资源
最近更新 更多