How to get camera video texture size or resolution?

I couldn’t find an answer for this on the forum (hope is not repeated!). I wonder if is possible to get the native camera video texture size on Three.js.

Maybe something like this(?):

var video = document.getElementById( 'video' );    
var videoTexture = new THREE.VideoTexture( video );
var videoWidth = videoTexture.width; // or like this: videoTexture.image.width
var videoHeight = videoTexture.height; // or like this: videoTexture.image.height

It would be useful to have such property (if it doesn’t exist already). By getting the native width and height you can calculate the aspect ratios or made proper assumptions about image quality.

You can use the properties videoWidth and videoHeight of the HTML5 video element in order to read the dimensions of the video. But you have to work with the loadedmetadata event, otherwise you won’t read valid data. In some browsers, it’s obviously necessary that the video is playing.


More information:

1 Like

Oh, you are right. I didn’t thought about the video tag!

Thank you for explaining this @Mugen87, it works perfectly.