njh*_*jho 3 html javascript video html5-video
如何获得您在<video/>
元素中所处位置的帧精确计数?
我们知道:
currentTime
没有给你精确的时间 - 请参阅https://github.com/w3c/media-and-entertainment/issues/4显示浏览器可变性的示例:https ://daiz.github.io/frame-accurate-ish/
举例如下: https: //adhesive-smooth-product.glitch.me
我们可以看到以下工作可以frame
在整个示例视频中获得准确的计数 - 这是无法通过参数完成的currentTime
。
const updateCanvas = (now, metadata) => {
if (startTime === 0.0) {
startTime = now;
}
ctx.drawImage(video, 0, 0, width, height);
let frameOffset = 2
const frames = Math.round(metadata.mediaTime * fps) - frameOffset
fpsInfo.innerText = !isFinite(frames) ? 0 : frames;
metadataInfo.innerText = JSON.stringify(metadata, null, 2);
video.requestVideoFrameCallback(updateCanvas);
};
video.src =
"https://daiz.github.io/frame-accurate-ish/time.mp4";
video.requestVideoFrameCallback(updateCanvas);
Run Code Online (Sandbox Code Playgroud)
frameOffset
const frames = Math.round(metadata.mediaTime * fps)
必须通过查看等于 at 来确定time = 0
。
感谢博客文章: https: //blog.tomayac.com/2020/05/15/the-requestvideoframecallback-api/
归档时间: |
|
查看次数: |
2201 次 |
最近记录: |