title: Getting width and height of html video stream in js
body: <p>I'm trying to get width and height of video stream in html and js and it returns always zero, I dont want specify width and height in video tag, and always have what natural device video width and height is then check it's height and width is js, heres the code :</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;Title&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;video autoplay=&quot;true&quot;&gt;&lt;/video&gt;
  &lt;script&gt;
      let video = document.querySelector(&quot;video&quot;)
      navigator.mediaDevices.getUserMedia({video: true})
          .then((stream) =&gt; {
              video.srcObject = stream
          })
  
      function vid() {
          let vidCheck = document.querySelector(&quot;video&quot;)
          console.log(vidCheck.videoWidth) // returns 0
          console.log(vidCheck.videoWidth)//returns 0
      }
  
      vid()
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>