@hyperframes/producer 0.9.28 → 0.9.29

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.
@@ -1637,6 +1637,10 @@ function estimateMeasuredCaptureCostMultiplier(samples) {
1637
1637
  return { multiplier: 1, reasons: [] };
1638
1638
  }
1639
1639
  const p95Ms = Math.round(p95Sample.captureTimeMs);
1640
+ const mid = sorted.length / 2;
1641
+ const medianMs = Math.round(
1642
+ sorted.length % 2 === 1 ? sorted[Math.floor(mid)].captureTimeMs : (sorted[mid - 1].captureTimeMs + sorted[mid].captureTimeMs) / 2
1643
+ );
1640
1644
  const multiplier = Math.min(
1641
1645
  MAX_MEASURED_CAPTURE_COST_MULTIPLIER,
1642
1646
  Math.max(1, Math.round(p95Ms / CAPTURE_CALIBRATION_TARGET_MS * 100) / 100)
@@ -1644,7 +1648,8 @@ function estimateMeasuredCaptureCostMultiplier(samples) {
1644
1648
  return {
1645
1649
  multiplier,
1646
1650
  reasons: multiplier > 1 ? [`calibration-p95=${p95Ms}ms`] : [],
1647
- p95Ms
1651
+ p95Ms,
1652
+ medianMs
1648
1653
  };
1649
1654
  }
1650
1655
  function selectCaptureCalibrationFrames(totalFrames) {
package/dist/index.js CHANGED
@@ -4988,7 +4988,7 @@ async function runCaptureSegmentedStage(input) {
4988
4988
 
4989
4989
  // src/services/render/renderEtaGuard.ts
4990
4990
  var RENDER_TOO_SLOW = "RENDER_TOO_SLOW";
4991
- var ETA_MARGIN = 1.2;
4991
+ var ETA_MARGIN = 2;
4992
4992
  var MIN_SAMPLE_MS = 6e4;
4993
4993
  var MIN_SAMPLE_FRAMES = 3;
4994
4994
  var POLL_MS = 5e3;
@@ -5016,6 +5016,15 @@ function checkRenderEta(stage, input) {
5016
5016
  if (etaMs <= maxRenderMs * ETA_MARGIN) return void 0;
5017
5017
  return new RenderTooSlowError(stage, { ...input, maxRenderMs, etaMs });
5018
5018
  }
5019
+ function checkCalibratedRenderEta(input) {
5020
+ return checkRenderEta("capture_calibration", {
5021
+ maxRenderMs: input.maxRenderMs,
5022
+ elapsedMs: input.elapsedMs,
5023
+ framesCompleted: 0,
5024
+ totalFrames: input.totalFrames,
5025
+ msPerFrame: (input.estimate?.medianMs ?? 0) / input.workerCount
5026
+ });
5027
+ }
5019
5028
  function createRateSampler() {
5020
5029
  let base;
5021
5030
  let lastFrames = 0;
@@ -5100,13 +5109,15 @@ function combineCaptureCostEstimates(staticCost, measuredCost) {
5100
5109
  return {
5101
5110
  multiplier: staticCost.multiplier,
5102
5111
  reasons: [...staticCost.reasons, ...measuredCost.reasons],
5103
- p95Ms: measuredCost.p95Ms
5112
+ p95Ms: measuredCost.p95Ms,
5113
+ medianMs: measuredCost.medianMs
5104
5114
  };
5105
5115
  }
5106
5116
  return {
5107
5117
  multiplier: measuredCost.multiplier,
5108
5118
  reasons: [...measuredCost.reasons, ...staticCost.reasons],
5109
- p95Ms: measuredCost.p95Ms
5119
+ p95Ms: measuredCost.p95Ms,
5120
+ medianMs: measuredCost.medianMs
5110
5121
  };
5111
5122
  }
5112
5123
  function buildHeapAdvisoryWarning(sizing, requestedWorkers) {
@@ -5172,6 +5183,10 @@ function estimateMeasuredCaptureCostMultiplier(samples) {
5172
5183
  return { multiplier: 1, reasons: [] };
5173
5184
  }
5174
5185
  const p95Ms = Math.round(p95Sample.captureTimeMs);
5186
+ const mid = sorted.length / 2;
5187
+ const medianMs = Math.round(
5188
+ sorted.length % 2 === 1 ? sorted[Math.floor(mid)].captureTimeMs : (sorted[mid - 1].captureTimeMs + sorted[mid].captureTimeMs) / 2
5189
+ );
5175
5190
  const multiplier = Math.min(
5176
5191
  MAX_MEASURED_CAPTURE_COST_MULTIPLIER,
5177
5192
  Math.max(1, Math.round(p95Ms / CAPTURE_CALIBRATION_TARGET_MS * 100) / 100)
@@ -5179,7 +5194,8 @@ function estimateMeasuredCaptureCostMultiplier(samples) {
5179
5194
  return {
5180
5195
  multiplier,
5181
5196
  reasons: multiplier > 1 ? [`calibration-p95=${p95Ms}ms`] : [],
5182
- p95Ms
5197
+ p95Ms,
5198
+ medianMs
5183
5199
  };
5184
5200
  }
5185
5201
  function selectCaptureCalibrationFrames(totalFrames) {
@@ -6270,7 +6286,7 @@ function isToleratedShortClipBoundaryMiss(report, threshold) {
6270
6286
  return threshold < 1 && report.capturedFrames > 0 && report.expectedFrames >= SHORT_CLIP_ONE_FRAME_TOLERANCE_MIN_EXPECTED_FRAMES && report.expectedFrames <= SHORT_CLIP_ONE_FRAME_TOLERANCE_MAX_EXPECTED_FRAMES && report.expectedFrames - report.capturedFrames === 1;
6271
6287
  }
6272
6288
  function expectedFramesForVideo(video, entry, fps) {
6273
- const rounding = entry && !entry.metadata.isVFR ? "nearest" : "ceil";
6289
+ const rounding = entry && !entry.metadata.isVFR ? "slots" : "ceil";
6274
6290
  const slotSourceDuration = sourceTimeAt(
6275
6291
  normalizeRateSpec(video.playbackRate),
6276
6292
  Math.max(0, video.end - video.start)
@@ -14903,7 +14919,8 @@ async function executeRenderPipeline(input) {
14903
14919
  observability.checkpoint("capture_calibration", "resolved", {
14904
14920
  forceScreenshot: captureForceScreenshot,
14905
14921
  multiplier: outcome.calibration?.estimate.multiplier ?? null,
14906
- p95Ms: outcome.calibration?.estimate.p95Ms ?? null
14922
+ p95Ms: outcome.calibration?.estimate.p95Ms ?? null,
14923
+ medianMs: outcome.calibration?.estimate.medianMs ?? null
14907
14924
  });
14908
14925
  } else {
14909
14926
  observability.checkpoint("capture_calibration", "skipped", {
@@ -15008,12 +15025,12 @@ async function executeRenderPipeline(input) {
15008
15025
  deWorkerInversion: deWorkerInversion ?? "none",
15009
15026
  deParallelRouter: deParallelRouter ?? "none"
15010
15027
  });
15011
- const calibratedTooSlow = checkRenderEta("capture_calibration", {
15028
+ const calibratedTooSlow = checkCalibratedRenderEta({
15012
15029
  maxRenderMs: job.config.maxRenderMs,
15013
15030
  elapsedMs: Date.now() - pipelineStart,
15014
- framesCompleted: 0,
15015
15031
  totalFrames,
15016
- msPerFrame: (captureCalibration?.estimate.p95Ms ?? 0) / workerCount
15032
+ estimate: captureCalibration?.estimate,
15033
+ workerCount
15017
15034
  });
15018
15035
  if (calibratedTooSlow) throw calibratedTooSlow;
15019
15036
  execution.defer(
@@ -5001,7 +5001,7 @@ async function runCaptureSegmentedStage(input) {
5001
5001
 
5002
5002
  // src/services/render/renderEtaGuard.ts
5003
5003
  var RENDER_TOO_SLOW = "RENDER_TOO_SLOW";
5004
- var ETA_MARGIN = 1.2;
5004
+ var ETA_MARGIN = 2;
5005
5005
  var MIN_SAMPLE_MS = 6e4;
5006
5006
  var MIN_SAMPLE_FRAMES = 3;
5007
5007
  var POLL_MS = 5e3;
@@ -5029,6 +5029,15 @@ function checkRenderEta(stage, input) {
5029
5029
  if (etaMs <= maxRenderMs * ETA_MARGIN) return void 0;
5030
5030
  return new RenderTooSlowError(stage, { ...input, maxRenderMs, etaMs });
5031
5031
  }
5032
+ function checkCalibratedRenderEta(input) {
5033
+ return checkRenderEta("capture_calibration", {
5034
+ maxRenderMs: input.maxRenderMs,
5035
+ elapsedMs: input.elapsedMs,
5036
+ framesCompleted: 0,
5037
+ totalFrames: input.totalFrames,
5038
+ msPerFrame: (input.estimate?.medianMs ?? 0) / input.workerCount
5039
+ });
5040
+ }
5032
5041
  function createRateSampler() {
5033
5042
  let base;
5034
5043
  let lastFrames = 0;
@@ -5113,13 +5122,15 @@ function combineCaptureCostEstimates(staticCost, measuredCost) {
5113
5122
  return {
5114
5123
  multiplier: staticCost.multiplier,
5115
5124
  reasons: [...staticCost.reasons, ...measuredCost.reasons],
5116
- p95Ms: measuredCost.p95Ms
5125
+ p95Ms: measuredCost.p95Ms,
5126
+ medianMs: measuredCost.medianMs
5117
5127
  };
5118
5128
  }
5119
5129
  return {
5120
5130
  multiplier: measuredCost.multiplier,
5121
5131
  reasons: [...measuredCost.reasons, ...staticCost.reasons],
5122
- p95Ms: measuredCost.p95Ms
5132
+ p95Ms: measuredCost.p95Ms,
5133
+ medianMs: measuredCost.medianMs
5123
5134
  };
5124
5135
  }
5125
5136
  function buildHeapAdvisoryWarning(sizing, requestedWorkers) {
@@ -5185,6 +5196,10 @@ function estimateMeasuredCaptureCostMultiplier(samples) {
5185
5196
  return { multiplier: 1, reasons: [] };
5186
5197
  }
5187
5198
  const p95Ms = Math.round(p95Sample.captureTimeMs);
5199
+ const mid = sorted.length / 2;
5200
+ const medianMs = Math.round(
5201
+ sorted.length % 2 === 1 ? sorted[Math.floor(mid)].captureTimeMs : (sorted[mid - 1].captureTimeMs + sorted[mid].captureTimeMs) / 2
5202
+ );
5188
5203
  const multiplier = Math.min(
5189
5204
  MAX_MEASURED_CAPTURE_COST_MULTIPLIER,
5190
5205
  Math.max(1, Math.round(p95Ms / CAPTURE_CALIBRATION_TARGET_MS * 100) / 100)
@@ -5192,7 +5207,8 @@ function estimateMeasuredCaptureCostMultiplier(samples) {
5192
5207
  return {
5193
5208
  multiplier,
5194
5209
  reasons: multiplier > 1 ? [`calibration-p95=${p95Ms}ms`] : [],
5195
- p95Ms
5210
+ p95Ms,
5211
+ medianMs
5196
5212
  };
5197
5213
  }
5198
5214
  function selectCaptureCalibrationFrames(totalFrames) {
@@ -6283,7 +6299,7 @@ function isToleratedShortClipBoundaryMiss(report, threshold) {
6283
6299
  return threshold < 1 && report.capturedFrames > 0 && report.expectedFrames >= SHORT_CLIP_ONE_FRAME_TOLERANCE_MIN_EXPECTED_FRAMES && report.expectedFrames <= SHORT_CLIP_ONE_FRAME_TOLERANCE_MAX_EXPECTED_FRAMES && report.expectedFrames - report.capturedFrames === 1;
6284
6300
  }
6285
6301
  function expectedFramesForVideo(video, entry, fps) {
6286
- const rounding = entry && !entry.metadata.isVFR ? "nearest" : "ceil";
6302
+ const rounding = entry && !entry.metadata.isVFR ? "slots" : "ceil";
6287
6303
  const slotSourceDuration = sourceTimeAt(
6288
6304
  normalizeRateSpec(video.playbackRate),
6289
6305
  Math.max(0, video.end - video.start)
@@ -14876,7 +14892,8 @@ async function executeRenderPipeline(input) {
14876
14892
  observability.checkpoint("capture_calibration", "resolved", {
14877
14893
  forceScreenshot: captureForceScreenshot,
14878
14894
  multiplier: outcome.calibration?.estimate.multiplier ?? null,
14879
- p95Ms: outcome.calibration?.estimate.p95Ms ?? null
14895
+ p95Ms: outcome.calibration?.estimate.p95Ms ?? null,
14896
+ medianMs: outcome.calibration?.estimate.medianMs ?? null
14880
14897
  });
14881
14898
  } else {
14882
14899
  observability.checkpoint("capture_calibration", "skipped", {
@@ -14981,12 +14998,12 @@ async function executeRenderPipeline(input) {
14981
14998
  deWorkerInversion: deWorkerInversion ?? "none",
14982
14999
  deParallelRouter: deParallelRouter ?? "none"
14983
15000
  });
14984
- const calibratedTooSlow = checkRenderEta("capture_calibration", {
15001
+ const calibratedTooSlow = checkCalibratedRenderEta({
14985
15002
  maxRenderMs: job.config.maxRenderMs,
14986
15003
  elapsedMs: Date.now() - pipelineStart,
14987
- framesCompleted: 0,
14988
15004
  totalFrames,
14989
- msPerFrame: (captureCalibration?.estimate.p95Ms ?? 0) / workerCount
15005
+ estimate: captureCalibration?.estimate,
15006
+ workerCount
14990
15007
  });
14991
15008
  if (calibratedTooSlow) throw calibratedTooSlow;
14992
15009
  execution.defer(
@@ -17,6 +17,7 @@ export interface CaptureCostEstimate {
17
17
  multiplier: number;
18
18
  reasons: string[];
19
19
  p95Ms?: number;
20
+ medianMs?: number;
20
21
  }
21
22
  export interface CaptureCalibrationSample {
22
23
  frameIndex: number;
@@ -19,6 +19,16 @@ export declare class RenderTooSlowError extends Error {
19
19
  }
20
20
  /** The one ETA decision, shared by the post-calibration and the measured-rate checks. */
21
21
  export declare function checkRenderEta(stage: string, input: RenderEtaInput): RenderTooSlowError | undefined;
22
+ /** The pre-capture check. The typical calibration frame predicts the render; the slowest one over-refuses. */
23
+ export declare function checkCalibratedRenderEta(input: {
24
+ maxRenderMs?: number;
25
+ elapsedMs: number;
26
+ totalFrames: number;
27
+ estimate?: {
28
+ medianMs?: number;
29
+ };
30
+ workerCount: number;
31
+ }): RenderTooSlowError | undefined;
22
32
  interface RenderEtaGuardOptions {
23
33
  maxRenderMs?: number;
24
34
  job: {
@@ -85,11 +85,11 @@ export declare function isVideoFrameCoverageError(err: unknown): err is VideoFra
85
85
  export declare function resolveVideoCoverageThreshold(envValue?: string | undefined): number | null;
86
86
  /**
87
87
  * Count frames in a clip's authored `[start,end)` window. CFR extraction
88
- * rounds to the nearest output-frame boundary and VFR extraction rounds up,
88
+ * fills every output slot the window covers and VFR extraction rounds up,
89
89
  * as `extractionFrameCountForDuration` does. Missing entries
90
90
  * retain the fail-closed `ceil` default. Positive sub-frame clips emit one.
91
91
  */
92
- export declare function expectedFramesForClip(start: number, end: number, fps: FpsInput, rounding?: "ceil" | "nearest"): number;
92
+ export declare function expectedFramesForClip(start: number, end: number, fps: FpsInput, rounding?: "ceil" | "slots"): number;
93
93
  export declare function computeVideoFrameCoverage(videos: readonly VideoElement[], extracted: readonly ExtractedFrames[], fps: FpsInput): VideoFrameCoverageReport[];
94
94
  /**
95
95
  * Throws `VideoFrameCoverageError` when any per-clip ratio is below
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/producer",
3
- "version": "0.9.28",
3
+ "version": "0.9.29",
4
4
  "description": "HTML-to-video rendering engine using Chrome's BeginFrame API",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,11 +35,11 @@
35
35
  "postcss": "^8.4.0",
36
36
  "puppeteer": "~25.11.0",
37
37
  "puppeteer-core": "^25.11.0",
38
- "@hyperframes/engine": "0.9.28",
39
- "@hyperframes/lint": "0.9.28",
40
- "@hyperframes/parsers": "0.9.28",
41
- "@hyperframes/studio-server": "0.9.28",
42
- "@hyperframes/core": "0.9.28"
38
+ "@hyperframes/engine": "0.9.29",
39
+ "@hyperframes/lint": "0.9.29",
40
+ "@hyperframes/studio-server": "0.9.29",
41
+ "@hyperframes/parsers": "0.9.29",
42
+ "@hyperframes/core": "0.9.29"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "^25.0.10",
@@ -48,7 +48,7 @@
48
48
  "tsx": "^4.21.0",
49
49
  "typescript": "^5.7.2",
50
50
  "vitest": "^4.1.11",
51
- "@hyperframes/aws-lambda": "0.9.28"
51
+ "@hyperframes/aws-lambda": "0.9.29"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=22"