@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.
@@ -13,8 +13,8 @@ import {
13
13
  import { calculateNearBlackRatio } from './restorationMetrics.js';
14
14
  import { resolveGeminiWatermarkSearchCatalogEntries } from './geminiSizeCatalog.js';
15
15
  import { measureOutputResidualLocalization } from './outputResidualLocalization.js';
16
- import { hasReliableStandardWatermarkSignal } from './watermarkPresence.js';
17
- import { shouldPreferFullStrengthNewMarginVariant } from './candidateEvaluation.js';
16
+ import { hasReliableStandardWatermarkSignal } from './watermarkPresence.js';
17
+ import { shouldPreferFullStrengthNewMarginVariant } from './candidateEvaluation.js';
18
18
 
19
19
  const AGGRESSIVE_FALLBACK_MAX_ABS_SPATIAL = 0.22;
20
20
  const AGGRESSIVE_FALLBACK_MAX_NEAR_BLACK_INCREASE = 0.05;
@@ -218,9 +218,9 @@ function createExact48R96SourceWitnessRescueTrial({
218
218
  },
219
219
  alphaMap: alpha48,
220
220
  alphaGain: 1,
221
- provenance: {
222
- catalogVariant: true,
223
- catalogFamily: catalogEntry.metadata.family,
221
+ provenance: {
222
+ catalogVariant: true,
223
+ catalogFamily: catalogEntry.metadata.family,
224
224
  catalogSourcePriority: catalogEntry.metadata.sourcePriority,
225
225
  catalogEvidenceGate: catalogEntry.metadata.evidenceGate
226
226
  }
@@ -337,7 +337,7 @@ function createExact96R192SourceWitnessRescueTrial({
337
337
  )
338
338
  )
339
339
  );
340
- const sourceLocalization = measureOutputResidualLocalization({
340
+ const sourceLocalization = measureOutputResidualLocalization({
341
341
  imageData: originalImageData,
342
342
  alphaMap,
343
343
  position,
@@ -371,53 +371,53 @@ function createExact96R192SourceWitnessRescueTrial({
371
371
  return null;
372
372
  }
373
373
 
374
- const baselineNearBlackRatio = calculateNearBlackRatio(
375
- originalImageData,
376
- position
377
- );
378
- const provenance = {
379
- catalogVariant: true,
380
- alphaVariant: '20260520',
381
- catalogFamily: catalogEntry.metadata.family,
382
- catalogSourcePriority: catalogEntry.metadata.sourcePriority,
383
- catalogEvidenceGate: catalogEntry.metadata.evidenceGate,
384
- sourceWitnessRescue: true,
385
- sourceWitnessReason: EXACT_96_R192_SOURCE_WITNESS_REASON,
386
- sourceWitnessGate: {
387
- spatialSignedTarget: spatialSignal,
388
- spatialPercentile,
389
- gradientSignedTarget: gradientSignal,
390
- twoSidedEdgeProminence:
391
- sourceLocalization.twoSidedEdgeProminence,
392
- twoSidedEdgePercentile:
393
- sourceLocalization.twoSidedEdgePercentile
394
- }
395
- };
396
- const createRescueTrial = (alphaGain) => evaluateRestorationCandidate({
397
- originalImageData,
398
- alphaMap,
399
- position,
400
- source: 'standard+catalog+source-witness-rescue',
401
- config: catalogEntry.config,
402
- baselineNearBlackRatio,
403
- alphaGain,
404
- provenance,
405
- includeImageData: false
406
- });
407
- const conservativeTrial = createRescueTrial(EXACT_96_R192_SOURCE_WITNESS_GAIN);
408
- const fullStrengthTrial = spatialSignal > 0 ? createRescueTrial(1) : null;
409
- const rescueTrial = fullStrengthTrial &&
410
- shouldPreferFullStrengthNewMarginVariant(fullStrengthTrial, conservativeTrial)
411
- ? fullStrengthTrial
412
- : conservativeTrial;
413
- if (
414
- acceptedEligibleTrials.length > 0 &&
415
- !hasDriftedDarkPolaritySelection &&
416
- rescueTrial !== fullStrengthTrial
417
- ) {
418
- return null;
419
- }
420
- return measurePresenceLocalization(
374
+ const baselineNearBlackRatio = calculateNearBlackRatio(
375
+ originalImageData,
376
+ position
377
+ );
378
+ const provenance = {
379
+ catalogVariant: true,
380
+ alphaVariant: '20260520',
381
+ catalogFamily: catalogEntry.metadata.family,
382
+ catalogSourcePriority: catalogEntry.metadata.sourcePriority,
383
+ catalogEvidenceGate: catalogEntry.metadata.evidenceGate,
384
+ sourceWitnessRescue: true,
385
+ sourceWitnessReason: EXACT_96_R192_SOURCE_WITNESS_REASON,
386
+ sourceWitnessGate: {
387
+ spatialSignedTarget: spatialSignal,
388
+ spatialPercentile,
389
+ gradientSignedTarget: gradientSignal,
390
+ twoSidedEdgeProminence:
391
+ sourceLocalization.twoSidedEdgeProminence,
392
+ twoSidedEdgePercentile:
393
+ sourceLocalization.twoSidedEdgePercentile
394
+ }
395
+ };
396
+ const createRescueTrial = (alphaGain) => evaluateRestorationCandidate({
397
+ originalImageData,
398
+ alphaMap,
399
+ position,
400
+ source: 'standard+catalog+source-witness-rescue',
401
+ config: catalogEntry.config,
402
+ baselineNearBlackRatio,
403
+ alphaGain,
404
+ provenance,
405
+ includeImageData: false
406
+ });
407
+ const conservativeTrial = createRescueTrial(EXACT_96_R192_SOURCE_WITNESS_GAIN);
408
+ const fullStrengthTrial = spatialSignal > 0 ? createRescueTrial(1) : null;
409
+ const rescueTrial = fullStrengthTrial &&
410
+ shouldPreferFullStrengthNewMarginVariant(fullStrengthTrial, conservativeTrial)
411
+ ? fullStrengthTrial
412
+ : conservativeTrial;
413
+ if (
414
+ acceptedEligibleTrials.length > 0 &&
415
+ !hasDriftedDarkPolaritySelection &&
416
+ rescueTrial !== fullStrengthTrial
417
+ ) {
418
+ return null;
419
+ }
420
+ return measurePresenceLocalization(
421
421
  originalImageData,
422
422
  rescueTrial
423
423
  ).repeatedTemplateCollision
@@ -425,6 +425,78 @@ function createExact96R192SourceWitnessRescueTrial({
425
425
  : rescueTrial;
426
426
  }
427
427
 
428
+ function getPositiveSourceEvidenceScore(trial) {
429
+ const spatial = Number(trial?.originalSpatialScore);
430
+ const gradient = Number(trial?.originalGradientScore);
431
+ return Math.max(
432
+ Number.isFinite(spatial) ? spatial : Number.NEGATIVE_INFINITY,
433
+ Number.isFinite(gradient) ? gradient : Number.NEGATIVE_INFINITY
434
+ );
435
+ }
436
+
437
+ function findCanonical96CatalogPriorTrial({
438
+ fixedSelection,
439
+ automaticSelection,
440
+ catalogPriorConfig
441
+ }) {
442
+ if (
443
+ catalogPriorConfig?.logoSize !== 96 ||
444
+ catalogPriorConfig.marginRight !== 64 ||
445
+ catalogPriorConfig.marginBottom !== 64
446
+ ) {
447
+ return null;
448
+ }
449
+
450
+ const trials = [fixedSelection, automaticSelection]
451
+ .flatMap((selection) => [
452
+ ...(selection?.candidatePool ?? []),
453
+ selection?.selectedTrial
454
+ ])
455
+ .filter(Boolean);
456
+ const canonicalTrial = trials.find((trial) => (
457
+ trial.config?.logoSize === 96 &&
458
+ trial.config.marginRight === 64 &&
459
+ trial.config.marginBottom === 64 &&
460
+ !trial.config.alphaVariant &&
461
+ trial.provenance?.darkPolarity !== true &&
462
+ trial.alphaGain === 1
463
+ ));
464
+ if (!canonicalTrial) return null;
465
+
466
+ return {
467
+ ...canonicalTrial,
468
+ source: `${canonicalTrial.source ?? 'standard'}+catalog-prior-best-effort`,
469
+ provenance: {
470
+ ...canonicalTrial.provenance,
471
+ sourceWitnessRescue: true,
472
+ sourceWitnessReason: 'canonical-96-prior-over-weaker-r192',
473
+ catalogPriorBestEffort: true
474
+ }
475
+ };
476
+ }
477
+
478
+ function selectExact96SourceWitnessTrial({
479
+ r192Trial,
480
+ fixedSelection,
481
+ automaticSelection,
482
+ catalogPriorConfig
483
+ }) {
484
+ if (!r192Trial) return null;
485
+ const canonicalTrial = findCanonical96CatalogPriorTrial({
486
+ fixedSelection,
487
+ automaticSelection,
488
+ catalogPriorConfig
489
+ });
490
+ if (
491
+ !canonicalTrial ||
492
+ getPositiveSourceEvidenceScore(canonicalTrial) <=
493
+ getPositiveSourceEvidenceScore(r192Trial)
494
+ ) {
495
+ return r192Trial;
496
+ }
497
+ return canonicalTrial;
498
+ }
499
+
428
500
  function isSafeAggressiveFallbackSelection(selection) {
429
501
  const trial = selection?.selectedTrial;
430
502
  const spatial = Number(trial?.processedSpatialScore);
@@ -989,9 +1061,15 @@ export function collectInitialWatermarkCandidates(input = {}) {
989
1061
  fixedSelection,
990
1062
  automaticSelection
991
1063
  });
1064
+ const exact96SourceWitnessTrial = selectExact96SourceWitnessTrial({
1065
+ r192Trial: exact96R192SourceWitnessRescueTrial,
1066
+ fixedSelection,
1067
+ automaticSelection,
1068
+ catalogPriorConfig: input.catalogPriorConfig
1069
+ });
992
1070
  const sourceWitnessRescueTrial =
993
1071
  exact48R96SourceWitnessRescueTrial ??
994
- exact96R192SourceWitnessRescueTrial;
1072
+ exact96SourceWitnessTrial;
995
1073
  const bestEffortSelections = presenceConfirmed ||
996
1074
  sourceWitnessRescueTrial
997
1075
  ? []
@@ -1201,9 +1279,9 @@ export function collectInitialWatermarkCandidates(input = {}) {
1201
1279
  const hypotheses = [...preferredHypotheses, ...retainedAlternatives]
1202
1280
  .map((hypothesis) => ({
1203
1281
  ...hypothesis,
1204
- presenceStatus: !presenceConfirmed && sourceWitnessRescueTrial
1205
- ? 'source-witness'
1206
- : bestEffortFallback
1282
+ presenceStatus: !presenceConfirmed && sourceWitnessRescueTrial
1283
+ ? 'source-witness'
1284
+ : bestEffortFallback
1207
1285
  ? 'selector-only'
1208
1286
  : 'confirmed',
1209
1287
  discoveryRole:
@@ -1229,8 +1307,8 @@ export function collectInitialWatermarkCandidates(input = {}) {
1229
1307
  hypotheses,
1230
1308
  presenceConfirmed,
1231
1309
  bestEffortFallback,
1232
- bestEffortReason: bestEffortFallback && sourceWitnessRescueTrial
1233
- ? sourceWitnessRescueTrial.provenance?.sourceWitnessReason ??
1310
+ bestEffortReason: bestEffortFallback && sourceWitnessRescueTrial
1311
+ ? sourceWitnessRescueTrial.provenance?.sourceWitnessReason ??
1234
1312
  'source-witness'
1235
1313
  : bestEffortFallback
1236
1314
  ? 'presence-witness-unconfirmed'
@@ -309,12 +309,12 @@ const STRONG_POSITIVE_FINE_TUNE_EXTRA_GAINS = Object.freeze([0.95, 1]);
309
309
  const STRONG_POSITIVE_FINE_TUNE_MAX_ACCEPTED_SPATIAL = 0.12;
310
310
  const STRONG_POSITIVE_FINE_TUNE_MAX_ACCEPTED_GRADIENT = 0.25;
311
311
  const STRONG_POSITIVE_FINE_TUNE_MAX_POSITIVE_HALO_LUM = 4;
312
- const CANONICAL_96_MODERATE_SIGNAL_MIN_ORIGINAL_SPATIAL = 0.4;
313
- const CANONICAL_96_MODERATE_SIGNAL_MIN_ORIGINAL_GRADIENT = 0.1;
314
- const CANONICAL_96_MODERATE_SIGNAL_MAX_CURRENT_SPATIAL = 0.26;
315
- const CANONICAL_96_MODERATE_SIGNAL_MAX_CURRENT_GRADIENT = 0.04;
316
- const FULL_STRENGTH_NEW_MARGIN_MIN_ORIGINAL_GRADIENT = 0.08;
317
- const FULL_STRENGTH_NEW_MARGIN_MAX_CURRENT_GRADIENT = 0.1;
312
+ const CANONICAL_96_MODERATE_SIGNAL_MIN_ORIGINAL_SPATIAL = 0.4;
313
+ const CANONICAL_96_MODERATE_SIGNAL_MIN_ORIGINAL_GRADIENT = 0.1;
314
+ const CANONICAL_96_MODERATE_SIGNAL_MAX_CURRENT_SPATIAL = 0.26;
315
+ const CANONICAL_96_MODERATE_SIGNAL_MAX_CURRENT_GRADIENT = 0.04;
316
+ const FULL_STRENGTH_NEW_MARGIN_MIN_ORIGINAL_GRADIENT = 0.08;
317
+ const FULL_STRENGTH_NEW_MARGIN_MAX_CURRENT_GRADIENT = 0.1;
318
318
  const CANONICAL_96_POSITIVE_HALO_RESCUE_MIN_ORIGINAL_SPATIAL = 0.4;
319
319
  const CANONICAL_96_POSITIVE_HALO_RESCUE_MIN_ORIGINAL_GRADIENT = 0.3;
320
320
  const CANONICAL_96_POSITIVE_HALO_RESCUE_MAX_ABS_CURRENT_SPATIAL = 0.12;
@@ -3722,28 +3722,28 @@ function shouldSkipLocatedAggressiveForCleanCanonical96({
3722
3722
  return false;
3723
3723
  }
3724
3724
 
3725
- const cleanExactNewMarginVariant =
3726
- config?.logoSize === 96 &&
3727
- config.marginRight === 192 &&
3725
+ const cleanExactNewMarginVariant =
3726
+ config?.logoSize === 96 &&
3727
+ config.marginRight === 192 &&
3728
3728
  config.marginBottom === 192 &&
3729
3729
  config.alphaVariant === '20260520' &&
3730
3730
  resolvedAlphaGain <= 1.3 &&
3731
3731
  originalSpatial >= 0.18 &&
3732
3732
  originalSpatial < 0.4 &&
3733
3733
  originalGradient >= 0.05 &&
3734
- originalGradient < 0.08;
3735
- if (cleanExactNewMarginVariant) return true;
3736
-
3737
- const cleanFullStrengthNewMarginVariant =
3738
- config?.logoSize === 96 &&
3739
- config.marginRight === 192 &&
3740
- config.marginBottom === 192 &&
3741
- config.alphaVariant === '20260520' &&
3742
- resolvedAlphaGain === 1 &&
3743
- originalSpatial > 0 &&
3744
- originalGradient >= FULL_STRENGTH_NEW_MARGIN_MIN_ORIGINAL_GRADIENT &&
3745
- currentGradient <= FULL_STRENGTH_NEW_MARGIN_MAX_CURRENT_GRADIENT;
3746
- if (cleanFullStrengthNewMarginVariant) return true;
3734
+ originalGradient < 0.08;
3735
+ if (cleanExactNewMarginVariant) return true;
3736
+
3737
+ const cleanFullStrengthNewMarginVariant =
3738
+ config?.logoSize === 96 &&
3739
+ config.marginRight === 192 &&
3740
+ config.marginBottom === 192 &&
3741
+ config.alphaVariant === '20260520' &&
3742
+ resolvedAlphaGain === 1 &&
3743
+ originalSpatial > 0 &&
3744
+ originalGradient >= FULL_STRENGTH_NEW_MARGIN_MIN_ORIGINAL_GRADIENT &&
3745
+ currentGradient <= FULL_STRENGTH_NEW_MARGIN_MAX_CURRENT_GRADIENT;
3746
+ if (cleanFullStrengthNewMarginVariant) return true;
3747
3747
 
3748
3748
  if (
3749
3749
  config?.logoSize !== 96 ||
package/src/sdk/node.d.ts CHANGED
@@ -1,56 +1,56 @@
1
- import type { ImageDataRemovalResult, RemoveOptions, WatermarkMeta } from './index.js';
2
- export type {
3
- VideoBufferRemovalOptions,
4
- VideoBufferRemovalResult,
5
- VideoFileRemovalOptions,
6
- VideoFileRemovalResult,
7
- VideoProcessingProgress,
8
- VideoRemovalMeta
9
- } from './video.js';
10
-
11
- export interface NodeCodecContext {
12
- mimeType: string;
13
- filePath?: string;
14
- meta?: WatermarkMeta;
15
- }
16
-
17
- export interface NodeBufferRemovalOptions extends Omit<RemoveOptions, 'engine'> {
18
- mimeType?: string;
19
- filePath?: string;
20
- decodeImageData: (
21
- input: Buffer | Uint8Array | ArrayBuffer,
22
- context: NodeCodecContext
23
- ) => Promise<ImageDataRemovalResult['imageData']> | ImageDataRemovalResult['imageData'];
24
- encodeImageData: (
25
- imageData: ImageDataRemovalResult['imageData'],
26
- context: NodeCodecContext
27
- ) => Promise<Buffer | Uint8Array | ArrayBuffer> | Buffer | Uint8Array | ArrayBuffer;
28
- }
29
-
30
- export interface NodeFileRemovalOptions extends NodeBufferRemovalOptions {
31
- outputPath?: string | null;
32
- }
33
-
34
- export interface NodeBufferRemovalResult extends ImageDataRemovalResult {
35
- buffer: Buffer;
36
- }
37
-
38
- export interface NodeFileRemovalResult extends NodeBufferRemovalResult {
39
- outputPath: string | null;
40
- }
41
-
42
- export function inferMimeTypeFromPath(filePath: string): string;
43
- export function removeWatermarkFromBuffer(
44
- inputBuffer: Buffer | Uint8Array | ArrayBuffer,
45
- options: NodeBufferRemovalOptions
46
- ): Promise<NodeBufferRemovalResult>;
47
- export function removeWatermarkFromFile(
48
- inputPath: string,
49
- options: NodeFileRemovalOptions
50
- ): Promise<NodeFileRemovalResult>;
51
- export {
52
- inferVideoMimeTypeFromPath,
53
- isVideoMimeType,
54
- removeVideoWatermarkFromBuffer,
55
- removeVideoWatermarkFromFile
56
- } from './video.js';
1
+ import type { ImageDataRemovalResult, RemoveOptions, WatermarkMeta } from './index.js';
2
+ export type {
3
+ VideoBufferRemovalOptions,
4
+ VideoBufferRemovalResult,
5
+ VideoFileRemovalOptions,
6
+ VideoFileRemovalResult,
7
+ VideoProcessingProgress,
8
+ VideoRemovalMeta
9
+ } from './video.js';
10
+
11
+ export interface NodeCodecContext {
12
+ mimeType: string;
13
+ filePath?: string;
14
+ meta?: WatermarkMeta;
15
+ }
16
+
17
+ export interface NodeBufferRemovalOptions extends Omit<RemoveOptions, 'engine'> {
18
+ mimeType?: string;
19
+ filePath?: string;
20
+ decodeImageData: (
21
+ input: Buffer | Uint8Array | ArrayBuffer,
22
+ context: NodeCodecContext
23
+ ) => Promise<ImageDataRemovalResult['imageData']> | ImageDataRemovalResult['imageData'];
24
+ encodeImageData: (
25
+ imageData: ImageDataRemovalResult['imageData'],
26
+ context: NodeCodecContext
27
+ ) => Promise<Buffer | Uint8Array | ArrayBuffer> | Buffer | Uint8Array | ArrayBuffer;
28
+ }
29
+
30
+ export interface NodeFileRemovalOptions extends NodeBufferRemovalOptions {
31
+ outputPath?: string | null;
32
+ }
33
+
34
+ export interface NodeBufferRemovalResult extends ImageDataRemovalResult {
35
+ buffer: Buffer;
36
+ }
37
+
38
+ export interface NodeFileRemovalResult extends NodeBufferRemovalResult {
39
+ outputPath: string | null;
40
+ }
41
+
42
+ export function inferMimeTypeFromPath(filePath: string): string;
43
+ export function removeWatermarkFromBuffer(
44
+ inputBuffer: Buffer | Uint8Array | ArrayBuffer,
45
+ options: NodeBufferRemovalOptions
46
+ ): Promise<NodeBufferRemovalResult>;
47
+ export function removeWatermarkFromFile(
48
+ inputPath: string,
49
+ options: NodeFileRemovalOptions
50
+ ): Promise<NodeFileRemovalResult>;
51
+ export {
52
+ inferVideoMimeTypeFromPath,
53
+ isVideoMimeType,
54
+ removeVideoWatermarkFromBuffer,
55
+ removeVideoWatermarkFromFile
56
+ } from './video.js';
@@ -1,24 +1,24 @@
1
- export interface VideoRemovalMeta {
1
+ export interface VideoRemovalMeta {
2
2
  status?: string;
3
3
  denoiseBackend?: string;
4
4
  actualDenoiseBackend?: string;
5
5
  actualControls?: Record<string, unknown>;
6
6
  pagePath?: string;
7
7
  [key: string]: unknown;
8
- }
9
-
10
- export interface VideoProcessingProgress {
11
- tone: string;
12
- status: string;
13
- progressText: string;
14
- progress: number | null;
15
- phase: string | null;
16
- processedFrames: number | null;
17
- frameEstimate: number | null;
18
- aiDenoiseFrames: number | null;
19
- aiReuseFrames: number | null;
20
- elapsedMs: number;
21
- }
8
+ }
9
+
10
+ export interface VideoProcessingProgress {
11
+ tone: string;
12
+ status: string;
13
+ progressText: string;
14
+ progress: number | null;
15
+ phase: string | null;
16
+ processedFrames: number | null;
17
+ frameEstimate: number | null;
18
+ aiDenoiseFrames: number | null;
19
+ aiReuseFrames: number | null;
20
+ elapsedMs: number;
21
+ }
22
22
 
23
23
  export interface VideoFileProcessorContext {
24
24
  outputPath?: string | null;
@@ -32,10 +32,10 @@ export interface VideoFileProcessorContext {
32
32
  residualCleanupStrength?: number;
33
33
  videoBitrate?: number;
34
34
  adaptiveAlpha?: boolean;
35
- alphaGain?: number;
36
- alphaProfile?: string;
37
- onProgress?: (progress: VideoProcessingProgress) => void;
38
- }
35
+ alphaGain?: number;
36
+ alphaProfile?: string;
37
+ onProgress?: (progress: VideoProcessingProgress) => void;
38
+ }
39
39
 
40
40
  export interface VideoBufferProcessorContext extends Omit<VideoFileProcessorContext, 'filePath'> {
41
41
  filePath?: string;
@@ -57,10 +57,10 @@ export interface VideoFileRemovalOptions {
57
57
  residualCleanupStrength?: number;
58
58
  videoBitrate?: number;
59
59
  adaptiveAlpha?: boolean;
60
- alphaGain?: number;
61
- alphaProfile?: string;
62
- onProgress?: (progress: VideoProcessingProgress) => void;
63
- processVideoFile?: (
60
+ alphaGain?: number;
61
+ alphaProfile?: string;
62
+ onProgress?: (progress: VideoProcessingProgress) => void;
63
+ processVideoFile?: (
64
64
  inputPath: string,
65
65
  context: VideoFileProcessorContext
66
66
  ) => Promise<VideoProcessorResult> | VideoProcessorResult;
package/src/sdk/video.js CHANGED
@@ -2,14 +2,14 @@ import path from 'node:path';
2
2
  import { createReadStream } from 'node:fs';
3
3
  import { createServer } from 'node:http';
4
4
  import { access, mkdir, readFile, stat, writeFile } from 'node:fs/promises';
5
- import { fileURLToPath } from 'node:url';
6
- import {
7
- DEFAULT_VIDEO_TIMEOUT_MS,
8
- configureVideoPageTimeouts,
9
- waitForVideoProcessing
10
- } from './videoProgress.js';
11
-
12
- const DEFAULT_VIDEO_DENOISE_BACKEND = 'allenk-fdncnn-browser-spike';
5
+ import { fileURLToPath } from 'node:url';
6
+ import {
7
+ DEFAULT_VIDEO_TIMEOUT_MS,
8
+ configureVideoPageTimeouts,
9
+ waitForVideoProcessing
10
+ } from './videoProgress.js';
11
+
12
+ const DEFAULT_VIDEO_DENOISE_BACKEND = 'allenk-fdncnn-browser-spike';
13
13
 
14
14
  function normalizeBufferLike(value) {
15
15
  if (Buffer.isBuffer(value)) return value;
@@ -204,11 +204,11 @@ async function processVideoWithPreviewPage(inputPath, options = {}) {
204
204
  edgeDenoiseStrength,
205
205
  residualCleanupStrength,
206
206
  videoBitrate,
207
- adaptiveAlpha = false,
208
- alphaGain,
209
- alphaProfile,
210
- onProgress
211
- } = options;
207
+ adaptiveAlpha = false,
208
+ alphaGain,
209
+ alphaProfile,
210
+ onProgress
211
+ } = options;
212
212
 
213
213
  if (!isHttpUrl(pagePath)) {
214
214
  await assertReadableFile(pagePath, 'Video preview page');
@@ -220,8 +220,8 @@ async function processVideoWithPreviewPage(inputPath, options = {}) {
220
220
  const browser = await chromium.launch({ headless: true });
221
221
  try {
222
222
  return await withLocalVideoPreviewPage(pagePath, async (pageUrl) => {
223
- const page = await browser.newPage();
224
- configureVideoPageTimeouts(page);
223
+ const page = await browser.newPage();
224
+ configureVideoPageTimeouts(page);
225
225
  await page.goto(pageUrl);
226
226
  await page.locator('#fileInput').setInputFiles(inputPath);
227
227
  await page.evaluate((value) => {
@@ -271,10 +271,10 @@ async function processVideoWithPreviewPage(inputPath, options = {}) {
271
271
  }
272
272
 
273
273
  await page.locator('#processBtn').click();
274
- const { status, tone } = await waitForVideoProcessing(page, {
275
- timeoutMs,
276
- onProgress
277
- });
274
+ const { status, tone } = await waitForVideoProcessing(page, {
275
+ timeoutMs,
276
+ onProgress
277
+ });
278
278
  if (tone !== 'success') {
279
279
  throw new Error(status || 'Video export failed');
280
280
  }