我可以翻译成中文:我能否获得HTML5视频当前帧的编号?

9

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

假设我有一个持续90秒的30fps视频。当我点击该按钮时,我希望它打印出当前帧的编号。这是否可能?

3个回答

3
我认为在各种浏览器中没有设定标准帧速率的方式,也没有一种直接通过html5视频访问当前帧的方法。不过,你可以使用电视标准帧速率29.97帧每秒,并将其乘以视频的当前时间,如下所示:(vid.currentTime * 29.97).toPrecision(6)
这里有一个我设置的fiddle演示如何将其绑定到按钮以获取当前帧:http://jsfiddle.net/893aM/1/

2
尽管这是一个旧答案,请注意“电视标准”在美国和其他国家不同。大多数网络视频都以25FPS编码和拍摄。 - WesleyE
2
.currentTime的精度不足以达到每帧级别。 - Brad

2

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

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


webkit属性已更改 https://github.com/adobe/webkit/blob/master/ManualTests/video-statistics.html - Macbric

1

我使用FFmpeg软件和Quick Time Player进行了检查。有时,由VideoFrame给出的总帧数与FFmpeg给出的帧数相差1-2帧。 - Soorajlal K G

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接