gpt4 book ai didi

javascript - 每秒帧数问题

转载 作者:行者123 更新时间:2023-12-03 07:49:02 26 4
gpt4 key购买 nike

嗨,我创建了一个函数,可以转换小时、分钟和每秒帧数,即 ->

 function toHHMMSS(seconds) {
var sec_num = parseInt(seconds);
var hours = Math.floor(sec_num / 3600);
var parshours = parseInt(hours);


var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var parsmin = parseInt(minutes);

var seconds = sec_num - (hours * 3600) - (minutes * 60);
var parssec = parseInt(seconds);

if (parshours < 10) { parshours = "0" + parshours; }
if (parsmin < 10) { parsmin = "0" + parsmin; }
if (parssec < 10) { parssec = "0" + parssec; }

// calculation for frames
var vidframes = document.getElementById('video');
timeFloat = parseInt(vidframes.currentTime * 25).toPrecision(4) / 60;
if (timeFloat > 25) {
timeFloat = 0;
}

frametestout = timeFloatOut - timeFloat;
frames = frametestout * frameRate;

var time = parshours + ':' + parsmin + ':' + parssec + ':' + timeFloat;

return time;
}
var timeFloat;
var timeFloatOut;


function getCurTime(e) {
var vid = document.getElementById('video');
timeFloat = parseInt(vid.currentTime);
var timeintime = document.getElementById('timein').innerHTML = toHHMMSS(timeFloat);
}

function getOutTime(e) {
var vid = document.getElementById('video');
timeFloatOut = parseInt(vid.currentTime);
var timeouttime = document.getElementById('timeOut').innerHTML = toHHMMSS(timeFloatOut);
var framecount = document.getElementById('frameCount').innerHTML = frames;
}

$("#btnTime").kendoButton({
click: getCurTime
});


$("#btnTimeOut").kendoButton({
click: getOutTime
});

}

问题是我需要每秒重置帧。而不是不断增加。

如有任何帮助,我们将不胜感激。

最佳答案

这不就可以了吗?

setTimeout(function(){
frames = 0;
},1000);

关于javascript - 每秒帧数问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35080329/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com