Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use time status #511

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 50 additions & 33 deletions FlowPlugins/FlowHelpers/1.0.0/cliParsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -60,14 +60,19 @@ var getFFmpegPercentage = function (_a) {
frameCount01 = Math.ceil(frameCount01);
VideoFrameRate = Math.ceil(VideoFrameRate);
Duration = Math.ceil(Duration);
if (frameCount01 > 0) {
perc = ((frame / frameCount01) * 100);
}
else if (VideoFrameRate > 0 && Duration > 0) {
perc = ((frame / (VideoFrameRate * Duration)) * 100);
if (frame > 0) {
if (frameCount01 > 0) {
perc = ((frame / frameCount01) * 100);
}
else if (VideoFrameRate > 0 && Duration > 0) {
perc = ((frame / (VideoFrameRate * Duration)) * 100);
}
else {
perc = (frame);
}
}
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
Expand All @@ -84,33 +89,45 @@ 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 frameRate = videoFrameRate || 0;
var duration = 0;
if (ffprobeDuration
&& parseFloat(ffprobeDuration) > 0) {
duration = parseFloat(ffprobeDuration);
}
else if (metaDuration) {
duration = metaDuration;
}
var per = getFFmpegPercentage({
f: frame,
fc: frameCount,
vf: frameRate,
d: duration,
});
var outputNum = Number(per);
if (outputNum > 0) {
percentage = outputNum;
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
&& parseFloat(ffprobeDuration) > 0) {
duration = parseFloat(ffprobeDuration);
}
else if (metaDuration) {
duration = metaDuration;
}
var per = getFFmpegPercentage({
time: time,
f: frame,
fc: frameCount,
vf: frameRate,
d: duration,
});
var outputNum = Number(per);
if (outputNum > 0) {
percentage = outputNum;
}
}
return percentage;
};
Expand Down
93 changes: 56 additions & 37 deletions FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -85,12 +86,16 @@ const getFFmpegPercentage = ({
VideoFrameRate = Math.ceil(VideoFrameRate);
Duration = Math.ceil(Duration);

if (frameCount01 > 0) {
perc = ((frame / frameCount01) * 100);
} else if (VideoFrameRate > 0 && Duration > 0) {
perc = ((frame / (VideoFrameRate * Duration)) * 100);
} else {
perc = (frame);
if (frame > 0) {
if (frameCount01 > 0) {
perc = ((frame / frameCount01) * 100);
} else if (VideoFrameRate > 0 && Duration > 0) {
perc = ((frame / (VideoFrameRate * Duration)) * 100);
} else {
perc = (frame);
}
} else if (time > 0 && Duration > 0) {
perc = ((time / Duration) * 100);
}

const percString = perc.toFixed(2);
Expand Down Expand Up @@ -124,40 +129,54 @@ 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',
});
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;
const frameRate = videoFrameRate || 0;
let duration = 0;

if (
ffprobeDuration
if (
ffprobeDuration
&& parseFloat(ffprobeDuration) > 0
) {
duration = parseFloat(ffprobeDuration);
} else if (metaDuration) {
duration = metaDuration;
}
) {
duration = parseFloat(ffprobeDuration);
} else if (metaDuration) {
duration = metaDuration;
}

const per = getFFmpegPercentage(
{
f: frame,
fc: frameCount,
vf: frameRate,
d: duration,
},
);

const outputNum = Number(per);
if (outputNum > 0) {
percentage = outputNum;
}
const per = getFFmpegPercentage(
{
time,
f: frame,
fc: frameCount,
vf: frameRate,
d: duration,
},
);

const outputNum = Number(per);
if (outputNum > 0) {
percentage = outputNum;
}
}

Expand Down
Loading