Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Movie seeking

Discussion in 'Scripting' started by vogles, Oct 30, 2009.

  1. vogles

    vogles

    Joined:
    Sep 28, 2009
    Posts:
    131
    First, I want to say i'm not sure if this was supposed to be posted under Unity Support or if its fine here. And I apologize if its in the wrong section.

    So here's an interesting thing i found while tinkering with Unity. You can kind of trick movie playback into doing a fast forward if instead you use audio.time to seek the audio. Its extremely volatile and i would not recommend it for production use, but it's interesting to look at.

    What I did was attach a movie texture and its audio clip to an object. I thought it would be interesting to see the movie and the audio play at different points, so I set audio.time = audio.clip.length / 2.0f. It didn't do what i expected. Instead it jumped ahead about a second or so. it looks like Unity is trying to keep the movie and audio synced, so it'll move the movie ahead to catch up with the audio.

    Unfortunately, Unity is very temperamental when you try to exploit this. The editor crashes quite often if you do this. The standalone crashes often, too.

    Another way to simulate fast forwarding is to raise the pitch of the audio. I'm not 100% sure if this works in code, since i haven't tried it. What I did try was increasing this value in the inspector and it did speed the movie up. This approach does the whole chipmunk audio thing. Quite funny to watch.

    I plan to bug my findings since you can accidently crash the editor and your app.
     
  2. vogles

    vogles

    Joined:
    Sep 28, 2009
    Posts:
    131
    I should also specify that this was done in 2.5.1. I had no idea 2.6 was out until after i posted this. I'm going to try the same thing on 2.6 and see the result. if something changed in 2.6 that handles these behaviors, it could be an amazing solution to the whole "can't seek movies" dilemma.
     
  3. vogles

    vogles

    Joined:
    Sep 28, 2009
    Posts:
    131
    2.6 behaves pretty much the same way. Haven't gotten a crash, but does the same thing.
     
  4. DarkMagicCK

    DarkMagicCK

    Joined:
    Dec 25, 2012
    Posts:
    8
    WOW really thanks, vogles! We've tried our best to find a way to change speed of move texture playback but no good.
    Your function is really nice. I've tried that. This is a nice hack.
     
unityunity