1

I have the following code to stream connected Video Source in my Google Chrome Browser. getUserMedia of WebRTC does this. The following code snippet is to configure Resolution and frame Rate of my external camera device.

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);
}

And yes i was successfully able to stream the video from my external Camera device.The camera provides 2 types of Frame Format YUYV and BY8. But i truly don't have any idea what Frame Format is streaming currently.

Is there any method to configure my interested Video Frame Format in WebRTC.

vgokul129
  • 777
  • 12
  • 31

1 Answers1

5

To answer your question "Is there any method to configure my interested Video Frame Format in WebRTC." The answer is no... and that is quite frustrating!

You must take the stream and render it to a canvas to get the data and then do the conversions... This is primarily due to how MediaCapture functions and the transformations the frame may go through (depending on browser implementation). You can use ImageCapture to gain more camera properties (and to get it as an ImageBitmap) but support right now is very weak.

Please read my answers below which goes into more depth on MediaCapture and ImageCapture for their use cases for more information.

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

Take photo when the camera is automatically focused

Marcus
  • 1,880
  • 20
  • 27