Webrtc - Get Webcam Aspect Ratio

I am trying to learn how to develop webRTC applications, and I would like to know if it is possible to get the camera aspect ratio ... (I do not know if this helps, but I use webrtc.io, but if it is better, I could stop using his)

+5
source share
3 answers

Since you access the camera through an element <video>, you must use the attributes videoWidthandvideoHeight to calculate the aspect ratio. These values ​​reflect the actual size of the source media stream and may differ from the attributes widthand the heightitem <video>displayed on the page.

This approach seems to work well in Chrome and Firefox Nightly.

+2

, , , / .

, IIRC.

w3.org

0

From MDN you can get the current video stream aspectRatiofrom MediaTrackSettingsby calling:

stream.getVideoTracks()[0].getSettings().aspectRatio
0
source

All Articles