Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

VideoPlayer plays some clips and not others

Discussion in '5.6 Beta' started by alexandraweiss, Feb 21, 2017.

  1. alexandraweiss

    alexandraweiss

    Joined:
    Jan 31, 2017
    Posts:
    2
    Hello,

    Recently I tried out the VideoPlayer component in 5.6.09b. To get things started, I created an empty project and used this (http://stackoverflow.com/questions/41144054/using-new-unity-videoplayer-and-videoclip-api-to-play-video) to get things running.
    All of the files I used are .mp4 (H264 encoded) files. Some of them will play without any problem whatsoever, whereas others won't. Each file can be opened and played in VLC player and Windows Media Player.

    Unity is stuck in the following while loop:
    Code (CSharp):
    1. while (!videoPlayer.isPrepared)
    2.         {
    3.             Debug.Log("Preparing Video");
    4.             yield return null;
    5.         }
    What could be possible reasons for this? I'm also looking for good ways to debug this.

    Thanks!
     
  2. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi Alexandra!

    There are a few reasons a mp4 H.264 clip will not work correctly in Unity, one of which is when the first frame is not starting exactly at a time of 0. Timestamps for frames sometimes start a bit later, preventing the playback logic from starting because frame 0 is not found. We are repairing this at the moment. This being said, the behaviour will be a bit different (and more reliable) if you just test them out with Play On Awake set to true. Ultimately, both ways (through scripting and through editor) will work identically when the fix in progress is done.

    I assume you're working on Windows: comparing with Windows Media Player is your safest bet to know what to expect with Unity, since on the Microsoft Platforms we are using the same library Windows Media Player uses: Media Foundation.

    If possible, please, open a bug (or many) with the clips that don't work so we can reproduce locally and make sure they are really addressed by the fix we're doing.

    Thanks for your feedback!

    Dominique
    A/V developer at Unity
     
  3. alexandraweiss

    alexandraweiss

    Joined:
    Jan 31, 2017
    Posts:
    2
    Hey Dominique,

    Setting Play On Awake to true fixed it for some of the files i'm working with. Thanks :)
    I'll file a bug with a link to a video.

    Cheers
     
    charlesb_rm likes this.