I´m working in a blueprint that changes dynamically the video texture of a Static Mesh. All the videos have different resolutions and I need to rescale the static mesh to conserve the video original aspect ratio.
There is any way to get the original resolution of this videos (from the Media Player or the Media Texture) in blueprints? If you look in the Media Texture you can find these:
But i can´t find a way to get these info from a reference of the player or texture in a blueprint. Any idea?
You’re right, there’s currently no way to get this information in Blueprint, neither via UTexture nor via UMediaTexture.
I’m going to add BP functions like the ones in UTexture2D, and I will also add a delegate that will notify you if the media texture dimensions changed, so you don’t have to poll each tick. This won’t make it into 4.14, however, because we already branched.
Added UE-37241 for tracking
I added the following BP functions to UMediaTexture in CL# 3160746:
I decided to not add a script delegate for dimension changes at this time, because it would greatly complicate the current implementation.
Here are the changes in case you want to modify your Engine locally:
* Gets the current aspect ratio of the texture.
* @return Texture aspect ratio.
* @see GetHeight, GetWidth
float GetAspectRatio() const;
* Gets the current height of the texture.
* @return Texture height (in pixels).
* @see GetAspectRatio, GetWidth
int32 GetHeight() const;
* Gets the current width of the texture.
* @return Texture width (in pixels).
* @see GetAspectRatio, GetHeight
int32 GetWidth() const;
float UMediaTexture::GetAspectRatio() const
if (Resource == nullptr)
const FIntPoint Dimensions = ((FMediaTextureResource*)Resource)->GetSizeXY();
if (Dimensions.Y == 0)
return Dimensions.X / Dimensions.Y;
int32 UMediaTexture::GetHeight() const
return (Resource != nullptr) ? (int32)Resource->GetSizeY() : 0;
int32 UMediaTexture::GetWidth() const
return (Resource != nullptr) ? (int32)Resource->GetSizeX() : 0;
Thanks so much for this man. I will try to compile with these changes.