Search Unity

Video Urgent! VideoPlayer on Android can't fade from one video to another

Discussion in 'Audio & Video' started by danielesuppo, May 21, 2018.

  1. danielesuppo

    danielesuppo

    Joined:
    Oct 20, 2015
    Posts:
    331
    Hello, I'm working on a very simple 360 video player for GearVR that should fade from one main video to another one.
    These videos are stored in the Application.PersistentData path, so I can change them without to rebuild the app.

    1 - I'm using a unlited sphere (with reversed normal and a simple unlit shader with float transparency on it) to show the 1st video.
    2 - when the user look at some button another bigger sphere, with the 2nd video, is SetActive true, it's own videoplayer start to Prepare and Play.
    3 - The 1st sphere is faded out, from 1 to 0, and next it's own videoplayer Stop, and this sphere is SetActive false;

    Everything work fine in Editor, always.
    But on Android it work just until I use for both the 1st video and the 2nd video some .mp4 files with maximum resolution (3840x1920) (At least I did many test and it seem to me that this is the issue).

    When I try to use maximum resolution for both files I get this error:
    AndroidVideoMedia: Error -10000 while configuring codec.

    Instead, if I use, let's say, maximum resolution for the 1st video and 1280x720 for the 2nd one everything work fine.

    I'm using for my test a Samsung S6+.
    Maybe is it an issue due to the my poor device (the target device should be a Samsung S7) ?

    Many thanks!
     
  2. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    Hi, android devices have limited resources for hardware video decoding, so depending on device capabilities you might not be able to use two such large resolution videos simultaneously.
     
  3. danielesuppo

    danielesuppo

    Joined:
    Oct 20, 2015
    Posts:
    331
  4. AdamBL

    AdamBL

    Joined:
    Oct 27, 2016
    Posts:
    29
    Do you have any suggestions for optimizing videos for Android. Even loading a short (10 second) SD MP4 causes a hitch where you miss the first ~1 second of the video.
     
  5. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
  6. AdamBL

    AdamBL

    Joined:
    Oct 27, 2016
    Posts:
    29
    Yes, that does seem to be working. Does it matter how far ahead of time you prepare the video? Is the best practice to do it at the start of the scene?
     
  7. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    It does not matter when you prepare the video, just be early enough that preparation would have enough time to complete before you need to playback. Preparation loads video and allocates resources, so it might not be a good idea to always prepare all videos at the start of the scene, because you might run out of resources.