每秒帧数问题

时间:2016-01-29 08:50:52

标签: javascript html5-video frame-rate

您好我创建了一个转换小时,分钟和每秒帧数的函数,即 - >

 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
});

}

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

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

不会这样做吗?

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