2011-08-24 57 views
9

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

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

回答

1

我不认为跨浏览器设置标准帧速率或以任何方式访问HTML5视频开箱即用的框架。你可以做的是使用29.97帧每秒的电视标准帧速率,并简单地乘以视频的当前时间,如下所示:(vid.currentTime * 29.97).toPrecision(6)

这里有一个小提琴我成立了演示如何把它绑定到一个按钮来获得当前帧: http://jsfiddle.net/893aM/1/

+1

虽然这是一个古老的回答,请注意,“电视标准”是不是在美国同世界其他地区。无论如何,大多数网络视频都是编码和拍摄的@ 25FPS。 – WesleyE

+0

'.currentTime'几乎不够准确,不足以达到每帧的水平。 – Brad

3

我想你可以使用Webkit的下列API /基于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

相关问题