Search Unity

Video Black background in first frames when playing webm video on Android

Discussion in 'Audio & Video' started by agasser, Jan 10, 2019.

  1. agasser

    agasser

    Joined:
    Nov 25, 2018
    Posts:
    5
    Hi all,

    We are in the process of building a mobile game for Android and iOS in which we want to play some video files at certain points. These videos contain an alpha (transparency) channel and we display it in-game using render mode "Render Texture". Our development IDE is Unity 2018.3.0f2 on Windows and the video files we are currently playing with are .webm files using the VP8 codec. We chose this codec, as this was recommended in the Unity documentation: https://docs.unity3d.com/Manual/VideoTransparency.html This page states, that, in order to make it run on Android, you have to enable transcoding, as the native VP8 coded of Android does not support transparency. We did that.

    We came to a state where the video is played correctly on iOS (including transparency) and within the Unity Editor. On Android, we observed that the video is played using transparency, but still renders the first frames of the video as black frames (no content). After a couple of frames (approx half a second), the black frames disappear and the video is displayed correctly. I wonder what needs to be done in order to get rid of these black frames at the beginning.

    We tested this on an Google Nexus 7 tablet running Android 6.0 and a Samsung Galaxy S9 running the latest Android OS (i guess it was 8 or 9). Both devices showed the same problem.

    I have attached two screenshots of Android running the video (the blue elephant at the bottom). In the first one you see the black frames appearing and the second shows the same video after a couple of frames (displaying correctly).

    In general, it would be very interesting to hear how other Unity developers handle / work with video data in Unity when developing games for Android and iOS. Any inputs highly appreciated!

    Thanks for sharing your thoughts on this.
    André
     

    Attached Files:

  2. bryanDDI

    bryanDDI

    Joined:
    Feb 16, 2017
    Posts:
    8
    Try creating a CustomRenderTexture for the VideoPlayer. In the created CustomRenderTexture set the Color to have 0 alpha. Source needs to be set to "Texture and Color" to have the Color field.
     
    Marte5 likes this.
  3. agasser

    agasser

    Joined:
    Nov 25, 2018
    Posts:
    5
    Thank you! That solved my issue! :)