Use time status

make-only-subtitle-default
HaveAGitGat 2 years ago
parent 138c3270f2
commit 1ba41207d3

@ -51,7 +51,7 @@ var getFFmpegVar = function (_a) {
};
exports.getFFmpegVar = getFFmpegVar;
var getFFmpegPercentage = function (_a) {
var f = _a.f, fc = _a.fc, vf = _a.vf, d = _a.d;
var time = _a.time, f = _a.f, fc = _a.fc, vf = _a.vf, d = _a.d;
var frameCount01 = fc;
var VideoFrameRate = vf;
var Duration = d;
@ -60,6 +60,7 @@ var getFFmpegPercentage = function (_a) {
frameCount01 = Math.ceil(frameCount01);
VideoFrameRate = Math.ceil(VideoFrameRate);
Duration = Math.ceil(Duration);
if (frame > 0) {
if (frameCount01 > 0) {
perc = ((frame / frameCount01) * 100);
}
@ -69,6 +70,10 @@ var getFFmpegPercentage = function (_a) {
else {
perc = (frame);
}
}
else if (time > 0 && Duration > 0) {
perc = ((time / Duration) * 100);
}
var percString = perc.toFixed(2);
// eslint-disable-next-line no-restricted-globals
if (isNaN(perc)) {
@ -84,13 +89,25 @@ var ffmpegParser = function (_a) {
}
var percentage = 0;
if (str.length >= 6) {
var n = str.indexOf('fps');
if (n >= 6) {
// get frame
var frame = getFFmpegVar({
str: str,
variable: 'frame',
});
var time = 0;
// get time
var timeStr = getFFmpegVar({
str: str,
variable: 'time',
});
if (timeStr) {
var timeArr = timeStr.split(':');
if (timeArr.length === 3) {
var hours = parseInt(timeArr[0], 10);
var minutes = parseInt(timeArr[1], 10);
var seconds = parseInt(timeArr[2], 10);
time = (hours * 3600) + (minutes * 60) + seconds;
}
}
var frameRate = videoFrameRate || 0;
var duration = 0;
if (ffprobeDuration
@ -101,6 +118,7 @@ var ffmpegParser = function (_a) {
duration = metaDuration;
}
var per = getFFmpegPercentage({
time: time,
f: frame,
fc: frameCount,
vf: frameRate,
@ -111,7 +129,6 @@ var ffmpegParser = function (_a) {
percentage = outputNum;
}
}
}
return percentage;
};
exports.ffmpegParser = ffmpegParser;

@ -66,12 +66,13 @@ const getFFmpegVar = ({
};
const getFFmpegPercentage = ({
time,
f,
fc,
vf,
d,
}: {
time: number,
f: string, fc: number, vf: number, d: number
}): number => {
let frameCount01: number = fc;
@ -85,6 +86,7 @@ const getFFmpegPercentage = ({
VideoFrameRate = Math.ceil(VideoFrameRate);
Duration = Math.ceil(Duration);
if (frame > 0) {
if (frameCount01 > 0) {
perc = ((frame / frameCount01) * 100);
} else if (VideoFrameRate > 0 && Duration > 0) {
@ -92,6 +94,9 @@ const getFFmpegPercentage = ({
} else {
perc = (frame);
}
} else if (time > 0 && Duration > 0) {
perc = ((time / Duration) * 100);
}
const percString = perc.toFixed(2);
@ -124,15 +129,29 @@ const ffmpegParser = ({
let percentage = 0;
if (str.length >= 6) {
const n = str.indexOf('fps');
if (n >= 6) {
// get frame
const frame = getFFmpegVar({
str,
variable: 'frame',
});
let time = 0;
// get time
const timeStr = getFFmpegVar({
str,
variable: 'time',
});
if (timeStr) {
const timeArr = timeStr.split(':');
if (timeArr.length === 3) {
const hours = parseInt(timeArr[0], 10);
const minutes = parseInt(timeArr[1], 10);
const seconds = parseInt(timeArr[2], 10);
time = (hours * 3600) + (minutes * 60) + seconds;
}
}
const frameRate = videoFrameRate || 0;
let duration = 0;
@ -147,6 +166,7 @@ const ffmpegParser = ({
const per = getFFmpegPercentage(
{
time,
f: frame,
fc: frameCount,
vf: frameRate,
@ -159,7 +179,6 @@ const ffmpegParser = ({
percentage = outputNum;
}
}
}
return percentage;
};

Loading…
Cancel
Save