mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-15 02:05:54 -07:00
Use time status
This commit is contained in:
parent
138c3270f2
commit
1ba41207d3
2 changed files with 104 additions and 68 deletions
|
|
@ -51,7 +51,7 @@ var getFFmpegVar = function (_a) {
|
||||||
};
|
};
|
||||||
exports.getFFmpegVar = getFFmpegVar;
|
exports.getFFmpegVar = getFFmpegVar;
|
||||||
var getFFmpegPercentage = function (_a) {
|
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 frameCount01 = fc;
|
||||||
var VideoFrameRate = vf;
|
var VideoFrameRate = vf;
|
||||||
var Duration = d;
|
var Duration = d;
|
||||||
|
|
@ -60,14 +60,19 @@ var getFFmpegPercentage = function (_a) {
|
||||||
frameCount01 = Math.ceil(frameCount01);
|
frameCount01 = Math.ceil(frameCount01);
|
||||||
VideoFrameRate = Math.ceil(VideoFrameRate);
|
VideoFrameRate = Math.ceil(VideoFrameRate);
|
||||||
Duration = Math.ceil(Duration);
|
Duration = Math.ceil(Duration);
|
||||||
if (frameCount01 > 0) {
|
if (frame > 0) {
|
||||||
perc = ((frame / frameCount01) * 100);
|
if (frameCount01 > 0) {
|
||||||
|
perc = ((frame / frameCount01) * 100);
|
||||||
|
}
|
||||||
|
else if (VideoFrameRate > 0 && Duration > 0) {
|
||||||
|
perc = ((frame / (VideoFrameRate * Duration)) * 100);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
perc = (frame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (VideoFrameRate > 0 && Duration > 0) {
|
else if (time > 0 && Duration > 0) {
|
||||||
perc = ((frame / (VideoFrameRate * Duration)) * 100);
|
perc = ((time / Duration) * 100);
|
||||||
}
|
|
||||||
else {
|
|
||||||
perc = (frame);
|
|
||||||
}
|
}
|
||||||
var percString = perc.toFixed(2);
|
var percString = perc.toFixed(2);
|
||||||
// eslint-disable-next-line no-restricted-globals
|
// eslint-disable-next-line no-restricted-globals
|
||||||
|
|
@ -84,33 +89,45 @@ var ffmpegParser = function (_a) {
|
||||||
}
|
}
|
||||||
var percentage = 0;
|
var percentage = 0;
|
||||||
if (str.length >= 6) {
|
if (str.length >= 6) {
|
||||||
var n = str.indexOf('fps');
|
var frame = getFFmpegVar({
|
||||||
if (n >= 6) {
|
str: str,
|
||||||
// get frame
|
variable: 'frame',
|
||||||
var frame = getFFmpegVar({
|
});
|
||||||
str: str,
|
var time = 0;
|
||||||
variable: 'frame',
|
// get time
|
||||||
});
|
var timeStr = getFFmpegVar({
|
||||||
var frameRate = videoFrameRate || 0;
|
str: str,
|
||||||
var duration = 0;
|
variable: 'time',
|
||||||
if (ffprobeDuration
|
});
|
||||||
&& parseFloat(ffprobeDuration) > 0) {
|
if (timeStr) {
|
||||||
duration = parseFloat(ffprobeDuration);
|
var timeArr = timeStr.split(':');
|
||||||
}
|
if (timeArr.length === 3) {
|
||||||
else if (metaDuration) {
|
var hours = parseInt(timeArr[0], 10);
|
||||||
duration = metaDuration;
|
var minutes = parseInt(timeArr[1], 10);
|
||||||
}
|
var seconds = parseInt(timeArr[2], 10);
|
||||||
var per = getFFmpegPercentage({
|
time = (hours * 3600) + (minutes * 60) + seconds;
|
||||||
f: frame,
|
|
||||||
fc: frameCount,
|
|
||||||
vf: frameRate,
|
|
||||||
d: duration,
|
|
||||||
});
|
|
||||||
var outputNum = Number(per);
|
|
||||||
if (outputNum > 0) {
|
|
||||||
percentage = outputNum;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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;
|
return percentage;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -66,12 +66,13 @@ const getFFmpegVar = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFFmpegPercentage = ({
|
const getFFmpegPercentage = ({
|
||||||
|
time,
|
||||||
f,
|
f,
|
||||||
fc,
|
fc,
|
||||||
vf,
|
vf,
|
||||||
d,
|
d,
|
||||||
}: {
|
}: {
|
||||||
|
time: number,
|
||||||
f: string, fc: number, vf: number, d: number
|
f: string, fc: number, vf: number, d: number
|
||||||
}): number => {
|
}): number => {
|
||||||
let frameCount01: number = fc;
|
let frameCount01: number = fc;
|
||||||
|
|
@ -85,12 +86,16 @@ const getFFmpegPercentage = ({
|
||||||
VideoFrameRate = Math.ceil(VideoFrameRate);
|
VideoFrameRate = Math.ceil(VideoFrameRate);
|
||||||
Duration = Math.ceil(Duration);
|
Duration = Math.ceil(Duration);
|
||||||
|
|
||||||
if (frameCount01 > 0) {
|
if (frame > 0) {
|
||||||
perc = ((frame / frameCount01) * 100);
|
if (frameCount01 > 0) {
|
||||||
} else if (VideoFrameRate > 0 && Duration > 0) {
|
perc = ((frame / frameCount01) * 100);
|
||||||
perc = ((frame / (VideoFrameRate * Duration)) * 100);
|
} else if (VideoFrameRate > 0 && Duration > 0) {
|
||||||
} else {
|
perc = ((frame / (VideoFrameRate * Duration)) * 100);
|
||||||
perc = (frame);
|
} else {
|
||||||
|
perc = (frame);
|
||||||
|
}
|
||||||
|
} else if (time > 0 && Duration > 0) {
|
||||||
|
perc = ((time / Duration) * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
const percString = perc.toFixed(2);
|
const percString = perc.toFixed(2);
|
||||||
|
|
@ -124,40 +129,54 @@ const ffmpegParser = ({
|
||||||
|
|
||||||
let percentage = 0;
|
let percentage = 0;
|
||||||
if (str.length >= 6) {
|
if (str.length >= 6) {
|
||||||
const n = str.indexOf('fps');
|
const frame = getFFmpegVar({
|
||||||
|
str,
|
||||||
|
variable: 'frame',
|
||||||
|
});
|
||||||
|
|
||||||
if (n >= 6) {
|
let time = 0;
|
||||||
// get frame
|
|
||||||
const frame = getFFmpegVar({
|
|
||||||
str,
|
|
||||||
variable: 'frame',
|
|
||||||
});
|
|
||||||
|
|
||||||
const frameRate = videoFrameRate || 0;
|
// get time
|
||||||
let duration = 0;
|
const timeStr = getFFmpegVar({
|
||||||
|
str,
|
||||||
|
variable: 'time',
|
||||||
|
});
|
||||||
|
|
||||||
if (
|
if (timeStr) {
|
||||||
ffprobeDuration
|
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;
|
||||||
|
|
||||||
|
if (
|
||||||
|
ffprobeDuration
|
||||||
&& parseFloat(ffprobeDuration) > 0
|
&& parseFloat(ffprobeDuration) > 0
|
||||||
) {
|
) {
|
||||||
duration = parseFloat(ffprobeDuration);
|
duration = parseFloat(ffprobeDuration);
|
||||||
} else if (metaDuration) {
|
} else if (metaDuration) {
|
||||||
duration = metaDuration;
|
duration = metaDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
const per = getFFmpegPercentage(
|
const per = getFFmpegPercentage(
|
||||||
{
|
{
|
||||||
f: frame,
|
time,
|
||||||
fc: frameCount,
|
f: frame,
|
||||||
vf: frameRate,
|
fc: frameCount,
|
||||||
d: duration,
|
vf: frameRate,
|
||||||
},
|
d: duration,
|
||||||
);
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const outputNum = Number(per);
|
const outputNum = Number(per);
|
||||||
if (outputNum > 0) {
|
if (outputNum > 0) {
|
||||||
percentage = outputNum;
|
percentage = outputNum;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue