- Home /
Using the new "Video Player", large video won't load in Build, but will load in editor
Hey everyone, I actually solved this, but I wanted to get this out there for anyone who might be running into this issue. It seems pretty simple in retrospect, but then again, don't most issues? Anyways, I am using the new "Video Player" in unity beta, and it's been working swell as I'm developing. I have a few smaller videos (10-20 MB) and one very large video, which I play at the beginning of the scene. Everything is working great in the editor, so I create a build, and the video does not play...Long story short (skipping the pulling of the hair and cussing at the monitor), the video actually was playing, but it took about 60 seconds before it started to show it was playing.
There is a section in "Player Settings" where you can actually PreLoad assets...You can get there by going to File->Build Settings->Player Settings, Go to the "Other Settings" tab and under "Optimization" there is an array field called "Preloaded Assets". Make that array size as big as you need and import each asset you want to preload right there. This solved my problem for the video, though, this solution will probably work for any large asset that is giving you issues...
Anyways, hope this helps...And if I stated something overly obvious, I'm sorry about that...I'm just hoping to save someone the 5 hours it took me to figure out.
I am having this problem as well, but your solution doesn't work for me. $$anonymous$$y video plays great in the editor. I was all excited about this new video player. It was really easy to set up and control and looked great. Then I tried to build... and I can't seem to get the video to display at all.
After finding your post, I hoped I had found the solution, and added the video to PreLoaded Assets, but alas it didn't work for me.
The video is long, and I am sending it to a render texture. I have tried compressing the heck out of my 7 $$anonymous$$ute long video. (around 60mb) but still no dice. I have tried both $$anonymous$$ac and Windows builds, but neither are displaying the vid. Anyone else have this problem or find a solution?
I'm having the same issue, $$anonymous$$-Woods. Unfortunately the above solution wouldn't work for me either. I am just learning unity, and I have a project including 2 videos. I was happy to figure out the scripting etc to get the videos to play in the editor. I notice that when I go to build out an exe on windows, the file size for the exe is something like 17 $$anonymous$$B. But the video files I have included are 40 $$anonymous$$B and 20 $$anonymous$$B. So this can't be right... I'm wondering if for some reason the exe isn't including the video files themselves? Just seems really strange to me.
Hi jdpeters79. I was able to get the build to work on windows by setting the video source to url rather than "Video Clip". I stored my videos within a "$$anonymous$$edia" folder in my assets, and scripted my vid player to get the url with the following:
private VideoPlayer vid;
public string vidname;
void Start () {
vid = GetComponent<VideoPlayer> ();
vid.url = Application.dataPath + "/$$anonymous$$edia/" + vidname;
}
After the build on Windows, I then had to manually copy the $$anonymous$$edia folder to the build's Data folder. This worked fine on Windows, but I haven't got it working on the mac. I haven't had time to fully troubleshoot it, and come up with a complete solution, but hopefully this helps you.
Sorry for a quick 2nd reply - but for my project, I just figured out the issue. As mentioned above I wasn't sure if the exe file even pulled in the videos. I found the output log txt file, and sure enough, it wasn't. I was using relative links in my C# script to find the video, and that gummed things up during the build. Switching to absolute links to my video files did the trick, in my case.
Cool, thanks for the info guys...Just one more tidbit of information. The preloaded assets trick I mentioned up top only works if the video is the first (or only) preloaded asset in the entire project. I think this new system may be a buggy system, as we are seeing.
Has anyone had any luck getting the video player to work for a web build?
Answer by Jonesy19 · Jul 11, 2017 at 12:07 AM
Hey everyone, I realize the solution I listed above might not be the best, or ideal...I did find something else that worked for me, and if the above solution isn't working for you, you can try this...
If you go to the properties of the imported video (in the unity editor), check the "Transcode" checkbox. Then you should be good to go. This also worked for me and, in fact, I was able to remove the video from the preloaded assets section and it still worked!!! I'd be curious if this works for anyone else, so please comment below if it worked for you, as I'm still testing this out on different platforms...
Even though your original solution worked well for me, I decided, that for the sake of science, I should give your second suggestion a whirl. I went ahead and removed a video of $$anonymous$$e from the preloaded assets and tried unchecking Transcode to see what kind of difference it made. The video is an 29.2 $$anonymous$$B 1920x1080 30 second avi. After reverting to these setting, the problem of the video not showing in a build once again reared its ugly head. So, I will be sticking with the adding the videos to preloaded assets method until something better comes along. Cheers!
Ahh bummer...Well, thanks for the reply and the info. The VideoPlayer is so new it's good to get information out there...I know I have spent waaay too much time in this area and it would have been much easier if there were more threads on the topic.
Well there's a live training about to come on and I intend to ask about it.
https://unity3d.com/learn/live-training/session/playing-video-unity
Edit: Okay so after watching the live training, they suggested I try the H264 codec ins$$anonymous$$d of AVI. I rendered a 30 second video with blender using H264 and swapped the new video in for the previous avi I had. After building the game with the new video, it appears to be working now. I also did not select 'Transcode' on the video clip import settings since I guess the clips are transcoded to H264 anyway.
Answer by HanSoloYolo · Feb 28, 2018 at 11:26 PM
I do the transcoding, preloading, AND attach a script with:
//be sure to have the using statements at the top
using UnityEngine;
using UnityEngine.Video;
//create a public videoplayer, this way you can simply drag the video plane
//onto the object this script is attached to in Unity's Inspector
public VideoPlayer videoPlane;
//then in whatever method or even the Start()
// I am building a Vuforia project, so I use this in the OnTrackingLost()
videoPlane.Prepare();
This finally did the trick for me. I had to combine all 3 methods (Transcoding, Preloaded Asset, and Prepare())
Answer by JohnnyMc · Sep 04, 2019 at 10:21 PM
I know this is old but thank you! The Transcode fix worked for me.
Answer by SirMazius · Oct 05, 2021 at 07:32 AM
Hello there, maybe a bit late but i walked across this very same problem last day at work.
Apparently the loading stuff carried on by .Prepare()
is managed underneath asynchronously. So in order to make sure your video is prepared you can subscribe to VideoPlayer.prepareCompleted
and be notified when that takes place.
The reason of transcoding working is that maybe makes the process faster so you dont notice the loading process.
Your answer
Follow this Question
Related Questions
How to stop game hitch from Loading a Large asset in Async method? 0 Answers
Loading asset depending on variable's value 1 Answer
Scene load before video (Handled Android) 0 Answers
How would I go about making an open world game? 1 Answer
How can I dynamically load assets from a dedicated and moddable folder at runtime? 1 Answer