我目前正在尝试自定义一个HTML5视频播放器,以便我可以添加一个返回当前帧数的按钮。
假设我有一个持续90秒的30fps视频。当我点击该按钮时,我希望它打印出当前帧的编号。这是否可能?
我目前正在尝试自定义一个HTML5视频播放器,以便我可以添加一个返回当前帧数的按钮。
假设我有一个持续90秒的30fps视频。当我点击该按钮时,我希望它打印出当前帧的编号。这是否可能?
(vid.currentTime * 29.97).toPrecision(6)
。我认为您可以在基于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
有一个不错的视频框架JS库可以用于帧操作https://github.com/X3TechnologyGroup/VideoFrame
这是一个很老的问题,但对新读者可能会有用。
参考文献:获取HTML5视频中的帧数
.currentTime
的精度不足以达到每帧级别。 - Brad