I'm trying to learn how to develop webRTC applications and I would like to know whether you can get a camera's aspect ratio... (I don't know if it helps, but I'm using webrtc.io, but -if it's better- I could stop using it)
From MDN, you can get the current video stream's aspectRatio
from MediaTrackSettings
by calling:
stream.getVideoTracks()[0].getSettings().aspectRatio
Since you are accessing the camera through a <video>
-element, you should use the videoWidth
and videoHeight
attributes to calculate the aspect ratio. These values reflect the actual dimensions of the source mediastream and can differ from the width
and height
attributes of the <video>
element as rendered on the page.
This approach seems to work well in Chrome and Firefox Nightly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With