@remotion/renderer 3.3.100 → 3.3.102

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.
@@ -11,5 +11,5 @@ declare type Options = {
11
11
  totalSize: number | null;
12
12
  }) => void) | undefined;
13
13
  };
14
- export declare const downloadFile: (options: Options, retries?: number) => Promise<Response>;
14
+ export declare const downloadFile: (options: Options, retries?: number, attempt?: number) => Promise<Response>;
15
15
  export {};
@@ -4,6 +4,7 @@ exports.downloadFile = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const ensure_output_directory_1 = require("../ensure-output-directory");
6
6
  const read_file_1 = require("./read-file");
7
+ const incorrectContentLengthToken = 'Download finished with';
7
8
  const downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
8
9
  return new Promise((resolve, reject) => {
9
10
  let rejected = false;
@@ -76,7 +77,7 @@ const downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
76
77
  });
77
78
  res.on('close', () => {
78
79
  if (totalSize !== null && downloaded !== totalSize) {
79
- rejectAndFlag(new Error(`Download finished with ${downloaded} bytes, but expected ${totalSize} bytes from 'Content-Length'.`));
80
+ rejectAndFlag(new Error(`${incorrectContentLengthToken} ${downloaded} bytes, but expected ${totalSize} bytes from 'Content-Length'.`));
80
81
  }
81
82
  writeStream.close();
82
83
  });
@@ -86,17 +87,23 @@ const downloadFileWithoutRetries = ({ onProgress, url, to: toFn }) => {
86
87
  });
87
88
  });
88
89
  };
89
- const downloadFile = async (options, retries = 2) => {
90
+ const downloadFile = async (options, retries = 2, attempt = 1) => {
90
91
  try {
91
92
  const res = await downloadFileWithoutRetries(options);
92
93
  return res;
93
94
  }
94
95
  catch (err) {
95
- if (err.message === 'aborted') {
96
+ const { message } = err;
97
+ if (message === 'aborted' ||
98
+ message.includes(incorrectContentLengthToken)) {
96
99
  if (retries === 0) {
97
100
  throw err;
98
101
  }
99
- return (0, exports.downloadFile)(options, retries - 1);
102
+ const backoffInSeconds = (attempt + 1) ** 2;
103
+ await new Promise((resolve) => {
104
+ setTimeout(() => resolve(), backoffInSeconds * 1000);
105
+ });
106
+ return (0, exports.downloadFile)(options, retries - 1, attempt + 1);
100
107
  }
101
108
  throw err;
102
109
  }
package/dist/index.d.ts CHANGED
@@ -77,7 +77,7 @@ export declare const RenderInternals: {
77
77
  downloaded: number;
78
78
  totalSize: number | null;
79
79
  }) => void) | undefined;
80
- }, retries?: number) => Promise<{
80
+ }, retries?: number, attempt?: number) => Promise<{
81
81
  sizeInBytes: number;
82
82
  to: string;
83
83
  }>;
@@ -6,6 +6,16 @@ import type { ImageFormat } from './image-format';
6
6
  import type { CancelSignal } from './make-cancel-signal';
7
7
  import type { PixelFormat } from './pixel-format';
8
8
  import type { ProResProfile } from './prores-profile';
9
+ declare type RunningStatus = {
10
+ type: 'running';
11
+ } | {
12
+ type: 'quit-successfully';
13
+ stderr: string;
14
+ } | {
15
+ type: 'quit-with-error';
16
+ exitCode: number;
17
+ stderr: string;
18
+ };
9
19
  declare type PreSticherOptions = {
10
20
  fps: number;
11
21
  width: number;
@@ -26,5 +36,6 @@ declare type PreSticherOptions = {
26
36
  export declare const prespawnFfmpeg: (options: PreSticherOptions, remotionRoot: string) => Promise<{
27
37
  task: execa.ExecaChildProcess<string>;
28
38
  getLogs: () => string;
39
+ getExitStatus: () => RunningStatus;
29
40
  }>;
30
41
  export {};
@@ -95,6 +95,24 @@ const prespawnFfmpeg = async (options, remotionRoot) => {
95
95
  }
96
96
  }
97
97
  });
98
- return { task, getLogs: () => ffmpegOutput };
98
+ let exitCode = {
99
+ type: 'running',
100
+ };
101
+ task.on('exit', (code) => {
102
+ if (typeof code === 'number' && code > 0) {
103
+ exitCode = {
104
+ type: 'quit-with-error',
105
+ exitCode: code,
106
+ stderr: ffmpegOutput,
107
+ };
108
+ }
109
+ else {
110
+ exitCode = {
111
+ type: 'quit-successfully',
112
+ stderr: ffmpegOutput,
113
+ };
114
+ }
115
+ });
116
+ return { task, getLogs: () => ffmpegOutput, getExitStatus: () => exitCode };
99
117
  };
100
118
  exports.prespawnFfmpeg = prespawnFfmpeg;
@@ -252,6 +252,13 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
252
252
  return;
253
253
  }
254
254
  const id = (0, perf_1.startPerfMeasure)('piping');
255
+ const exitStatus = preStitcher === null || preStitcher === void 0 ? void 0 : preStitcher.getExitStatus();
256
+ if ((exitStatus === null || exitStatus === void 0 ? void 0 : exitStatus.type) === 'quit-successfully') {
257
+ throw new Error(`FFmpeg already quit while trying to pipe frame ${frame} to it. Stderr: ${exitStatus.stderr}}`);
258
+ }
259
+ if ((exitStatus === null || exitStatus === void 0 ? void 0 : exitStatus.type) === 'quit-with-error') {
260
+ throw new Error(`FFmpeg quit with code ${exitStatus.exitCode} while piping frame ${frame}. Stderr: ${exitStatus.stderr}}`);
261
+ }
255
262
  (_a = stitcherFfmpeg === null || stitcherFfmpeg === void 0 ? void 0 : stitcherFfmpeg.stdin) === null || _a === void 0 ? void 0 : _a.write(buffer);
256
263
  (0, perf_1.stopPerfMeasure)(id);
257
264
  setFrameToStitch(Math.min(realFrameRange[1] + 1, frame + everyNthFrame));
@@ -116,7 +116,7 @@ const setPropsAndEnv = (params) => {
116
116
  new Promise((_, reject) => {
117
117
  setTimeout(() => {
118
118
  reject(new Error('Timed out while setting up the headless browser - the browser seems to not respond. This error is thrown to trigger a retry.'));
119
- }, 10000);
119
+ }, 20000);
120
120
  }),
121
121
  ]);
122
122
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/renderer",
3
- "version": "3.3.100",
3
+ "version": "3.3.102",
4
4
  "description": "Renderer for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "dependencies": {
17
17
  "execa": "5.1.1",
18
18
  "extract-zip": "2.0.1",
19
- "remotion": "3.3.100",
19
+ "remotion": "3.3.102",
20
20
  "source-map": "^0.8.0-beta.0",
21
21
  "ws": "8.7.0"
22
22
  },
@@ -41,13 +41,13 @@
41
41
  "vitest": "0.24.3"
42
42
  },
43
43
  "optionalDependencies": {
44
- "@remotion/compositor-darwin-arm64": "3.3.100",
45
- "@remotion/compositor-darwin-x64": "3.3.100",
46
- "@remotion/compositor-linux-arm64-gnu": "3.3.100",
47
- "@remotion/compositor-linux-arm64-musl": "3.3.100",
48
- "@remotion/compositor-linux-x64-gnu": "3.3.100",
49
- "@remotion/compositor-linux-x64-musl": "3.3.100",
50
- "@remotion/compositor-win32-x64-msvc": "3.3.100"
44
+ "@remotion/compositor-darwin-arm64": "3.3.102",
45
+ "@remotion/compositor-darwin-x64": "3.3.102",
46
+ "@remotion/compositor-linux-arm64-gnu": "3.3.102",
47
+ "@remotion/compositor-linux-arm64-musl": "3.3.102",
48
+ "@remotion/compositor-linux-x64-gnu": "3.3.102",
49
+ "@remotion/compositor-linux-x64-musl": "3.3.102",
50
+ "@remotion/compositor-win32-x64-msvc": "3.3.102"
51
51
  },
52
52
  "keywords": [
53
53
  "remotion",