I am testing Videoplayer. I am trying to write a script to make Videoplayer load video from url and put video on RawImage so I am using RenderTexture on Videoplayer.
In order to create RenderTexture with correct size (resoloution) , anyone know how to check video resolution , which if from url ?
I’m having the same issue. The only workarround I found so far is:
- prepare the video
- Get the size from the internal texture (videoplayer.texture.width/height) on prepareCompleted
- Create a new render texture
- Assign render texture to videoplayer and material
It’s not really a neat solution as it involves starting the player, but this is the only time the information is available it seems to me.
Maybe there is a way to get meta info from a file someway, but I have yet to find it.
Therefore the answer from gilead did’t worked for me, here is another working one:
VideoPlayer videoPlayer = GetComponent<VideoPlayer>();
Texture vidTex = videoPlayer.texture;
float videoWidth = vidTex.width;
float videoHeight = vidTex.height;
via: c# - Accessing dimensions (width/height) from a VideoPlayer source URL - Stack Overflow