简体   繁体   English

如何获取 HTML5 中每一帧的像素数据<video>元素

[英]How can I get pixel data of every frame in a HTML5 <video> element

I'm thinking I'll have to wait for the video to finish loading, then set up an interval (at 1/24 sec.) to get the current frame data, for the duration of the video.我想我必须等待视频完成加载,然后设置一个时间间隔(1/24 秒)来获取当前帧数据,在视频的持续时间内。 But that seems pretty hacky and looks like it might skip frames and such…但这看起来很hacky,看起来它可能会跳帧等等......

So, is there a "onFrameChange" listener I can hook on to, so I can get every frame, or any other way to get the image data of every frame of a HTML5 video?那么,是否有我可以连接的“onFrameChange”侦听器,以便我可以获取每一帧,或者以任何其他方式获取 HTML5 视频的每一帧的图像数据?

Thanks in advance.提前致谢。

There is the timeUpdate event which is fired any time the time changes (through normal playback, or the user scrubbing the controls).timeUpdate事件会在时间改变时触发(通过正常播放,或用户擦洗控件)。 On Firefox, this is fired once per frame, though that assumption isn't portable to other browsers.在 Firefox 上,这是每帧触发一次,尽管该假设不能移植到其他浏览器。

I don't think that there's a portable way of doing what you mention.我不认为有一种可移植的方式来做你提到的事情。 I've advocated for timeUpdate to be more reliable, but haven't made much headway.我一直主张timeUpdate更可靠,但没有取得太大进展。 An interval at 1/24th of a second, or faster, may be the best way to do it. 1/24 秒或更快的间隔可能是最好的方法。

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

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