- Home /
Speed up video play
And another quality question ;)
As we are rendering everything as fast as possible in our application, and I already figured out how to speed up the animations (look in my other questions), I now switched to movies playing on a plane (or rather on the material).
And while the movie does play, it does so in original speed. Which is what I do not want. I want each frame of the movie played in exactly one frame in the application. Kind of fast forward as fast as the application framerate lets me. I could probably simulate that via script, but a Movie texture only has Play(), Stop(), etc. and does not seem to have any JumpToFrameX() function.
Any idea how I could do that, speeding up a movie clip on a plane? Or, as a possible alternative, go to time/frame X of a movie?
In our current engine, we do that by decoding a movie via ffmpeg into single pictures and then pass those to a shader. Needless to say, this works, but is pretty complicated and heavy on the performance. I COULD implement this for Unity, too I guess, but a better way without any plugins would be... well... better. :)
Answer by DarkMagicCK · Dec 25, 2012 at 05:15 PM
Hey! Although 1 year later but I've worked out how to change the speed of video playback. Thanks to vogles's nice hack in this post( http://forum.unity3d.com/threads/33181-Movie-seeking )
And the answer is simply change the PITCH of the video's SOUND CLIP when play them all, you need an extra "audio source" to handle the sound clip, and AudioSource.Play() and MovieTexture.Play().
public MovieTexture myMovieTex;
public AudioSource myAudioSource;
void Start()
{
myAudioSource.clip = myMovieTex.audioClip;
myAudioSource.pitch = 2.0f; //The scale factor you want
myMovieTex.Play();
myAudioSource.Play();
}
This works fine. Unity seems to sync the video according to its audio clip, you're not able to set the MovieTexture.audioClip.time. If your video clip has no sound, just use any other video app to add a blank sound on it.
Hi,
I tried this but I'm having a problem, I get a NullReferenceException on the AudioSource. I tried doing myAudioSource = new AudioSource and then doing the myAudioSource.clip = my$$anonymous$$ovieTex.audioClip; but I still get a NullReferenceException :(
Any ideas why?
AudioSource audioSource = gameObject.AddComponent();
I think it is because your video clip do not have an audio track. $$anonymous$$ake sure your imported video clip has its audio.
Happy to report that the code snippet / hack shown above (note: not the plugin) works nicely, I can now control both audio and video frame rates. Pretty much made my day. TheSHEEEP if you're still having probe, I'm more than happy to help if I can can.
Does anyone know if it is possible to rewind the video with this technique?
Answer by Julien-Lynge · Dec 06, 2011 at 04:40 PM
On the Wiki is a plugin and associated scripts for doing advanced movie playback, and among the features is the ability to set the framerate. You could probably easily modify the script to set the framerate on a per-frame basis to some multiple of Time.deltaTime.
Okay, I now get an status error from that plugin. It says "-50". What does that mean? That's not exactly descriptive :D
Found out that this is a quicktime error. "Error in user parameter list (-50)"
So it is something plugin internal, which makes it even harder to guess what this is about.
Seems that the plugin needs a full path, as the error is gone when I set the path absolute. Awkward, but okay...
Anyway, it does not display any movie and the plane the script is on stays black. And yes, light is on.
Well, I found out that the plugin only works when forcing openGL. Unfortunately, this is not really a solution for our application.
I guess I will have to find another solution for this, then.
Your answer
Follow this Question
Related Questions
Allow Unity to render as fast as possible? 0 Answers
How to Cycle video through sphere as a texture ? 0 Answers
How to play video on WEBGL 0 Answers
Unity 1080p Video player 1 Answer
VideoPlayer Completed Event Handler 0 Answers