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

More accurate hb 2 pass logic #530

Merged
merged 1 commit into from
Nov 8, 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
14 changes: 7 additions & 7 deletions FlowPlugins/FlowHelpers/1.0.0/cliParsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.editreadyParser = exports.getFFmpegVar = exports.getFFmpegPercentage = exports.ffmpegParser = exports.handbrakeParser = void 0;
var handbrakeParser = function (_a) {
var str = _a.str;
var str = _a.str, hbPass = _a.hbPass;
if (typeof str !== 'string') {
return 0;
}
Expand All @@ -19,14 +19,14 @@ var handbrakeParser = function (_a) {
var outputNum = Number(output);
if (outputNum > 0) {
percentage = outputNum;
if (hbPass === 1) {
percentage /= 2;
}
else if (hbPass === 2) {
percentage = 50 + (percentage / 2);
}
}
}
if (str.includes('task 1 of 2')) {
percentage /= 2;
}
else if (str.includes('task 2 of 2')) {
percentage = 50 + (percentage / 2);
}
return percentage;
};
exports.handbrakeParser = handbrakeParser;
Expand Down
8 changes: 8 additions & 0 deletions FlowPlugins/FlowHelpers/1.0.0/cliUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ var CLI = /** @class */ (function () {
this.oldEstSize = 0;
this.oldProgress = 0;
this.lastProgCheck = 0;
this.hbPass = 0;
this.updateETA = function (perc) {
if (perc > 0) {
if (_this.lastProgCheck === 0) {
Expand Down Expand Up @@ -154,8 +155,15 @@ var CLI = /** @class */ (function () {
_this.config.jobLog(str);
}
if (_this.config.cli.toLowerCase().includes('handbrake')) {
if (str.includes('task 1 of 2')) {
_this.hbPass = 1;
}
else if (str.includes('task 2 of 2')) {
_this.hbPass = 2;
}
var percentage = (0, cliParsers_1.handbrakeParser)({
str: str,
hbPass: _this.hbPass,
});
if (percentage > 0) {
_this.updateETA(percentage);
Expand Down
16 changes: 9 additions & 7 deletions FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const handbrakeParser = ({
str,
hbPass,
}:
{
str: string
str: string,
hbPass: number
}): number => {
if (typeof str !== 'string') {
return 0;
Expand All @@ -25,13 +27,13 @@ const handbrakeParser = ({
const outputNum = Number(output);
if (outputNum > 0) {
percentage = outputNum;
}
}

if (str.includes('task 1 of 2')) {
percentage /= 2;
} else if (str.includes('task 2 of 2')) {
percentage = 50 + (percentage / 2);
if (hbPass === 1) {
percentage /= 2;
} else if (hbPass === 2) {
percentage = 50 + (percentage / 2);
}
}
}

return percentage;
Expand Down
10 changes: 10 additions & 0 deletions FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class CLI {

lastProgCheck = 0;

hbPass = 0;

constructor(config: Iconfig) {
this.config = config;
}
Expand Down Expand Up @@ -163,9 +165,17 @@ class CLI {
}

if (this.config.cli.toLowerCase().includes('handbrake')) {
if (str.includes('task 1 of 2')) {
this.hbPass = 1;
} else if (str.includes('task 2 of 2')) {
this.hbPass = 2;
}

const percentage = handbrakeParser({
str,
hbPass: this.hbPass,
});

if (percentage > 0) {
this.updateETA(percentage);
this.config.updateWorker({
Expand Down
Loading