Where is fps stored in the video metadata in html5?

To fully implement my custom html5 video player, I need the exact frame rate of the video. However, I have not been able to find it yet, and I use the standard value of 25. Usually the video has a frame rate in the metadata, so I turned to the metadata using something like this:

var vid = document.getElementById("myVideo"); vid.onloadedmetadata = function(e) { console.log(e); }; 

However, I cannot find the frame rate here. Maybe I don’t read metadata at all. I can use your help. Thanks!

+5
source share
1 answer

I am 95% sure that the standard html5 video api does not disclose fps information, from what I read in the past months, another apis like MPEG-DASH and jwplayer represent more / different data.

It would be best to keep track of w3schools.com/tags/ref_av_dom.asp and similar mdn pages.

You can calculate this in real time yourself, and it should work most of the time, but I can imagine a case or two when it won't. Take a look at PresentedFrames and then do something like:

 fps = video.time / PresentedFrames 

Read more about PresentedFrames here (currently a proposal) and similar attributes with the same link .

+1
source

Source: https://habr.com/ru/post/1243099/


All Articles