• 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
2
Question by TheSHEEEP · Dec 06, 2011 at 04:02 PM · videospeedframeratevideotexture

Speed up video play

And another quality question ;)

As we are rendering everyt$$anonymous$$ng 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 w$$anonymous$$le the movie does play, it does so in original speed. W$$anonymous$$ch 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, t$$anonymous$$s works, but is pretty complicated and heavy on the performance. I COULD implement t$$anonymous$$s for Unity, too I guess, but a better way without any plugins would be... well... better. :)

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

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 t$$anonymous$$s 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();
 }

T$$anonymous$$s 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.

Comment
Add comment · Show 5 · 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 Carkey · Jan 30, 2014 at 09:54 PM 0
Share

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 = myMovieTex.audioClip; but I still get a NullReferenceException :(

Any ideas why?

avatar image hitmax87 Carkey · May 18, 2016 at 03:00 PM 0
Share

AudioSource audioSource = gameObject.AddComponent();

avatar image DarkMagicCK · Jan 31, 2014 at 07:28 AM 1
Share

I think it is because your video clip do not have an audio track. Make sure your imported video clip has its audio.

avatar image splashy · Feb 24, 2014 at 06:43 PM 0
Share

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.

avatar image Ben-BearFish · Jun 10, 2015 at 06:21 PM 0
Share

Does anyone know if it is possible to rewind the video with this technique?

avatar image
2

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.

Comment
Add comment · Show 4 · 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 TheSHEEEP · Dec 07, 2011 at 10:03 AM 0
Share

Okay, I now get an status error from that plugin. It says "-50". What does that mean? That's not exactly descriptive :D

avatar image TheSHEEEP · Dec 07, 2011 at 10:16 AM 0
Share

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.

avatar image TheSHEEEP · Dec 07, 2011 at 10:34 AM 0
Share

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.

avatar image TheSHEEEP · Dec 07, 2011 at 10:57 AM 1
Share

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

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

7 People are following this question.

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

Related Questions

Allow Unity to render as fast as possible? 0 Answers

Play VideoTexture's audio only 1 Answer

I'm using a Chromakey to remove the green screen in my video but this has made the object visible through walls. Dose anyone know a fix? 0 Answers

Is it possible to switch audio tracks in a video? 0 Answers

Can I measure the users connection speed? 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