javascript - 在网页上的视频/动画中移回 X 帧的最无延迟方式是什么?
问题描述
我将我的论文演示文稿放在网上,作为一个带有自定义控件的视频,用于在动画视频的“幻灯片”之间前进(类似于 powerpoint)。两个“幻灯片”之间的一些转换需要在大约 1 秒的循环中重复,而重复部分是延迟发生的地方。
这是我尝试过的唯一解决方案,因为我没有时间(演示文稿是在星期五),也没有了解其他视频/动画图像格式运作良好所需的专业知识。我将尝试使用不同的文件格式(ogg、webm),看看是否会有所不同。
<html>
<head>
</head>
<body>
<video
id="video-active"
width="640"
height="390"
controls="">
<source src="presentation.mp4" type="video/mp4">
</video>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
video = document.querySelector("#video-active");
framerate = 60;
thresholdFrameNo = 300;
timeToRevert = 0.5;
$(document).ready(function(){
document.querySelector("#video-active").defaultPlaybackRate = 1.0;
$("#video-active").on(
"timeupdate",
function(event){
onTrackedVideoFrame(this.currentTime, this.duration);
})});
function onTrackedVideoFrame(currentTime, duration){
currentFrame = Math.round(currentTime*framerate);
if(currentFrame > thresholdFrameNo){
video.currentTime -= timeToRevert;
}
}
</script>
</html>
我希望视频能很快到达半秒前的位置,但在播放之前它会在旧的搜索位置冻结一点(可能长达半秒)。
解决方案
推荐阅读
- c# - 有没有办法让 RazorEngine 抛出异常,使用 JSON 作为数据模型渲染模板?
- php - 为什么我的 for 循环只抓取第一个元素?
- android - 不调用 BLE 功能
- javascript - 用于显示我在 phonegap 应用上收听的音乐的 Javascript 代码
- na - GAM 回归 (mgcv) 如何处理重复值?
- php - 没有默认值的函数参数,我是否需要检查是否已定义?
- ios - iOS 扩展和试飞
- selenium - 使用 Nightwatch.js 时如何缩小特定网页?
- php - 每个产品类别和属性显示一个滑块
- dialogflow-es - Dialogflow Webhook V2 - 无法解析 webhook JSON 响应:找不到字段:消息 google.cloud.dialogflow.v2.WebhookResponse 中的有效负载