Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Video Player...some .mp4 working, some not!?

Discussion in 'General Graphics' started by Jayme65, Apr 5, 2017.

  1. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    See this topic where I was complaining about some mp4 not starting to play and globally out of sync audio for many mp4 files: https://forum.unity3d.com/threads/video-player-some-mp4-working-some-not.461576

    Now, v6 is out...and the problem is still the same! What's the meaning of releasing a new feature when this is actually half working?

    Severe audio sync problem with this video (among many other with the same symptoms)
    Games for Windows.mp4

    The problem is particularly visible as soon as you're using post effects!!

    What can be done about this please?

    Thanks
     
    Last edited: Apr 5, 2017
  2. ovirta

    ovirta

    Joined:
    Mar 20, 2015
    Posts:
    42
    We are also trying to get Video player to work (on Android) and after transcoding our video to platform supported format (as recommended by @DominiqueLrx) it is working ok.

    Would like to try your problematic video but zippyshare is not working. Any other service you could upload the video?

    Update: Was able to download the file after a while. Service seems to be up again...
     
    Last edited: Apr 5, 2017
  3. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    ovirta likes this.
  4. ovirta

    ovirta

    Joined:
    Mar 20, 2015
    Posts:
    42
    Thanks. Did some testing in our own test scene and audio issues are clear. Even with the simplest scene.

    After converting the video with Handbrake to a more standard (lower quality) 480p30fps from the non-standard60fps format the situation was much better. Video played quite well when attached to camera object and to GUI RawImage Texture. On Android video playback was a slide show even after transcoding to 640x480x30fps-VP8 format but audio played very well though :) For us it is just a question of converting videos to supported format. But as this is not an option for you it's not really helpful, sorry!

    We are looking forward to 5.6 patch releases with Video player improvements. Hope those will resolve your issues as well!
     
  5. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hey everyone!

    I just want to acknowledge the H.264/AAC sync issues you are facing on Windows. VP8/Vorbis also has the same implementation (and problem) on most platforms except WebGL and Android. H.264 doesn't have this issue on Android, iOS, OSX and WebGL.

    On the affected platforms, the delay will be up to around 1s. We have started to fix this and we'll get this into a patch release as soon as possible. In the mean time, you can separate the audio out of your movie file and play it independently, but this is hardly a long-term solution both in terms of asset management and resource usage.

    Sorry for the trouble and hope to have good news soon!

    Dominique
    A/V developer at Unity
     
  6. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    Thanks for the reply Dominique!
    You're talking of a 1s delay...but in my test the problem is not a delay problem but choppy sound that get worse on high display size and/or camera post effects.
    A scene played at 320x240 will "perfectly" play while a 1920x1080 one will show severe audio problems!
    Is this related to what you're talking about?
     
  7. DominiqueLrx

    DominiqueLrx

    Unity Technologies

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

    Yes, they are one an the same. Basically, right now the audio samples are sent to the Unity audio system from the main thread. This is subject to all sorts of outages and overruns, and using larger resolution clips augment the likelihood of those.

    So the improvements I'm talking about revolve around outputting audio samples from the background thread (the one that is decoding the video) and keeping track of these main thread outages so we can adjust the audio timing so it stays in sync.

    Other future improvements will reduce resource usage on Windows (e.g.: enable DXVA when it is available) so that the video playback itself is less susceptible of contributing to the overruns.

    I know you can't do much with this information, but at least I hope it helps understanding what is happening and what has to be done to fix this.

    Dominique
     
  8. Knusper

    Knusper

    Joined:
    Jun 5, 2014
    Posts:
    35
    I'm also facing issues with audio sync.
    When I'm seeking to a specific frame the audio gets out of sync. I haven't tested it on all platforms yet but on WebGL everything seems to work fine while in the editor and PC builds the audio gets out of sync.
    When the video gets loaded and started by 0, everything is correctly in sync.

    I'm loading the video via URL from the streaming assets folder. The audio output is set to AudioSource.

    I don't have any access to the audio clip (the clip is playing and the audiosource is set but the clip remains null).
    If I had access I'd set the audioclip-time manually.

    Loading the video via URL also brings another strange behaviour. The video is playing correctly but the VideoClip from the player stays null.

    Aside from the strange behaviour: The main problem is that seeking will set the audio / video playback out of sync on PC (and maybe mobile platforms?)

    I have installed 5.6.1p1 and tried 2017 Beta. Is this bug known or will it be fixed in the next patch release?

    It's really important to me.


    Thanks in advance,


    Mischaal


    *EDIT*
    Interestingly setting time and setting frames are handled differently.
    If I'm setting my video position via
    Code (CSharp):
    1. player.frame = (long)(player.frameCount * time);
    then the sync gap between video and audio is longer than using this code:
    Code (CSharp):
    1. player.time = (ulong)(player.frameCount / player.frameRate) * time;

    But still with the second code we are still out of sync.
     
    Last edited: May 22, 2017
  9. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    Hi Dominique,

    Two months since the very first post (https://forum.unity3d.com/threads/video-player-some-mp4-working-some-not.461576/) and this problem is still persisting! :(
    I can hardly believe that a great company like yours released a video player component...not being able to play all (in my tests a lot of) mp4 files.
    Dominique, is there a chance to have this concern fixed quickly?
     
    shelkeanmol likes this.
  10. harjeetchandwani

    harjeetchandwani

    Joined:
    May 9, 2017
    Posts:
    1
    Thanks for your message, can you please suggest how i can make it work on HoloLens, we are facing same Audio issue of choppy sound when using video player?
     
  11. jmdeb

    jmdeb

    Joined:
    Jul 28, 2017
    Posts:
    23
    When does Unity intend to fix this problem!? :(
    The first complain on the subject is dated March 17 !! More than 4 months ago!! :eek:

    I'm facing the same issue here, my project heavily relies on video play and the release is postponed, waiting for this bug to be fixed!!
     
    Last edited: Jul 28, 2017
  12. ovirta

    ovirta

    Joined:
    Mar 20, 2015
    Posts:
    42
    Haven't done work with HoloLens yet so only few questions I can offer there.

    What video format are you using?
    Does downgrading video quality help?
    Sample scene?
     
  13. Arvin6

    Arvin6

    Joined:
    Jun 2, 2017
    Posts:
    27
    @DominiqueLrx
    I'm in the same situation as @jmdeb. Our release is postponed because of this issue as well. Apart from that, I'm having trouble loading mp4 files from the web, it seems to work on windows and not on mac. I had luck only with ogv files on mac, how do we transcode files from the web? Say I have a mp4 file that I'm accessing over http, how would I transcode it when I'm playing it dynamically.
     
  14. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    198
    There are some VLC implementations on the Asset Store that works like a charm and have a lot more potential than the embedded Video Player, I know that they aren't free, but hey, for that little money you'll save in headhaches.
     
    VirtualPierogi and ovirta like this.
  15. ovirta

    ovirta

    Joined:
    Mar 20, 2015
    Posts:
    42
    Follow up to my previous message about Video Player performance.

    Audio and video playback problems seem to be resolved (IMHO) with 2017.1.0f3 Unity version.

    Both Editor and Android (Samsung Galaxy Tab 4) are playing video and audio smoothly with no visible or audible issues (H264-MPEG4 AVC, 1920x1080@25fps, MPEG AAC 48kHz audio).
     
    Last edited: Aug 2, 2017
  16. Knusper

    Knusper

    Joined:
    Jun 5, 2014
    Posts:
    35
    As long as you aren't trying to seek time it works perfectly on all platforms. But if you want to seek to a specific time or frame you will have a bad time with the current player situation. In another thread ( https://forum.unity3d.com/threads/the-recommended-way-to-seek-time.471547/#post-3152788 ) someone told that one developer of Unity said they plan to resolve that issue in 2017.3 which will come out late 2017 / early 2018.

    Playing a video without seeking seems to work fine now.
     
    ovirta likes this.
  17. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    Yes, I have problems where we have a pause button. Hitting the pause button has the video pause, but the audio keeps playing for about a second or so. Upgraded the project to 2017.3 because of mention of audio fixes to the video player, but still the same issue. Sadly, this issue makes the two out of sync and suddenly the person's mouth is moving but the voice in the video starts a bit after.
     
    Last edited: Dec 20, 2017
  18. Knusper

    Knusper

    Joined:
    Jun 5, 2014
    Posts:
    35
    I've got a strange bug. That's really annoying and impossible to ship any game using the video system!
    I don't know if this bug also appears on mobile devices but at least on WebGL you can't load multiple videos (or one video a second time) via URL.

    I'm loading a video via URL with video player. When I try to load another video after that video (it doesn't matter if the video has finished or if you just load it while the previous video runs) the screen stays blank (or black). I'm using material override. Using RenderTexture didn't help.

    The problem is: It doesn't seem to be a problem in my script. The correct video seems to be loaded and started because the sound of the video is playing properly. I just don't see any moving picture.

    Has anybody also got such behaviour? I'm using the recently released 2017.3.0f3
     
  19. Knusper

    Knusper

    Joined:
    Jun 5, 2014
    Posts:
    35
    Sorry for double posting.
    The only possible solution to get around that error is:
    - Play Video first time
    - Every time when you load another video:
    - - Destroy the Videoplayer Component
    - - Add VideoPlayer as a new Component on the object you want to have the videoplayer attached (most likely the object where you destroy the old VideoPlayer component from)
    - - Reinitialize the VideoPlayer as you have in inspector before
    - - load video via url and play.

    At least there is a workaround to that problem. But it is a shame that such problems appear over 1 year after the original release of the VideoPlayer. And it is also a shame that no official statement is being made about current bugs or about when those bugs are being fixed.
    Bugs like "out of sync while seeking" or "no second video can be loaded after a first has been played" on WebGL are very common cases and should not be declared as stable. And it's very likely that this bug again needs 6-12 months to be solved because I have the impression that Unity puts more attention in adding countless new features instead of stabilizing and bugfixing existing features.
     
  20. Eastwing

    Eastwing

    Joined:
    Mar 30, 2013
    Posts:
    26
    I've just checked 2018.1 beta aaaaand the problem is still there.

    Is there any chance that it'll be solved sometime? Or is there any chance that developers will start reacting somehow?
     
  21. Knusper

    Knusper

    Joined:
    Jun 5, 2014
    Posts:
    35
    On which platform are you facing problems?
     
  22. Eastwing

    Eastwing

    Joined:
    Mar 30, 2013
    Posts:
    26
    Windows 10 x64. Windows 7 might have the same ones, but I'm not sure yet.

    Also, today I've tried the last beta, and it looks to work even worse sometimes. But I just import the project and haven't done any other changes.
     
  23. Knusper

    Knusper

    Joined:
    Jun 5, 2014
    Posts:
    35
    Does anyone has also the same problems like me when using a streamed video on Firefox?
    Unity's VideoSystem is such a crappy solution. I just can't understand why the QA of unity makes the worst job ever.
    And I also can't understand why NOT A SINGLE Unity developer is helping here with such obvious problems.

    I'm having frame skips and frame jiggles. It is also described already in this issue:
    https://issuetracker.unity3d.com/issues/firefox-videoplayer-has-an-occasional-choppy-playback

    On Chrome everything works as expected. Firefox is nearly unwatchable.
    The last comment of an official Unity dev was nearly one year ago. It's not too much to ask when this issue is addressed or if there is any workaround there... This videosystem never should have been approved as stable and working.
     
  24. Eastwing

    Eastwing

    Joined:
    Mar 30, 2013
    Posts:
    26
    I'm not trying to protect Unity QA (at least they could answer more frequently). But I'm suspect that problem not in Unity, but in Mono.

    We had a memory leak during mp4 playback on Windows build and what is really helps is GC.Collect(). And usually there's no point to run it in Unity API since it's from Mono.

    I'm not sure if garbage collecting will help you with Firefox issue, but I think you can try to write to Mono guys.
     
  25. Knusper

    Knusper

    Joined:
    Jun 5, 2014
    Posts:
    35
    What did you do then exactly? Called the GC.Collect() at the very start? Or frequential while playing the video?

    Thanks in advance
     
  26. Eastwing

    Eastwing

    Joined:
    Mar 30, 2013
    Posts:
    26
    The script calls collecting right after playback ending.
     
  27. Knusper

    Knusper

    Joined:
    Jun 5, 2014
    Posts:
    35
    Thanks for your help!
    But the video itself has a choppy and stuttering image while playing. After playback won't help with this issue.
    However, Thanks for your help.

    I'd like to hear something from an official developer about the status of the video system because there are a lot of issues with the player.
     
  28. as87dgs6asg0a

    as87dgs6asg0a

    Joined:
    Sep 2, 2013
    Posts:
    10
    Hello 2019, where audio sync in the Video Player is still an issue :)
     
    OwlBoy- and paxron like this.
  29. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Hi @DominiqueLrx
    Please note the Video Player no longer plays videos correctly after updating to 2018.4.4f1.

    The visuals are all garbled (snowy) and desynced. Used h.264 codecs and handbrake. Audio is playing, but can't tell if it's synced to the video due to the garbled images.
     
  30. malikfahad

    malikfahad

    Joined:
    Jun 1, 2021
    Posts:
    1
    what transcoding you used?