@pilio/gemini-watermark-remover 1.0.39 → 1.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/dist/video-app.js +1 -1
- package/package.json +1 -1
- package/src/cli/gwrCli.js +17 -17
- package/src/cli/gwrRemoveCommand.js +433 -433
- package/src/core/candidateEvaluation.js +137 -137
- package/src/core/geminiSizeCatalog.js +29 -0
- package/src/core/pipelineCandidateQuality.js +823 -823
- package/src/core/pipelineInitialSelection.js +137 -59
- package/src/core/watermarkProcessor.js +22 -22
- package/src/sdk/node.d.ts +56 -56
- package/src/sdk/video.d.ts +23 -23
- package/src/sdk/video.js +19 -19
- package/src/sdk/videoProgress.js +108 -108
package/src/sdk/videoProgress.js
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
const DEFAULT_VIDEO_TIMEOUT_MS = 6 * 60 * 1000;
|
|
2
|
-
const DEFAULT_VIDEO_PROGRESS_POLL_INTERVAL_MS = 1000;
|
|
3
|
-
const DEFAULT_VIDEO_PAGE_SETUP_TIMEOUT_MS = 30_000;
|
|
4
|
-
|
|
5
|
-
function delay(ms) {
|
|
6
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
async function readVideoProgressSnapshot(page) {
|
|
10
|
-
return page.evaluate(() => {
|
|
11
|
-
const status = document.getElementById('status');
|
|
12
|
-
const progressBar = document.getElementById('progressBar');
|
|
13
|
-
const progressText = document.getElementById('progressText');
|
|
14
|
-
const rawProgress = Number.parseFloat(progressBar?.style?.width || '');
|
|
15
|
-
const runtimeProgress = globalThis.__gwrVideoCliProgress;
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
tone: status?.dataset?.tone || '',
|
|
19
|
-
status: status?.textContent || '',
|
|
20
|
-
progressText: progressText?.textContent || '',
|
|
21
|
-
progress: Number.isFinite(runtimeProgress?.progress)
|
|
22
|
-
? Math.max(0, Math.min(1, runtimeProgress.progress))
|
|
23
|
-
: Number.isFinite(rawProgress)
|
|
24
|
-
? Math.max(0, Math.min(1, rawProgress / 100))
|
|
25
|
-
: null,
|
|
26
|
-
phase: runtimeProgress?.phase || null,
|
|
27
|
-
processedFrames: Number.isFinite(runtimeProgress?.processedFrames)
|
|
28
|
-
? runtimeProgress.processedFrames
|
|
29
|
-
: null,
|
|
30
|
-
frameEstimate: Number.isFinite(runtimeProgress?.frameEstimate)
|
|
31
|
-
? runtimeProgress.frameEstimate
|
|
32
|
-
: null,
|
|
33
|
-
aiDenoiseFrames: Number.isFinite(runtimeProgress?.aiDenoiseFrames)
|
|
34
|
-
? runtimeProgress.aiDenoiseFrames
|
|
35
|
-
: null,
|
|
36
|
-
aiReuseFrames: Number.isFinite(runtimeProgress?.aiReuseFrames)
|
|
37
|
-
? runtimeProgress.aiReuseFrames
|
|
38
|
-
: null
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function describeProgress(snapshot) {
|
|
44
|
-
return [snapshot?.progressText, snapshot?.status]
|
|
45
|
-
.map((value) => String(value || '').trim())
|
|
46
|
-
.filter(Boolean)
|
|
47
|
-
.filter((value, index, values) => values.indexOf(value) === index)
|
|
48
|
-
.join(' - ');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function configureVideoPageTimeouts(page) {
|
|
52
|
-
page.setDefaultTimeout(DEFAULT_VIDEO_PAGE_SETUP_TIMEOUT_MS);
|
|
53
|
-
page.setDefaultNavigationTimeout(DEFAULT_VIDEO_PAGE_SETUP_TIMEOUT_MS);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async function waitForVideoProcessing(page, options = {}) {
|
|
57
|
-
const timeoutMs = Number.isFinite(options.timeoutMs) && options.timeoutMs > 0
|
|
58
|
-
? options.timeoutMs
|
|
59
|
-
: DEFAULT_VIDEO_TIMEOUT_MS;
|
|
60
|
-
const pollIntervalMs = Number.isFinite(options.pollIntervalMs) && options.pollIntervalMs >= 0
|
|
61
|
-
? options.pollIntervalMs
|
|
62
|
-
: DEFAULT_VIDEO_PROGRESS_POLL_INTERVAL_MS;
|
|
63
|
-
const now = typeof options.now === 'function' ? options.now : Date.now;
|
|
64
|
-
const sleep = typeof options.sleep === 'function' ? options.sleep : delay;
|
|
65
|
-
const onProgress = typeof options.onProgress === 'function' ? options.onProgress : () => {};
|
|
66
|
-
const startedAt = now();
|
|
67
|
-
let lastActivityAt = startedAt;
|
|
68
|
-
let lastSnapshotKey = null;
|
|
69
|
-
|
|
70
|
-
while (true) {
|
|
71
|
-
const snapshot = await readVideoProgressSnapshot(page);
|
|
72
|
-
const elapsedMs = Math.max(0, now() - startedAt);
|
|
73
|
-
const result = { ...snapshot, elapsedMs };
|
|
74
|
-
const snapshotKey = JSON.stringify(snapshot);
|
|
75
|
-
if (snapshotKey !== lastSnapshotKey) {
|
|
76
|
-
lastActivityAt = now();
|
|
77
|
-
lastSnapshotKey = snapshotKey;
|
|
78
|
-
onProgress(result);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (snapshot.tone === 'success' || snapshot.tone === 'error') {
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const inactiveMs = Math.max(0, now() - lastActivityAt);
|
|
86
|
-
if (inactiveMs >= timeoutMs) {
|
|
87
|
-
const detail = describeProgress(snapshot);
|
|
88
|
-
const timeoutLabel = timeoutMs < 1000
|
|
89
|
-
? `${Math.round(timeoutMs)} ms`
|
|
90
|
-
: `${Math.round(timeoutMs / 1000)} seconds`;
|
|
91
|
-
throw new Error(
|
|
92
|
-
`Video processing made no progress for ${timeoutLabel}${detail ? ` at ${detail}` : ''}. ` +
|
|
93
|
-
'Increase --video-timeout-ms for unusually long files.'
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
await sleep(Math.min(pollIntervalMs, Math.max(0, timeoutMs - inactiveMs)));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export {
|
|
102
|
-
DEFAULT_VIDEO_PAGE_SETUP_TIMEOUT_MS,
|
|
103
|
-
DEFAULT_VIDEO_PROGRESS_POLL_INTERVAL_MS,
|
|
104
|
-
DEFAULT_VIDEO_TIMEOUT_MS,
|
|
105
|
-
configureVideoPageTimeouts,
|
|
106
|
-
describeProgress,
|
|
107
|
-
waitForVideoProcessing
|
|
108
|
-
};
|
|
1
|
+
const DEFAULT_VIDEO_TIMEOUT_MS = 6 * 60 * 1000;
|
|
2
|
+
const DEFAULT_VIDEO_PROGRESS_POLL_INTERVAL_MS = 1000;
|
|
3
|
+
const DEFAULT_VIDEO_PAGE_SETUP_TIMEOUT_MS = 30_000;
|
|
4
|
+
|
|
5
|
+
function delay(ms) {
|
|
6
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async function readVideoProgressSnapshot(page) {
|
|
10
|
+
return page.evaluate(() => {
|
|
11
|
+
const status = document.getElementById('status');
|
|
12
|
+
const progressBar = document.getElementById('progressBar');
|
|
13
|
+
const progressText = document.getElementById('progressText');
|
|
14
|
+
const rawProgress = Number.parseFloat(progressBar?.style?.width || '');
|
|
15
|
+
const runtimeProgress = globalThis.__gwrVideoCliProgress;
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
tone: status?.dataset?.tone || '',
|
|
19
|
+
status: status?.textContent || '',
|
|
20
|
+
progressText: progressText?.textContent || '',
|
|
21
|
+
progress: Number.isFinite(runtimeProgress?.progress)
|
|
22
|
+
? Math.max(0, Math.min(1, runtimeProgress.progress))
|
|
23
|
+
: Number.isFinite(rawProgress)
|
|
24
|
+
? Math.max(0, Math.min(1, rawProgress / 100))
|
|
25
|
+
: null,
|
|
26
|
+
phase: runtimeProgress?.phase || null,
|
|
27
|
+
processedFrames: Number.isFinite(runtimeProgress?.processedFrames)
|
|
28
|
+
? runtimeProgress.processedFrames
|
|
29
|
+
: null,
|
|
30
|
+
frameEstimate: Number.isFinite(runtimeProgress?.frameEstimate)
|
|
31
|
+
? runtimeProgress.frameEstimate
|
|
32
|
+
: null,
|
|
33
|
+
aiDenoiseFrames: Number.isFinite(runtimeProgress?.aiDenoiseFrames)
|
|
34
|
+
? runtimeProgress.aiDenoiseFrames
|
|
35
|
+
: null,
|
|
36
|
+
aiReuseFrames: Number.isFinite(runtimeProgress?.aiReuseFrames)
|
|
37
|
+
? runtimeProgress.aiReuseFrames
|
|
38
|
+
: null
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function describeProgress(snapshot) {
|
|
44
|
+
return [snapshot?.progressText, snapshot?.status]
|
|
45
|
+
.map((value) => String(value || '').trim())
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.filter((value, index, values) => values.indexOf(value) === index)
|
|
48
|
+
.join(' - ');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function configureVideoPageTimeouts(page) {
|
|
52
|
+
page.setDefaultTimeout(DEFAULT_VIDEO_PAGE_SETUP_TIMEOUT_MS);
|
|
53
|
+
page.setDefaultNavigationTimeout(DEFAULT_VIDEO_PAGE_SETUP_TIMEOUT_MS);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function waitForVideoProcessing(page, options = {}) {
|
|
57
|
+
const timeoutMs = Number.isFinite(options.timeoutMs) && options.timeoutMs > 0
|
|
58
|
+
? options.timeoutMs
|
|
59
|
+
: DEFAULT_VIDEO_TIMEOUT_MS;
|
|
60
|
+
const pollIntervalMs = Number.isFinite(options.pollIntervalMs) && options.pollIntervalMs >= 0
|
|
61
|
+
? options.pollIntervalMs
|
|
62
|
+
: DEFAULT_VIDEO_PROGRESS_POLL_INTERVAL_MS;
|
|
63
|
+
const now = typeof options.now === 'function' ? options.now : Date.now;
|
|
64
|
+
const sleep = typeof options.sleep === 'function' ? options.sleep : delay;
|
|
65
|
+
const onProgress = typeof options.onProgress === 'function' ? options.onProgress : () => {};
|
|
66
|
+
const startedAt = now();
|
|
67
|
+
let lastActivityAt = startedAt;
|
|
68
|
+
let lastSnapshotKey = null;
|
|
69
|
+
|
|
70
|
+
while (true) {
|
|
71
|
+
const snapshot = await readVideoProgressSnapshot(page);
|
|
72
|
+
const elapsedMs = Math.max(0, now() - startedAt);
|
|
73
|
+
const result = { ...snapshot, elapsedMs };
|
|
74
|
+
const snapshotKey = JSON.stringify(snapshot);
|
|
75
|
+
if (snapshotKey !== lastSnapshotKey) {
|
|
76
|
+
lastActivityAt = now();
|
|
77
|
+
lastSnapshotKey = snapshotKey;
|
|
78
|
+
onProgress(result);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (snapshot.tone === 'success' || snapshot.tone === 'error') {
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const inactiveMs = Math.max(0, now() - lastActivityAt);
|
|
86
|
+
if (inactiveMs >= timeoutMs) {
|
|
87
|
+
const detail = describeProgress(snapshot);
|
|
88
|
+
const timeoutLabel = timeoutMs < 1000
|
|
89
|
+
? `${Math.round(timeoutMs)} ms`
|
|
90
|
+
: `${Math.round(timeoutMs / 1000)} seconds`;
|
|
91
|
+
throw new Error(
|
|
92
|
+
`Video processing made no progress for ${timeoutLabel}${detail ? ` at ${detail}` : ''}. ` +
|
|
93
|
+
'Increase --video-timeout-ms for unusually long files.'
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
await sleep(Math.min(pollIntervalMs, Math.max(0, timeoutMs - inactiveMs)));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
DEFAULT_VIDEO_PAGE_SETUP_TIMEOUT_MS,
|
|
103
|
+
DEFAULT_VIDEO_PROGRESS_POLL_INTERVAL_MS,
|
|
104
|
+
DEFAULT_VIDEO_TIMEOUT_MS,
|
|
105
|
+
configureVideoPageTimeouts,
|
|
106
|
+
describeProgress,
|
|
107
|
+
waitForVideoProcessing
|
|
108
|
+
};
|