Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Video is broken in unity webgl builds.

Discussion in 'Web' started by unity_zenaad_dev, Sep 26, 2023.

  1. unity_zenaad_dev

    unity_zenaad_dev

    Joined:
    Mar 18, 2021
    Posts:
    2
    Why does the video look like this?
    스크린샷 2023-09-26 오후 5.55.17.png

    The original video looks like this 스크린샷 2023-09-26 오후 5.55.58.png

    Unity 2022.3.9f1
    Canvas - Raw Image - Render Texture - Video Player
    Code (CSharp):
    1.         var vp = GetComponent<VideoPlayer>();
    2.         vp.url = System.IO.Path.Combine(Application.streamingAssetsPath, streamingVideo);
    3.         Debug.Log("web stream video: " + vp.url);
    4.         vp.isLooping = true;
    5.         vp.Play();
     
  2. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Does the video play correctly in any browser? Or is it like that in all browsers?

    If you use a native video player program (Windows Media Player, VideoLan, etc) to view the file, does that work?

    Something to try here to double check if it is Unity, or web browsers that would be at fault, is to create a small stand-alone video.html file with contents

    Code (CSharp):
    1. <html><body><video controls autoplay src='test.mp4'></video></body></html>
    and place that next to test.mp4, and then open the .html file in a browser. If that shows up correctly, then it is likely a Unity bug -> please open a bug report with the test video file.

    If that also shows up incorrectly, then it is likely a browser bug, or a system-installed codec bug. -> report a bug to Chrome/Firefox/Safari.

    As a workaround, I wonder if changing video codecs might help. Do you know which video codec the video is using?
     
  3. unity_zenaad_dev

    unity_zenaad_dev

    Joined:
    Mar 18, 2021
    Posts:
    2
    @jukka_j Thank you for your reply.

    I've tested in other browsers and only Firefox shows the problem.

    QuickTime Player:
    quicktimeplayer_video.jpg

    Safari:
    safari_video.jpg

    Chrome:
    chrome_video.jpg

    Firefox:
    firefox_video.jpg

    By the way, I have no problem opening the video directly in Firefox. (with your test html)
    It's only through Unity Player that the problem occurs.

    The codec for the video in question is shown below.
    Code (csharp):
    1. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vecteezy_space.mp4':
    2.   Metadata:
    3.     major_brand     : isom
    4.     minor_version   : 512
    5.     compatible_brands: isomiso2avc1mp41
    6.     encoder         : Lavf60.3.100
    7.   Duration: 00:00:10.00, start: 0.000000, bitrate: 17881 kb/s
    8.   Stream #0:0[0x1](eng): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p10le(tv, bt709, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 17877 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    9.     Metadata:
    10.       handler_name    : Apple Video Media Handler
    11.       vendor_id       : [0][0][0][0]
    12.       encoder         : Lavc60.3.100 libx264
    13.       timecode        : 00:00:00:00
    14.   Stream #0:1[0x2](eng): Data: none (tmcd / 0x64636D74), 0 kb/s
    15.     Metadata:
    16.       handler_name    : Apple Video Media Handler
    17.       timecode        : 00:00:00:00
     
  4. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953