Search Unity

AudioSampleProvider's buffer overflow on 360 Video

Discussion in 'AR/VR (XR) Discussion' started by dlnb2012, Nov 9, 2018.

  1. dlnb2012

    dlnb2012

    Joined:
    Aug 21, 2018
    Posts:
    3
    Hi all !

    I've a weird issue : I've made an app for playing 360 video, most of them in 4K (4096x2048), some of them a little smaller.

    When I launch the app for the first time (meaning, after boot or reboot the phone), sometimes, the video freeze, but the sound continue (the sound is uncluded in the MP4 file). The app itself is not freezed (actions planed at the the end of the video works well).
    The sound is also a bit delayed from a few frames.

    Just before the video freeze, the logcat show several
    AudioSampleProvider's buffer overflow. xxx sampe frames discarded


    The app replay the video after the HMD has been unmounted, and from there, no issue at all, never (sound is synchronize, video never freeze).

    This behaviour occurs both on S7 phone with Gear VR and Oculus Go.

    The video is project via a skybox panoramic shader with renderTexture, here is the code :
    Code (CSharp):
    1.     void Start () {
    2.    
    3.         OVRManager.HMDMounted += HandleHMDMounted;
    4.         OVRManager.HMDUnmounted += HandleHMDUnmounted;
    5.  
    6.         videoPlayer = videoPlayerObj.GetComponent<VideoPlayer>();
    7.         videoPlayer.url = Application.persistentDataPath + "/video.mp4";
    8.         videoPlayer.EnableAudioTrack(0, true);
    9.  
    10.         audioSource = gameObject.AddComponent<AudioSource>();
    11.         audioSource.playOnAwake = false;
    12.        
    13.         videoPlayer.playOnAwake = false;
    14.         videoPlayer.SetTargetAudioSource(0, audioSource);
    15.         videoPlayer.Prepare();
    16.         videoPlayer.loopPointReached += EndReached;
    17.         videoPlayer.prepareCompleted += PlayerReady;
    18.        
    19.     }
    20.  
    21.     void PlayerReady(VideoPlayer vp)
    22.     {
    23.         //Play Video
    24.         videoPlayer.Play();
    25.         audioSource.Play();
    26.  
    27.     }
    28.  
    29.     void EndReached(VideoPlayer vp)
    30.     {
    31.         videoPlayer.frame = 0;
    32.     }
    33.  
    Think of an issue related to decompressing the audio in Unity (because works well after first read), but don't know how to solve this !

    Thanks
     
  2. gunboldb

    gunboldb

    Joined:
    Jun 8, 2018
    Posts:
    7
    Hey! I am also getting overflow errors suddenly. Everything was working fine before. Any luck with solutions?
     
  3. dlnb2012

    dlnb2012

    Joined:
    Aug 21, 2018
    Posts:
    3
    Hi, unfortunately, still stuck on this
     
  4. Rayeloy

    Rayeloy

    Joined:
    Feb 12, 2017
    Posts:
    45
    I've got the same problem! still no solution
     
  5. Vehicle

    Vehicle

    Joined:
    Jan 23, 2017
    Posts:
    2
    I have the same problem.2018.3.13f1
     
  6. kittphi

    kittphi

    Joined:
    Feb 17, 2019
    Posts:
    4
    I have the same problem. Unity 2019.1.8
    Any luck on your end gentlemen?
     
  7. TazerProductions

    TazerProductions

    Joined:
    Nov 19, 2019
    Posts:
    1
    have a similar issue aswell
     
  8. yty

    yty

    Joined:
    Aug 10, 2009
    Posts:
    82
    I don't use VR,I have the same problem. Unity 2018.4.2f1.
     
  9. Quartermazer

    Quartermazer

    Joined:
    Dec 20, 2019
    Posts:
    2
    I was able to fix this by clicking 'wait for first frame' on the video player.
     
  10. Umresh

    Umresh

    Joined:
    Oct 14, 2013
    Posts:
    56
    Didn't work.
    Still facing the same issue on unity 2019.3.5f1
     
  11. tonybf

    tonybf

    Joined:
    Dec 24, 2017
    Posts:
    9
    Last edited: Jul 14, 2020