• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Ben Humphreys · May 13, 2013 at 09:47 AM · audiosourcelagmovietexture

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 on Start()/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?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ben Humphreys · May 13, 2013 at 09:51 AM 0
Share

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.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by pal1088 · Apr 03, 2015 at 12:35 PM

Any other tricks to solve this issue. I see the same in Unity 5.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges