UnityPlugin-AVProVideo icon indicating copy to clipboard operation
UnityPlugin-AVProVideo copied to clipboard

[Windows] Flipped texture and Performance drop when playing 240 FPS videos

Open tomashined opened this issue 1 month ago • 15 comments

Unity version

Unity 6000.2.11f1

Unity editor platform

Windows

AVPro Video edition

Core

AVPro Video version

2.9.3

Device hardware

iPad 10th

Which iOS version are you using?

26.0.1

Texture format

BGRA

Audio output

System Direct

Any other Media Player component configuration required to reproduce the issue.

No response

Which output component(s) are you using?

Resolve to RenderTexture

Any other component configuration required to reproduce the issue.

No response

The issue

Hello. I’m still using AVPro Video – Core Edition (2.9.3 · March 11, 2024). I’m experiencing the following issues when playing videos:

  1. Although the orientation appears correct in your MediaPlayer, the actual Texture is flipped, so I have to use “Resolve To RenderTexture,” as you suggested here. However, this consumes significant resources, which heavily impacts performance because...

  2. My videos play at 240 FPS, and when I either press Play or perform a Seek, the frames take a long time to load.

I need to receive the Texture (ideally a Texture2D) directly from your MediaPlayer in the correct orientation, and I also need smooth 240 FPS playback without freezes. I’m working and testing on both Windows/Mac Editor and iPadOS. Has this issue been fixed in the current 3.3.3 version so I can decide whether it’s worth upgrading?

Media information

No response

Log output


tomashined avatar Nov 11 '25 17:11 tomashined

I'd suggest testing using the free trial version, to make sure you are testing the exact same thing.

Chris-RH avatar Nov 11 '25 17:11 Chris-RH

I'd suggest testing using the free trial version, to make sure you are testing the exact same thing.

I’ve tested different combinations of AVPro Video Core 2.9.3 and Trial 3.3.3 with Unity 6 and Unity 6.2 using 240 FPS videos. In my main app, playback stutters occasionally, while in an empty test scene (where only the video is played) it usually runs smoothly — although there are still cases where the video visually lags, even though the playback time continues to advance without interruption.

Regarding the flip issue, I found that mediaPlayer.TextureProducer.RequiresVerticalFlip() indicates whether the video texture is upside down. In my case, it always reports that the texture is flipped, even though the video itself — both in the MediaPlayer preview and as a standalone file — looks perfectly fine. Why does this happen? Can you explain how this mechanism works?

I’m currently retrieving the texture using mediaPlayer?.TextureProducer?.GetTexture(), but it requires a short await delay before the texture is fully loaded. What’s the proper way to get a Texture2D directly — already in the correct orientation (not flipped) — without heavy processing or performance drops? Because ResolveToRenderTexture() is definitely expensive and adds a lot of per-frame overhead.

using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using RenderHeads.Media.AVProVideo;
using UnityEngine;
using UnityEngine.UI;
namespace Video
{
    [RequireComponent(typeof(MediaPlayer))]
    public class VideoPlayerTest : MonoBehaviour
    {
        public string VideoPath;
        
        [Header("Components")]
        public MediaPlayer mediaPlayer;
        public RawImage rawImage;
        
        [Header("State")]
        [SerializeField] private bool isLoaded;
        [SerializeField] private float durationSeconds;
        [SerializeField] private Texture videoTexture;

        public async UniTask Initialize()
        {
            Debug.Log($"VideoPlayer.Initialize(): Path={VideoPath}");
            
            isLoaded = mediaPlayer.OpenMedia(new MediaPath(VideoPath, MediaPathType.AbsolutePathOrURL), false);
            Debug.Log($"VideoPlayer.Initialize(): IsLoaded={isLoaded}");
            
            var timeout = UniTask.Delay(5000);
            var getTextureTask = UniTask.WaitUntil(() => TryGetVideoTexture(out videoTexture));
            var getTextureResult = await UniTask.WhenAny(timeout, getTextureTask);
            if (getTextureResult == 1)
            {
                Debug.Log($"VideoPlayer.Initialize(): VideoTexture={videoTexture!=null}, Size=({videoTexture.width}x{videoTexture.height})");
            }
            else
            {
                Debug.LogError("VideoPlayer.Initialize(): Timeout waiting for video texture.");
            }
            
            rawImage.texture = videoTexture;
            
            durationSeconds = (float)mediaPlayer.Info.GetDuration();
            Debug.Log($"VideoPlayer.Initialize(): Duration={durationSeconds}");

            bool RequiresVerticalFlip = mediaPlayer.TextureProducer.RequiresVerticalFlip();
            Debug.Log($"VideoPlayer.Initialize(): RequiresVerticalFlip={RequiresVerticalFlip}");
        }

        private bool TryGetVideoTexture(out Texture texture)
        {
            texture = mediaPlayer?.TextureProducer?.GetTexture();
            return texture != null;
        }
    }
}
`

tomashined avatar Nov 11 '25 19:11 tomashined

Adding an event listener and waiting for the FirstFrameReady event is the best way to wait for the video player to have started producing frames.

With AVPro Video 3 the texture output from the TextureProducer should be in the correct orientation. If this is not the case then please share your video with us so we can investigate further (please send to [email protected]).

MorrisRH avatar Nov 12 '25 09:11 MorrisRH

please share your video with us

Hello. I’ve sent you the video by email. So far, I haven’t had a single video that appears with the correct orientation - neither in the old nor in the new version of the plugin. This applies to videos recorded directly with the iPhone/iPad camera as well as those recorded through a third-party Unity plugin.

the best way to wait for the video player to have started producing frames

Could you please share the most reliable example code showing how to:

  • load a video from a given filePath,
  • retrieve all its metadata (duration, resolution, framerate, etc.),
  • obtain a Texture2D in the correct orientation,
  • and ensure smooth playback without freezes or delays (both when using Play and Seek)?

tomashined avatar Nov 12 '25 14:11 tomashined

I don't believe we have received an email yet.

Chris-RH avatar Nov 13 '25 07:11 Chris-RH

I don't believe we have received an email yet.

I’ve sent it one more time. imageimage

tomashined avatar Nov 13 '25 11:11 tomashined

I don't believe we have received an email yet.

Any updates?

tomashined avatar Nov 18 '25 17:11 tomashined

We've not been able to reproduce this using your video and AVPro Video version 3.3.3

Chris-RH avatar Nov 20 '25 16:11 Chris-RH

We've not been able to reproduce this using your video and AVPro Video version 3.3.3

How does it work for you? I’m just testing it on the trial version…

Image Image

I added you to my test repository. Please take a look.

tomashined avatar Nov 20 '25 16:11 tomashined

I sent you the information by email. @Chris-RH @MorrisRH

tomashined avatar Nov 20 '25 16:11 tomashined

Issue is with the Windows platform with version 3.x. Android, iOS, and macOS all produce a texture with the correct orientation.

MorrisRH avatar Nov 20 '25 17:11 MorrisRH

Issue is with the Windows platform with version 3.x. Android, iOS, and macOS all produce a texture with the correct orientation.

Yes, that is correct. However, I checked version 2.9.3 and the orientation is flipped there, while in version 3.3.3 on macOS and iOS the direction is correct. Why is this happening? What changes were made during this time?

When is the release of version 4 of the plugin planned? We did not upgrade from 2.9.3 to version 3 because we had only just purchased the plugin, and a couple of months later you released the third generation. We would prefer not to end up in the same situation again.

tomashined avatar Nov 20 '25 18:11 tomashined

When is the release of version 4 of the plugin planned? We did not upgrade from 2.9.3 to version 3 because we had only just purchased the plugin, and a couple of months later you released the third generation. We would prefer not to end up in the same situation again.

@MorrisRH @Chris-RH

tomashined avatar Nov 25 '25 22:11 tomashined

Hi,

We allow at least 2 years between each release, so the earliest release date would be 22 March 2026, this depends a lot on our workload with external projects, as we are a very small team. HOWEVER, we currently have no plans to release AVPro Video version 4 in the first two quarters of 2026.

Chris-RH avatar Nov 26 '25 11:11 Chris-RH

I'm having this same issue with Windows textures being flipped on a HAP with verion 3.2.7, any updates here?

I suppose I could just write a work around but wondering if there's an easy fix.

rlekey avatar Dec 01 '25 00:12 rlekey