- Home /
Video Help (MP4)
So, our company decided to port our project over to unity which everybody was all gun-ho and happy to do. However, this project requires MP4 playback (from a local file.) We have a catalouge of around 6,000+ MP4 files and it would seem that Unity cannot play them. I converted one to OGV and it played like a champ. Am I missing here or is this platform (Unity) really unable to play one of the most popular video formats in existence? Sample code below:
try
{
var mov = GameObject.Find("MoviePlayer");
var url = @"file:///C:/myfile.mp4";
var www = new WWW(url);
var movieTexture = www.movie;
mov.renderer.material.mainTexture = movieTexture;
movieTexture.Play();
}
catch (Exception er)
{
print("Fatal Exception: " + er.ToString());
}
EDIT: Converting the files to OGV is not a viable option as we have other programs for mobile devices, etc that rely on the $$anonymous$$P4 files. Perhaps I am missing something, who knows.
The premise for allowing external files is so that users can switch existing videos out for new ones or custom ones (as our game allows for themeing aspects.)
Does anybody know of any asset that can accomplish this? I tried searching on asset store came up with nil.
Answer by tanoshimi · Sep 18, 2014 at 10:32 PM
My understanding is that the only video format Unity natively supports is OGG Theora. When you import a (local) MP4/MOV/AVI file into your Unity project, Unity uses Quicktime to convert it to OGV behind-the-scenes, and that's how the resource is bundled with your published game.
But, if you're trying to access a video at runtime via WWW, that offline conversion obviously isn't available, which is why "WWW.movie data must be a movie in Ogg Theora format." (http://docs.unity3d.com/ScriptReference/WWW-movie.html)
That is an utterly nauseating to me. We have the application to where we want it, been developing it for about six months; then when it comes time for video playback we get a huge roadblock. We did our homework and Unity clearly states it supports $$anonymous$$P4 (boldy in fact), I guess this ends our project and a wast of six months of life; thanks Unity. :(
I've not used video extensively so I might be wrong, but the documentation seems pretty clear on the issue (and there are several posts here and on the Forums which state the same) - all other video formats are supported, but must be encoded to OGG. Likely because of the ugly patents protecting proprietary formats like FLV and $$anonymous$$P4.
Why not do a server-side conversion using, say, FF$$anonymous$$PEG2THEORA?
Your answer
![](https://koobas.hobune.stream/wayback/20220613163302im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
videos stopped working in RAW image 0 Answers
Displaying video 0 Answers
Is it possible to utilize both native cameras of a device simultaneous 0 Answers
RenderToCubeMap with TrailRenderer or LineRenderer 0 Answers
Unity simple client server video streaming using RPC calls to send webcamTexture 2 Answers