@remotion/web-renderer 4.0.434 → 4.0.436

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.
@@ -4088,6 +4088,7 @@ var createWebFsTarget = async () => {
4088
4088
  };
4089
4089
 
4090
4090
  // src/render-media-on-web.tsx
4091
+ var MAX_RECENT_FRAME_TIMINGS = 150;
4091
4092
  var internalRenderMediaOnWeb = async ({
4092
4093
  composition,
4093
4094
  inputProps,
@@ -4223,6 +4224,10 @@ var internalRenderMediaOnWeb = async ({
4223
4224
  }) : null, 0);
4224
4225
  const totalFrames = realFrameRange[1] - realFrameRange[0] + 1;
4225
4226
  const durationInSeconds = totalFrames / resolved.fps;
4227
+ const renderStart = Date.now();
4228
+ let doneIn = null;
4229
+ let renderEstimatedTime = 0;
4230
+ const recentFrameTimings = [];
4226
4231
  if (videoSampleSource) {
4227
4232
  outputWithCleanup.output.addVideoTrack(videoSampleSource.videoSampleSource, {
4228
4233
  maximumPacketCount: Math.ceil(totalFrames * 1.33)
@@ -4242,10 +4247,21 @@ var internalRenderMediaOnWeb = async ({
4242
4247
  if (signal?.aborted) {
4243
4248
  throw new Error("renderMediaOnWeb() was cancelled");
4244
4249
  }
4250
+ let timeOfLastFrame = Date.now();
4245
4251
  const progress = {
4246
4252
  renderedFrames: 0,
4247
4253
  encodedFrames: 0
4248
4254
  };
4255
+ const getProgressPayload = () => {
4256
+ const overallProgress = Math.round((70 * progress.renderedFrames + 30 * progress.encodedFrames) / totalFrames) / 100;
4257
+ return {
4258
+ renderedFrames: progress.renderedFrames,
4259
+ encodedFrames: progress.encodedFrames,
4260
+ doneIn,
4261
+ renderEstimatedTime,
4262
+ progress: overallProgress
4263
+ };
4264
+ };
4249
4265
  for (let frame = realFrameRange[0];frame <= realFrameRange[1]; frame++) {
4250
4266
  if (signal?.aborted) {
4251
4267
  throw new Error("renderMediaOnWeb() was cancelled");
@@ -4299,8 +4315,19 @@ var internalRenderMediaOnWeb = async ({
4299
4315
  });
4300
4316
  }
4301
4317
  }
4318
+ const now = Date.now();
4319
+ const timeToRenderInMilliseconds = now - timeOfLastFrame;
4320
+ timeOfLastFrame = now;
4302
4321
  progress.renderedFrames++;
4303
- throttledOnProgress?.({ ...progress });
4322
+ recentFrameTimings.push(timeToRenderInMilliseconds);
4323
+ if (recentFrameTimings.length > MAX_RECENT_FRAME_TIMINGS) {
4324
+ recentFrameTimings.shift();
4325
+ }
4326
+ const recentTimingsSum = recentFrameTimings.reduce((sum, time) => sum + time, 0);
4327
+ const newAverage = recentTimingsSum / recentFrameTimings.length;
4328
+ const remainingFrames = totalFrames - progress.renderedFrames;
4329
+ renderEstimatedTime = Math.round(remainingFrames * newAverage);
4330
+ throttledOnProgress?.(getProgressPayload());
4304
4331
  const audioCombineStart = performance.now();
4305
4332
  const assets = collectAssets.current.collectAssets();
4306
4333
  if (onArtifact) {
@@ -4327,12 +4354,15 @@ var internalRenderMediaOnWeb = async ({
4327
4354
  await Promise.all(encodingPromises);
4328
4355
  internalState.addAddSampleTime(performance.now() - addSampleStart);
4329
4356
  progress.encodedFrames++;
4330
- throttledOnProgress?.({ ...progress });
4357
+ if (progress.encodedFrames === totalFrames) {
4358
+ doneIn = Date.now() - renderStart;
4359
+ }
4360
+ throttledOnProgress?.(getProgressPayload());
4331
4361
  if (signal?.aborted) {
4332
4362
  throw new Error("renderMediaOnWeb() was cancelled");
4333
4363
  }
4334
4364
  }
4335
- onProgress?.({ ...progress });
4365
+ onProgress?.(getProgressPayload());
4336
4366
  videoSampleSource?.videoSampleSource.close();
4337
4367
  audioSampleSource?.audioSampleSource.close();
4338
4368
  await outputWithCleanup.output.finalize();
@@ -22,8 +22,19 @@ type MandatoryRenderMediaOnWebOptions<Schema extends $ZodObject, Props extends R
22
22
  composition: CompositionCalculateMetadataOrExplicit<Schema, Props>;
23
23
  };
24
24
  export type RenderMediaOnWebProgress = {
25
+ /**
26
+ * @deprecated Kept for backward compatibility. Use `progress` for overall
27
+ * status updates.
28
+ */
25
29
  renderedFrames: number;
26
30
  encodedFrames: number;
31
+ /**
32
+ * The total time in milliseconds from render start until all frames were
33
+ * encoded, or `null` while encoding is still in progress.
34
+ */
35
+ doneIn: number | null;
36
+ renderEstimatedTime: number;
37
+ progress: number;
27
38
  };
28
39
  export type RenderMediaOnWebResult = {
29
40
  getBlob: () => Promise<Blob>;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/web-renderer"
4
4
  },
5
5
  "name": "@remotion/web-renderer",
6
- "version": "4.0.434",
6
+ "version": "4.0.436",
7
7
  "main": "dist/index.js",
8
8
  "type": "module",
9
9
  "scripts": {
@@ -22,16 +22,16 @@
22
22
  "@mediabunny/mp3-encoder": "1.37.0",
23
23
  "@mediabunny/aac-encoder": "1.37.0",
24
24
  "@mediabunny/flac-encoder": "1.37.0",
25
- "@remotion/licensing": "4.0.434",
26
- "remotion": "4.0.434",
25
+ "@remotion/licensing": "4.0.436",
26
+ "remotion": "4.0.436",
27
27
  "mediabunny": "1.37.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@react-three/fiber": "9.2.0",
31
- "@remotion/eslint-config-internal": "4.0.434",
32
- "@remotion/player": "4.0.434",
33
- "@remotion/media": "4.0.434",
34
- "@remotion/three": "4.0.434",
31
+ "@remotion/eslint-config-internal": "4.0.436",
32
+ "@remotion/player": "4.0.436",
33
+ "@remotion/media": "4.0.436",
34
+ "@remotion/three": "4.0.436",
35
35
  "@types/three": "0.170.0",
36
36
  "@typescript/native-preview": "7.0.0-dev.20260217.1",
37
37
  "@vitejs/plugin-react": "4.3.4",