- Home /
MovieTexture Lag on AudioSource, Replaying
I'm trying to get a MovieTexture to replay relatively smoothly. Currently I'm calling Stop()
then Play()
manually as the .loop
attribute doesn't work (neither does .duration
)
When I call Stop()
, then Play()
, the final frame is shown for a second, the audio plays straight away, then movie finally catches up wth the audio after dropping first set of frames.
Interestingly when I do not play audio, the movie restarts perfectly with no dropped frames.
I made a small script to test the various combinations of Play/Pause/Stop and MovieTexture/AudioSource http://pastie.org/7901854
I found some interesting quirks:
Playing and stopping a movie without starting its AudioSource has no lag.
However once its AudioSource has
Play()
called on it, it makes the movie lag onStart()
/Stop()
.Pausing the AudioSource doesn't pause movie playback.
However resuming paused audio playback causes movie lag.
Stopping movie supposedly rewinds the clip, but the texture is not cleared.
Calling Play() an paused audiosource before calling Play() on its paused MovieTexture causes the sound to be half as quiet.
Pausing the movie pauses the sound.
Calling Play() on a paused movie's SoundSource causes it to loop the current sample.
The fact that MovieTexture doesn't clear when stopped is a problem too. I can set renderer.mainMaterial
to a black diffuse when I call Stop(), but when I call Start() again and re-assign the MovieTexture, it shows the last frames of the video clip.
I'm not sure what's causing this. There are no huge spikes in CPU. The movie is extremely small, only 190px by 108px, and 20s in length. I've set my ffmpeg encoding to output a large number of keyframes, so it should be able to play at the start.
Does anyone know how to stop AudioSource from adversely affecting a MovieTexture in this way? Also how to force a MovieTexture to clear when Stopped?
One "solution" I've found is to use ffmpeg to rip out the audio to a separate .ogg
, and then use that in an "unlinked" AudioSource. So don't use movieTexture.clip. But they could get out of sync.
Answer by pal1088 · Apr 03, 2015 at 12:35 PM
Any other tricks to solve this issue. I see the same in Unity 5.
Answer by Derpyness · Dec 25, 2015 at 01:06 AM
I have this problem but found a temporary workaround.
I have the audio of the movietexture set to an audiosource on the same object, then when I want to make calls to the clip, I make the call on both the movietexture component and audiosource component
Your answer
Follow this Question
Related Questions
Audio from Video starts stuttering + video playback lag after a few minutes 0 Answers
How can we get the current video time for scrubbing? 0 Answers
Change AudioSource maxDistance by script with no effect 0 Answers
How do i change the velocity of my video(movietexture) 0 Answers
AudioSource.Play lags. 2 Answers