Is it feasible to play 4K video in Unity?
Asked Answered
L

8

0

I’m starting work on a 360 VR video player, aimed at mobile devices (iOS/Android Cardboard + GearVR) and I’m evaluating whether it is possible to get video quality from 1080p to 4k in Unity or if I should instead just do the project natively (aka, OpenGL).

I’ve been trying to find information on the state of video in Unity but I haven’t arrived to a clear answer. I’m going to explain the info I’m running on as of now, hopping that someone can add to this or provide an answer or at least show that I am erring on the side of ignorance :slight_smile:

Assume a video in mp4, H264 at 4K resolution (equirectangular mapping):

OpenGL Approach:

If I were to do this in OpenGL, a (somewhat simplified) workflow would entail decoding each video frame, updating a GL_TEXTURE_2D with the pixel contents, and rendering to a sphere with glCullFace(GL_FRONT) as if it where a regular skybox.

With the above setup, the limiting factors would be:

  • Does the GPU in my device support 4K textures? what marketing calls 4k is usually 3840 horizontal, and, an iPhone6 for instance, returns 4096 for glGetIntegerv(GL_MAX_TEXTURE_SIZE,...). So I’d assume the iPhone6 can load textures as big as required for 4K.

  • Fill rate: i.e.: my iPhone6’s GPU might be capable of storing 4K Textures, but it might not be fast enough to fill up a 4K frame buffer at an acceptable frame rate. This unfortunately I think the only way to know is by testing. There is also the added overhead of the Cardboard rendering which means 2 passes per frame.

Unity Approach:

Now for a Unity approach, this is what I did:

  1. Empty scene with a sphere and cardboard camera at the origin.
  2. For the sphere, I created a material based on the Unlit shader with one texture and set the cull face to front.
  3. imported the video and assigned it as the material’s texture.

My observations from the above test are:

UPDATE: I now realize that my test was using Unity’s Move Texture, which is not available on mobile. So if I still pursuit this project in Unity I will anyway have to either do my own native Unity plugin and write the OpenGL code to map the textures to the geometry or purchase an asset like AVPRO

  1. When importing images, Unity also allows texture sizes of 4096 so 4K should be possible.
  2. Importing a video however, takes a ridiculous amount of time. I believe this is because Unity actually uses Ogg Theora and so it takes forever to transcode to Ogg. As a matter of fact, sometimes I was able to import and sometimes Unity would just stall.
  3. When importing a video, I was not given any mmap, filtering or size options as if I was importing an image. So I’m not really sure what Unity is doing to the video. All I get is a quality / compression slider. The end video is still 3840x1920, which was the original resolution.
  4. The rest of the experiment works ok, as in, yes, the video playbacks in the sphere. But the framerate is not great.

So at this point my conclusions are:

  1. Is it possible to do 4K in Unity? Kind of, In the sense that you can import 4K videos and reproduce them without any external assets.
  2. Is it really 4K quality? Probably not. mp4 is lossy and so is ogg, So I assume my video went a second round of lossy compression when it was transcoded to Ogg.
  3. Is it practical? Not sure. So far, video importing takes an impractical amount of time. Also, 4K in general might be too much for a mobile device rending in stereo, regardless of Unity or doing it straight in OpenGL.

As a side note and to complicate things even more, I was thinking of allowing both downloading and streaming video in the app. But from the above it seems that would be out of the question performance wise. Maybe I have to stick to 1080p or even 720p?

Leucopoiesis answered 29/11, 2023 at 9:11 Comment(0)
S
0

It’s possible to play 4k videos in Unity, but from personal experience without external assets, like you said, the framerate is not great and it could take hours to import.

So for myself, I use easy movie texture and it’s totally different, it’s fluid and in the StreamingAssets folders Unity doesn’t convert the videos to Ogg, so it’s really fast.

Suttles answered 6/6, 2023 at 2:10 Comment(3)

I was currently trying out the demo for AVPro, substantially more expensive than Easy Movie Texture. So you are saying Easy Movie is enough to play 4K? Also, yes, in the meantime I discovered that if I import to the streaming folder I skip the processing time since the files are left intact, like you said. And do you think it might be worth exploring me just doing a native plugin instead? Have you tried this approach? The potential would lie on me making sure only the necessary GL commands are issued for just this use case, but it might just not be significantly more performant. Thanks!

Leucopoiesis

Does easy movie texture work for pc releases too? All I find are android examples but I'd like to play a 4k Video for the HTC VIVE.

Emotion

Hi @Suttles i am using Easy-Movie-Texture. But even if I play 4k video (for VR project), it seems of less quality. Do you have any idea why is it so? The video is playing in the 4k supported devices, but it doesn't have the quality.

Radiation
C
0

Hi @Leucopoiesis, did you ever manage to get 4K video textures running at a decent frame rate in Unity?

I’m trying to create a project whereby the user watches a 360 video and then gets presented with two buttons to choose from which then selects the next scene. But it all rests on 4K textures running at a decent frame rate. Any help would be greatly appreciated. Thank you.

Curvy answered 4/11, 2016 at 20:17 Comment(0)
L
0

In case if anyone will be searching for a solution for desktop platforms in this topic (like I did), there is Demolition Media Hap plugin, which is capable of playing videos up to 8k@60fps!

Lochner answered 6/6, 2023 at 2:2 Comment(2)

Great find! Do you by chance know if it works that good in a VR environment?

Netta

Apparently 2 solutions in the SO link. Let me know if something works.

Washday
L
0

in my case with easy movie texture 4k video having 40 mb does not streming well. it just stop playing after playing some frame. if put this video in streaming asset folder it works well. but i need to play it from stream … plz help

Lisabethlisan answered 19/2, 2017 at 23:0 Comment(2)

Yes! I faced the same problem few months ago. Don't know the solution... Any updates?

Twinned

Oh and I can't find a solution in the mentioned links - those just show on how to get rid of the processes in order to remove the assertions - but I know that I can close unity to remove it - but thats what we want to avoid :)

Metalwork
M
0

With Unity 5.6, a new component called VideoPlayer has been introduced. Check it out. It plays 4k videos easily!
Currently no Android support though.

Messiah answered 4/4, 2017 at 5:6 Comment(0)
T
0

I need to make the same project and running into same question: “What quality should I steam video? Is it worth to use 4K video quality on Android and IOS devices? How can I make 4k been playable on mobile?” What was your solution and maybe you have some updates on this now?

Twinned answered 25/10, 2017 at 13:54 Comment(0)
S
0

I’m trying to create a project whereby the user watches a 360 video and then gets presented with two buttons to choose from which then selects the next scene. But it all rests on 4K textures running at a decent frame rate. https://www.zz.com.ve Any help would be greatly appreciated. Thank you.

Spectacles answered 25/10, 2017 at 13:58 Comment(3)

Yes that's what I meant. However, I am now not so sure. Like I said above, I tried it before posting as an answer, and literally watched the "Yes" turn to "No" and back several times. But now it doesn't seem to be doing that. So I don't know what's going on. Might have to downvote myself :)

Tanney

And FWIW, the "Disable Unity Audio" checkbox in Project Settings -> Audio Manager isn't doing anything either. I'm just experimenting here by the way, since I put my computer to sleep myself (much as I love the environment, I have work to do).

Tanney

I don't seem to be able to downvote my own answer or add another answer, so I have edited the above with what appears to be a more reliable (though considerably more fiddly) solution,

Tanney
S
0

Even before Unity 5.6, there was always HTC Vive’s Media Decoder (up to 8K) Unity plugin on the asset store.

Savino answered 14/7, 2018 at 22:10 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.