Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

VideoPlayer.frameRate and VideoPlayer.frameCount incorrect on WebGL

Discussion in 'WebGL' started by nathanael-omnivor, Apr 6, 2018.

  1. nathanael-omnivor

    nathanael-omnivor

    Joined:
    Apr 4, 2018
    Posts:
    3
    We are using a VideoPlayer to stream videos from URLs in our Unity project. When deployed on WebGL, the frameCount and frameRate properties of the VideoPlayer return the incorrect values.

    The expected values for the frame rate and frame count of our video are 30 fps and 540 frames. The values are correct in the editor (even when the platform is set to WebGL), and on iOS and PC Standalone. But when running in the browser using WebGL the VideoPlayer reports a frame rate of 24 and frame count of 432.

    The video plays to the end, but at 24fps, so it drops every sixth frame.

    Interestingly, the duration of the video when calculated with frameCount/frameRate is still correct when using the bad values (duration = 18 seconds). My guess is that the VideoPlayer calculates frameCount by multiplying frameRate and duration.

    The question is: Why is the VideoPlayer on WebGL choosing a frameRate of 24? Is there a limitation in the WebGL VideoPlayer that prevents playing videos at 30fps?
     
  2. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,067
  3. nathanael-omnivor

    nathanael-omnivor

    Joined:
    Apr 4, 2018
    Posts:
    3
    I've filed a bug (Issue ID 1023076).

    Thanks!
     
  4. ralf_b

    ralf_b

    Joined:
    Jul 9, 2013
    Posts:
    48
    Sorry to necro this thread, but was this resolved?
    I seemingly have the very same issue where frameCount run in the editor states a different value from what it states when run in WebGL in the browser.
     
  5. ralf_b

    ralf_b

    Joined:
    Jul 9, 2013
    Posts:
    48
    [RESOLVED] indeed there is a missmatch of FPS when playing a video in the editor VS WebGL
    https://docs.unity3d.com/ScriptReference/Video.VideoPlayer-frameRate.html
    "Note: On WebGL, the frame rate is always set to 24FPS because the underlying implementation, the javascript API for HTML5 <video>, does not expose frame rate information."

    My workarround is to base all calculations on seconds instead of frames now, therefore I still can use 25fps videos and pause them at 4 seconds in the editor as well as in WebGL, instead of checking the framerate and pausing the videos either at 200 frames @25fps or at 96 frames @24fps.