Video to texture performance issues

I am facing performance issues with video textures, here is a video, my FPS mostly remain stable while the video gets very choppy.

https://playcanvas.com/editor/scene/1136716

I am using PIXELFORMAT_R8_G8_B8 and have a GTX 1660TI which should be able to handle this.

Here is with one video instance, still choppy. Video is cached

video pixel to texture takes 0.23 ms

Hi @Saad_Haider
I had same issue in one of my games, apparently updating texture (transferring the latest video frame to the video texture) each frame causes some wired gimmicks.
If I rememeber correctly, I tried locking frame rate (tried to update my texture in some interval of 0.02 seconds), but in the end I went with creating a video tag in html and somehow rendering it on top of the canvas while forcing it alignment according to main canvas.

may be @yaustar or @will could help us out!.

One thing to note is that the mp4 is 1328x1660. That’s actually quite a lot of pixels to copy from the video to a texture every frame. Have you tried to maybe reduce the size by 50%? Try:

@will
hmm we could try that but is there a way to optimize update texture call somehow, apparently if you have a steady 60 fps, your texture will get updated roughly ~60 times a second, thats alot of CPU processing and if we are not using web workers or any other technique to manage call stacks it could somehow chock our other computational results or does these updates are handle by GPU itself?

The issue with that is I am getting these videos from people’s wallets (NFT’s) and displaying them in galleries, NFT’s could be images, videos, or models (these are loaded at run time from the server).

I would say that runtime resizing wouldn’t be possible for videos and have to think about another solution… because even on Babylon the above video takes around 21ms for conversion to texture, so Playcanvas is not the issue here.

For images as VRAM was an issue (They are mostly 4k or more), and since Basis at run time would be slow: I made an offscreen canvas with a smaller size with the same aspect ratio and displayed it to a texture on our canvas, Did a test with tons of 4k’s and doesn’t crash on iPhone with this technique.
https://playcanvas.com/editor/scene/1134102

On my Dell laptop, it takes 0.6ms to render each frame, even with the high resolution video. So it’s weird you are getting slow downs.

I would recommend doing the texture update every 41.666ms (24fps). Maybe call this.videoTexture.upload() in setInterval.