@hyperframes/producer 0.8.183 → 0.8.184

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.
@@ -5233,6 +5233,7 @@ async function runCaptureStage(input) {
5233
5233
  if (progress.capturedFrames === 0) reportWorkerStartup(job, progress, onProgress);
5234
5234
  return;
5235
5235
  }
5236
+ if (progress.landedFrame) input.onFrameLanded?.(progress.landedFrame);
5236
5237
  job.framesRendered = progress.capturedFrames;
5237
5238
  checkDiskProjection(progress.capturedFrames);
5238
5239
  const frameProgress = progress.capturedFrames / progress.totalFrames;
@@ -5473,7 +5474,8 @@ import {
5473
5474
  formatFfmpegError,
5474
5475
  MIXED_AUDIO_FILENAME as MIXED_AUDIO_FILENAME2,
5475
5476
  resolveConfig,
5476
- runFfmpeg as runFfmpeg3
5477
+ runFfmpeg as runFfmpeg3,
5478
+ spawnStreamingEncoder as spawnStreamingEncoder4
5477
5479
  } from "@hyperframes/engine";
5478
5480
  import {
5479
5481
  clearGifFramesBeforeNext,
@@ -5610,6 +5612,30 @@ function startEncodeProgress(job, stage, onProgress) {
5610
5612
  });
5611
5613
  return (frames = total) => reportEncodeProgress(job, frames, total, onProgress, 75);
5612
5614
  }
5615
+ function resolveEngineConfig(input) {
5616
+ return input.engineConfig ?? input.job.config.producerConfig ?? resolveConfig();
5617
+ }
5618
+ function videoEncoderOptions(input, engineCfg) {
5619
+ const { job, preset } = input;
5620
+ return {
5621
+ fps: job.config.fps,
5622
+ width: input.width,
5623
+ height: input.height,
5624
+ codec: preset.codec,
5625
+ preset: preset.preset,
5626
+ quality: input.effectiveQuality,
5627
+ bitrate: input.effectiveBitrate,
5628
+ pixelFormat: preset.pixelFormat,
5629
+ vp9CpuUsed: engineCfg.vp9CpuUsed,
5630
+ useGpu: job.config.useGpu,
5631
+ hdr: preset.hdr,
5632
+ // Distributed chunk renders pass these so the encoder writes closed-GOP
5633
+ // keyframes that survive `-f concat -c copy` at assemble time. In-process
5634
+ // renders leave both undefined → preserves the existing open-GOP output.
5635
+ lockGopForChunkConcat: input.lockGopForChunkConcat === true,
5636
+ gopSize: input.gopSize
5637
+ };
5638
+ }
5613
5639
  async function runEncodeStage(input) {
5614
5640
  const {
5615
5641
  job,
@@ -5617,16 +5643,11 @@ async function runEncodeStage(input) {
5617
5643
  outputPath,
5618
5644
  framesDir,
5619
5645
  videoOnlyPath,
5620
- width,
5621
- height,
5622
5646
  needsAlpha,
5623
5647
  hasAudio,
5624
5648
  audioOutputPath,
5625
5649
  isPngSequence,
5626
5650
  isGif,
5627
- preset,
5628
- effectiveQuality,
5629
- effectiveBitrate,
5630
5651
  enableChunkedEncode,
5631
5652
  chunkedEncodeSize,
5632
5653
  abortSignal,
@@ -5656,7 +5677,7 @@ async function runEncodeStage(input) {
5656
5677
  encoded();
5657
5678
  return { encodeMs: Date.now() - stage5Start };
5658
5679
  }
5659
- const engineCfg = input.engineConfig ?? job.config.producerConfig ?? resolveConfig();
5680
+ const engineCfg = resolveEngineConfig(input);
5660
5681
  if (isGif) {
5661
5682
  const encoded = startEncodeProgress(job, "Encoding GIF", onProgress);
5662
5683
  if (hasAudio) {
@@ -5686,24 +5707,7 @@ async function runEncodeStage(input) {
5686
5707
  const videoEngineCfg = scaledEncodeTimeout > engineCfg.ffmpegEncodeTimeout ? { ...engineCfg, ffmpegEncodeTimeout: scaledEncodeTimeout } : engineCfg;
5687
5708
  const frameExt = frameFileExtension2(input.captureImageFormat);
5688
5709
  const framePattern = `frame_%06d.${frameExt}`;
5689
- const encoderOpts = {
5690
- fps: job.config.fps,
5691
- width,
5692
- height,
5693
- codec: preset.codec,
5694
- preset: preset.preset,
5695
- quality: effectiveQuality,
5696
- bitrate: effectiveBitrate,
5697
- pixelFormat: preset.pixelFormat,
5698
- vp9CpuUsed: engineCfg.vp9CpuUsed,
5699
- useGpu: job.config.useGpu,
5700
- hdr: preset.hdr,
5701
- // Distributed chunk renders pass these so the encoder writes closed-GOP
5702
- // keyframes that survive `-f concat -c copy` at assemble time. In-process
5703
- // renders leave both undefined → preserves the existing open-GOP output.
5704
- lockGopForChunkConcat: input.lockGopForChunkConcat === true,
5705
- gopSize: input.gopSize
5706
- };
5710
+ const encoderOpts = videoEncoderOptions(input, engineCfg);
5707
5711
  const encodeResult = enableChunkedEncode ? await encodeFramesChunkedConcat(
5708
5712
  framesDir,
5709
5713
  framePattern,
@@ -10245,6 +10249,12 @@ function validatePlanVideosForChunk(value) {
10245
10249
  );
10246
10250
  }
10247
10251
  }
10252
+ var MIN_FRAMES_PER_CHUNK_BROWSER = 20;
10253
+ function resolveChunkCaptureWorkers(framesInChunk, machineSized, maxCaptureWorkers) {
10254
+ if (maxCaptureWorkers === void 0) return machineSized;
10255
+ const byFrames = Math.floor(framesInChunk / MIN_FRAMES_PER_CHUNK_BROWSER);
10256
+ return Math.max(machineSized, Math.floor(Math.min(maxCaptureWorkers, byFrames)));
10257
+ }
10248
10258
  function resolveChunkFrameRange(slice, chunkIndex, frameRange) {
10249
10259
  if (frameRange === void 0) return { startFrame: slice.startFrame, endFrame: slice.endFrame };
10250
10260
  const { startFrame, endFrame } = frameRange;
@@ -10481,7 +10491,11 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
10481
10491
  deferredVideos.filter((video) => remoteVideoIds.has(video.videoId))
10482
10492
  )
10483
10493
  });
10484
- const chunkWorkerCount = calculateOptimalWorkers2(framesInChunk, void 0, cfg);
10494
+ const chunkWorkerCount = resolveChunkCaptureWorkers(
10495
+ framesInChunk,
10496
+ calculateOptimalWorkers2(framesInChunk, void 0, cfg),
10497
+ options?.maxCaptureWorkers
10498
+ );
10485
10499
  let session = null;
10486
10500
  let outputKind;
10487
10501
  let framesEncoded = 0;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "0.1.0",
3
3
  "buildId": "dev",
4
- "sha256": "ba14a236a2e876f93d6683f19606311590ca5ee22b8f08cbe0e1205eabf24464",
4
+ "sha256": "fea4702bf337d3efdccc5f67da5d2d744a83ac9ab0cde7a82b0a378ab7e8e211",
5
5
  "artifacts": {
6
6
  "iife": "hyperframe.runtime.iife.js",
7
7
  "esm": "hyperframe.runtime.mjs"