MovieTexture.duration returning consistently incorrect duration
Whenever I call MovieTexture.Duration it returns a consistent but incorrect duration for my videos. (all videos are .ogv format).
For example, a video of ~5 seconds returns the float 23.40637. A video of ~1:26 returns the float 33.26076.
I am confused as to why this is happening. I was under the impression that it should return the duration of the movie in seconds. My code is below:
currentTime = 0f;
if(targetRender ==null) targetRender = GetComponent<MeshRenderer> ();
if(targetAudio ==null) targetAudio = GetComponent<AudioSource> ();
string url = "";
url = url +workingDirectory+ "/ogv_Video/" + Path.GetFileNameWithoutExtension (sceneLoader.getSceneParams () [0]) + ".ogv";
WWW request = new WWW (url);
while (request.isDone == false) {
yield return 0;
}
loadedTexture = request.movie;
while (loadedTexture.isReadyToPlay == false) {
yield return 0;
}
targetRender.material.mainTexture = loadedTexture;
targetAudio.clip = loadedTexture.audioClip;
//targetAudio.Play ();
loadedTexture.Play ();
movieDuration = loadedTexture.duration;
Debug.Log ("Movie Duration = "+movieDuration);
currentTime = 0f;
Answer by Zeanog · Feb 15, 2016 at 05:38 PM
We are seeing the same thing. To remove some small hitches that would happen when starting MovieTextures we changed to use WWW and after preconverting all of our videos to .ogv the durations returned are insanely too large Any help ASAP would be great.
Your answer
Follow this Question
Related Questions
Issues with video player coroutine 2 Answers
Cut Video(raw image) in-game? (enable canvas in-game) 0 Answers
How to properly import a video into Unity. 1 Answer
Avoid preparation VideoPlayer 1 Answer
Play video in reverse? 0 Answers