简体   繁体   English

我可以在HTML5视频中获取当前帧的编号吗?

[英]Can I get the number of the current frame in an HTML5 video?

I am currently trying to customize an HTML5 video player so that I can add a button that returns the current frame number. 我目前正在尝试自定义HTML5视频播放器,以便我可以添加一个返回当前帧编号的按钮。

Lets say I have a 30fps video that lasts 90 seconds. 假设我有一个持续90秒的30fps视频。 When I click on that button I want it to print me the number of the current frame. 当我点击那个按钮时,我想让它打印出当前帧的编号。 Is that possible? 那可能吗?

I think you can use the following API for Webkit/Mozilla based browser: 我认为您可以使用以下API用于基于Webkit / Mozilla的浏览器:

Mozilla have implemented the following statistics into Firefox: Mozilla已经在Firefox中实现了以下统计数据:

mozParsedFrames - number of frames that have been demuxed and extracted out of the media.
mozDecodedFrames - number of frames that have been decoded - converted into YCbCr.
mozPresentedFrames - number of frames that have been presented to the rendering pipeline for rendering - were "set as the current image".
mozPaintedFrames - number of frames which were presented to the rendering pipeline and ended up being painted on the screen. Note that if the video is not on screen (e.g. in another tab or scrolled off screen), this counter will not increase.
mozFrameDelay - the time delay between presenting the last frame and it being painted on screen (approximately). 

Mozilla are also working on some of the statistics listed here. Mozilla也正在研究这里列出的一些统计数据。

Webkit have implemented these: Webkit实现了这些:

webkitAudioBytesDecoded - number of audio bytes that have been decoded.
webkitVideoBytesDecoded - number of video bytes that have been decoded.
webkitDecodedFrames - number of frames that have been demuxed and extracted out of the media.
webkitDroppedFrames - number of frames that were decoded but not displayed due to performance issues. 

I still investigating the resolution on IE9... 我还在调查关于IE9的决议......

Reference:http://wiki.whatwg.org/wiki/Video_Metrics 参考文献:http://wiki.whatwg.org/wiki/Video_Metrics

I don't think there is a set standard framerate across browsers or any way of accessing the current frame out of the box with html5 video. 我不认为跨浏览器设置标准帧率,或者用html5视频开箱即用访问当前帧的任何方式。 What you could do though is use the television standard framerate of 29.97 frames per second and simply multiply that by the video's current time like so: (vid.currentTime * 29.97).toPrecision(6) . 你可以做的是使用每秒29.97帧的电视标准帧速率,然后将其乘以视频的当前时间,如: (vid.currentTime * 29.97).toPrecision(6)

Here's a fiddle I set up demonstrating how to bind this to a button to get the current frame: http://jsfiddle.net/893aM/1/ 这是我设置的小提琴演示如何将其绑定到按钮以获取当前帧: http//jsfiddle.net/893aM/1/

There is a decent Video Frame JS lib to work with frames https://github.com/X3TechnologyGroup/VideoFrame 有一个像样的Video Frame JS lib可以使用框架https://github.com/X3TechnologyGroup/VideoFrame

It's very old question, but this may be useful for new readers. 这是一个非常古老的问题,但这可能对新读者有用。

Ref: Get frame numbers in HTML5 Video 参考: 在HTML5视频中获取帧编号

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM