How to set a UMediaTexture to not stretch in UMG

I’m trying to render a UMediaTexture to a UImage in UMG, and I’d like behavior similar to the MatchSize value in SetBrushFromTexture.

For example, if I have a square UImage and a rectangular UTexture2D, I can do:

  myUMGImage->SetBrushFromTexture(myTexture2D, false);

to make sure that my texture does not stretch to fit the UImage.

However, I can’t do the same with UMediaTexture.

The recommended way to assign a UMediaTexture to a UImage is with a UMaterial:

   UMaterial* material = NewObject<UMaterial>();
   UMaterialInstanceDynamic* DynamicMaterial = UMaterialInstanceDynamic::Create(material, this);
   DynamicMaterial->SetTextureParameterValue("MediaTexture", myMediaTexture);
   UTexture* TextureParameter;

   if (!DynamicMaterial->GetTextureParameterValue(FHashedMaterialParameterInfo(TEXT("MediaTexture")), TextureParameter)) {
       UE_LOG(LogTemp, Warning, TEXT("Failed to get texture parameter"));
   }

   FSlateBrush Brush;
   Brush.TintColor = FLinearColor::White;
   Brush.SetResourceObject(TextureParameter);
   mMediaImage->SetBrush(Brush);

But using SetBrush does not give me a MatchSize option.

I saw that UMediaTexture inherits from UTexture, but I can’t seem to find a way to cast a UMediaTexture to a UTexture2D so that it can be used with SetBrushFromTexture().

What would be the best way to get the desired behavior?