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

时间:2011-08-24 14:23:25

标签: javascript html5 html5-video

我目前正在尝试自定义HTML5视频播放器,以便我可以添加一个返回当前帧编号的按钮。

假设我有一个持续90秒的30fps视频。当我点击那个按钮时,我想让它打印出当前帧的编号。这可能吗?

3 个答案:

答案 0 :(得分:2)

我认为浏览器没有设置标准帧率,也没有任何方法可以使用html5视频开箱即用。你可以做的是使用每秒29.97帧的电视标准帧速率,然后将其乘以视频的当前时间,如下所示:(vid.currentTime * 29.97).toPrecision(6)

这是我设置的小提琴演示如何将其绑定到按钮以获取当前帧: http://jsfiddle.net/893aM/1/

答案 1 :(得分:2)

我认为您可以将以下API用于基于Webkit / Mozilla的浏览器:

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也在研究这里列出的一些统计数据。

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. 

我仍在调查IE9的决议......

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

答案 2 :(得分:1)

有一个不错的Video Frame JS lib可以处理帧 https://github.com/X3TechnologyGroup/VideoFrame

这是一个非常古老的问题,但这可能对新读者有用。

参考:Get frame numbers in HTML5 Video