@remotion/renderer 4.0.33 → 4.0.35

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.
Files changed (41) hide show
  1. package/dist/browser/Product.d.ts +16 -0
  2. package/dist/browser/Product.js +17 -0
  3. package/dist/browser/create-browser-fetcher.d.ts +17 -0
  4. package/dist/browser/create-browser-fetcher.js +58 -0
  5. package/dist/browser/revisions.d.ts +20 -0
  6. package/dist/browser/revisions.js +21 -0
  7. package/dist/client.d.ts +23 -23
  8. package/dist/create-ffmpeg-complex-filter.d.ts +4 -1
  9. package/dist/get-available-memory.d.ts +1 -0
  10. package/dist/get-available-memory.js +47 -0
  11. package/dist/get-concurrency.js +6 -9
  12. package/dist/get-cpu-count.d.ts +1 -0
  13. package/dist/get-cpu-count.js +26 -0
  14. package/dist/get-extension-from-codec.d.ts +2 -2
  15. package/dist/get-video-threads-flag.js +4 -6
  16. package/dist/index.d.ts +21 -23
  17. package/dist/options/audio-bitrate.d.ts +0 -1
  18. package/dist/options/color-space.d.ts +1 -2
  19. package/dist/options/crf.d.ts +0 -1
  20. package/dist/options/enforce-audio.d.ts +0 -1
  21. package/dist/options/jpeg-quality.d.ts +0 -1
  22. package/dist/options/mute.d.ts +0 -1
  23. package/dist/options/offthreadvideo-cache-size.d.ts +0 -1
  24. package/dist/options/offthreadvideo-cache-size.js +1 -1
  25. package/dist/options/options-map.d.ts +0 -1
  26. package/dist/options/scale.d.ts +0 -1
  27. package/dist/options/video-bitrate.d.ts +0 -1
  28. package/dist/options/video-codec.d.ts +0 -1
  29. package/dist/options/webhook-custom-data.d.ts +0 -1
  30. package/dist/prestitcher-memory-usage.js +2 -5
  31. package/dist/provide-screenshot.d.ts +0 -1
  32. package/dist/puppeteer-screenshot.d.ts +0 -1
  33. package/dist/render-media.js +7 -1
  34. package/dist/screenshot-dom-element.d.ts +0 -1
  35. package/dist/screenshot-task.d.ts +0 -1
  36. package/dist/stitch-frames-to-video.d.ts +0 -1
  37. package/dist/take-frame-and-compose.d.ts +0 -1
  38. package/dist/validate-concurrency.d.ts +1 -1
  39. package/dist/validate-concurrency.js +2 -1
  40. package/dist/validate-output-filename.d.ts +1 -1
  41. package/package.json +9 -9
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2020 Google Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export type Product = 'chrome' | 'firefox';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2020 Google Inc. All rights reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2020 Google Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { Product } from './Product';
17
+ export declare function downloadBrowser(product: Product): Promise<void>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2020 Google Inc. All rights reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.downloadBrowser = void 0;
19
+ const BrowserFetcher_1 = require("./BrowserFetcher");
20
+ const revisions_1 = require("./revisions");
21
+ const supportedProducts = {
22
+ chrome: 'Chromium',
23
+ firefox: 'Firefox Nightly',
24
+ };
25
+ function getRevision(product) {
26
+ if (product === 'chrome') {
27
+ return revisions_1.PUPPETEER_REVISIONS.chromium;
28
+ }
29
+ throw new Error(`Unsupported product ${product}`);
30
+ }
31
+ async function downloadBrowser(product) {
32
+ const revision = getRevision(product);
33
+ const revisionInfo = (0, BrowserFetcher_1.getRevisionInfo)(revision, product);
34
+ await (0, BrowserFetcher_1.download)({
35
+ revision: revisionInfo.revision,
36
+ progressCallback: (downloadedBytes, totalBytes) => {
37
+ console.log('Downloading', supportedProducts[product], toMegabytes(downloadedBytes) + '/' + toMegabytes(totalBytes));
38
+ },
39
+ product,
40
+ platform: (0, BrowserFetcher_1.getPlatform)(product),
41
+ downloadHost: (0, BrowserFetcher_1.getDownloadHost)(product),
42
+ downloadsFolder: (0, BrowserFetcher_1.getDownloadsFolder)(product),
43
+ });
44
+ const _localRevisions = await (0, BrowserFetcher_1.localRevisions)((0, BrowserFetcher_1.getDownloadsFolder)(product), product, (0, BrowserFetcher_1.getPlatform)(product));
45
+ console.log(`${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}`);
46
+ await Promise.all(_localRevisions
47
+ .filter((__revision) => {
48
+ return __revision !== revisionInfo.revision;
49
+ })
50
+ .map((__revision) => {
51
+ return (0, BrowserFetcher_1.removeBrowser)(__revision, (0, BrowserFetcher_1.getFolderPath)(revision, (0, BrowserFetcher_1.getDownloadsFolder)(product), (0, BrowserFetcher_1.getPlatform)(product)));
52
+ }));
53
+ }
54
+ exports.downloadBrowser = downloadBrowser;
55
+ function toMegabytes(bytes) {
56
+ const mb = bytes / 1024 / 1024;
57
+ return `${Math.round(mb * 10) / 10} Mb`;
58
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2020 Google Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ type Revisions = Readonly<{
17
+ readonly chromium: string;
18
+ }>;
19
+ export declare const PUPPETEER_REVISIONS: Revisions;
20
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2020 Google Inc. All rights reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.PUPPETEER_REVISIONS = void 0;
19
+ exports.PUPPETEER_REVISIONS = {
20
+ chromium: '1002410',
21
+ };
package/dist/client.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export declare const BrowserSafeApis: {
2
- getFileExtensionFromCodec: <T extends "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif">(codec: T, audioCodec: "mp3" | "aac" | "pcm-16" | "opus" | null) => import("./file-extensions").FileExtension;
2
+ getFileExtensionFromCodec: <T extends "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">(codec: T, audioCodec: "mp3" | "aac" | "pcm-16" | "opus" | null) => import("./file-extensions").FileExtension;
3
3
  validCodecs: readonly ["h264", "h265", "vp8", "vp9", "mp3", "aac", "wav", "prores", "h264-mkv", "gif"];
4
4
  validAudioCodecs: readonly ["pcm-16", "aac", "mp3", "opus"];
5
- getDefaultCrfForCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif") => number;
6
- getValidCrfRanges: (codec: "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif") => [number, number];
7
- isAudioCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif" | undefined) => boolean;
5
+ getDefaultCrfForCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => number;
6
+ getValidCrfRanges: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => [number, number];
7
+ isAudioCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif" | undefined) => boolean;
8
8
  proResProfileOptions: readonly ["4444-xq", "4444", "hq", "standard", "light", "proxy"];
9
9
  x264PresetOptions: readonly ["ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow", "placebo"];
10
10
  validPixelFormats: readonly ["yuv420p", "yuva420p", "yuv422p", "yuv444p", "yuv420p10le", "yuv422p10le", "yuv444p10le", "yuva444p10le"];
@@ -78,10 +78,10 @@ export declare const BrowserSafeApis: {
78
78
  };
79
79
  };
80
80
  };
81
- prores: {
81
+ mp3: {
82
82
  default: import("./file-extensions").FileExtension;
83
83
  forAudioCodec: {
84
- aac: {
84
+ mp3: {
85
85
  possible: import("./file-extensions").FileExtension[];
86
86
  default: import("./file-extensions").FileExtension;
87
87
  };
@@ -91,10 +91,10 @@ export declare const BrowserSafeApis: {
91
91
  };
92
92
  };
93
93
  };
94
- mp3: {
94
+ aac: {
95
95
  default: import("./file-extensions").FileExtension;
96
96
  forAudioCodec: {
97
- mp3: {
97
+ aac: {
98
98
  possible: import("./file-extensions").FileExtension[];
99
99
  default: import("./file-extensions").FileExtension;
100
100
  };
@@ -104,22 +104,22 @@ export declare const BrowserSafeApis: {
104
104
  };
105
105
  };
106
106
  };
107
- aac: {
107
+ wav: {
108
108
  default: import("./file-extensions").FileExtension;
109
109
  forAudioCodec: {
110
- aac: {
111
- possible: import("./file-extensions").FileExtension[];
112
- default: import("./file-extensions").FileExtension;
113
- };
114
110
  "pcm-16": {
115
111
  possible: import("./file-extensions").FileExtension[];
116
112
  default: import("./file-extensions").FileExtension;
117
113
  };
118
114
  };
119
115
  };
120
- wav: {
116
+ prores: {
121
117
  default: import("./file-extensions").FileExtension;
122
118
  forAudioCodec: {
119
+ aac: {
120
+ possible: import("./file-extensions").FileExtension[];
121
+ default: import("./file-extensions").FileExtension;
122
+ };
123
123
  "pcm-16": {
124
124
  possible: import("./file-extensions").FileExtension[];
125
125
  default: import("./file-extensions").FileExtension;
@@ -161,10 +161,6 @@ export declare const BrowserSafeApis: {
161
161
  compressed: "pcm-16" | "opus" | null;
162
162
  lossless: "pcm-16" | "opus" | null;
163
163
  };
164
- prores: {
165
- compressed: "aac" | "pcm-16" | null;
166
- lossless: "aac" | "pcm-16" | null;
167
- };
168
164
  mp3: {
169
165
  compressed: "mp3" | "pcm-16" | null;
170
166
  lossless: "mp3" | "pcm-16" | null;
@@ -177,6 +173,10 @@ export declare const BrowserSafeApis: {
177
173
  compressed: "pcm-16" | null;
178
174
  lossless: "pcm-16" | null;
179
175
  };
176
+ prores: {
177
+ compressed: "aac" | "pcm-16" | null;
178
+ lossless: "aac" | "pcm-16" | null;
179
+ };
180
180
  "h264-mkv": {
181
181
  compressed: "mp3" | "pcm-16" | null;
182
182
  lossless: "mp3" | "pcm-16" | null;
@@ -186,8 +186,8 @@ export declare const BrowserSafeApis: {
186
186
  lossless: null;
187
187
  };
188
188
  };
189
- defaultCodecsForFileExtension: Record<import("./file-extensions").FileExtension, "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif">;
190
- validateOutputFilename: <T_1 extends "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif">({ codec, audioCodec, extension, preferLossless, }: {
189
+ defaultCodecsForFileExtension: Record<import("./file-extensions").FileExtension, "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">;
190
+ validateOutputFilename: <T_1 extends "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">({ codec, audioCodec, extension, preferLossless, }: {
191
191
  codec: T_1;
192
192
  audioCodec: "mp3" | "aac" | "pcm-16" | "opus" | null;
193
193
  extension: string;
@@ -280,7 +280,7 @@ export declare const BrowserSafeApis: {
280
280
  description: () => JSX.Element;
281
281
  docLink: string;
282
282
  ssrName: string;
283
- type: "bt709" | "default";
283
+ type: "default" | "bt709";
284
284
  };
285
285
  deleteAfterOption: {
286
286
  name: string;
@@ -382,6 +382,6 @@ export declare const BrowserSafeApis: {
382
382
  type: number | null;
383
383
  }];
384
384
  };
385
- codecSupportsCrf: (codec: "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif") => boolean;
386
- codecSupportsVideoBitrate: (codec: "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif") => boolean;
385
+ codecSupportsCrf: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => boolean;
386
+ codecSupportsVideoBitrate: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => boolean;
387
387
  };
@@ -4,6 +4,9 @@ export declare const createFfmpegComplexFilter: ({ filters, downloadMap, }: {
4
4
  filters: PreprocessedAudioTrack[];
5
5
  downloadMap: DownloadMap;
6
6
  }) => Promise<{
7
- complexFilterFlag: [string, string] | null;
7
+ complexFilterFlag: [
8
+ string,
9
+ string
10
+ ] | null;
8
11
  cleanup: () => void;
9
12
  }>;
@@ -0,0 +1 @@
1
+ export declare const getAvailableMemory: () => number;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAvailableMemory = void 0;
4
+ const node_fs_1 = require("node:fs");
5
+ const node_os_1 = require("node:os");
6
+ const logger_1 = require("./logger");
7
+ const getFreeMemoryFromProcMeminfo = () => {
8
+ const data = (0, node_fs_1.readFileSync)('/proc/meminfo', 'utf-8');
9
+ // Split the file by lines and find the line with MemFree
10
+ const lines = data.split('\n');
11
+ const memAvailableLine = lines.find((line) => line.startsWith('MemAvailable'));
12
+ // If we couldn't find MemAvailable, return an error
13
+ if (!memAvailableLine) {
14
+ throw new Error('MemAvailable not found in /proc/meminfo');
15
+ }
16
+ // Extract the value and unit from the line
17
+ const matches = memAvailableLine.match(/(\d+)\s+(\w+)/);
18
+ if (!matches || matches.length !== 3) {
19
+ throw new Error('Failed to parse MemAvailable value');
20
+ }
21
+ const value = parseInt(matches[1], 10);
22
+ const unit = matches[2].toLowerCase();
23
+ // Convert the value to bytes based on its unit
24
+ switch (unit) {
25
+ case 'kb':
26
+ return value * 1024;
27
+ case 'mb':
28
+ return value * 1024 * 1024;
29
+ case 'gb':
30
+ return value * 1024 * 1024 * 1024;
31
+ default:
32
+ throw new Error(`Unknown unit: ${unit}`);
33
+ }
34
+ };
35
+ const getAvailableMemory = () => {
36
+ if ((0, node_fs_1.existsSync)('/proc/meminfo')) {
37
+ try {
38
+ getFreeMemoryFromProcMeminfo();
39
+ }
40
+ catch (err) {
41
+ logger_1.Log.warn('Tried to get available memory from /proc/meminfo but failed. Falling back to os.freemem(). Error:');
42
+ logger_1.Log.warn(err);
43
+ }
44
+ }
45
+ return (0, node_os_1.freemem)();
46
+ };
47
+ exports.getAvailableMemory = getAvailableMemory;
@@ -1,26 +1,23 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getActualConcurrency = void 0;
7
- const node_os_1 = __importDefault(require("node:os"));
4
+ const get_cpu_count_1 = require("./get-cpu-count");
8
5
  const getActualConcurrency = (userPreference) => {
6
+ const maxCpus = (0, get_cpu_count_1.getCpuCount)();
9
7
  if (userPreference === null) {
10
- return Math.round(Math.min(8, Math.max(1, node_os_1.default.cpus().length / 2)));
8
+ return Math.round(Math.min(8, Math.max(1, maxCpus / 2)));
11
9
  }
12
- const max = node_os_1.default.cpus().length;
13
10
  const min = 1;
14
11
  let rounded;
15
12
  if (typeof userPreference === 'string') {
16
13
  const percentage = parseInt(userPreference.slice(0, -1), 10);
17
- rounded = Math.floor((percentage / 100) * max);
14
+ rounded = Math.floor((percentage / 100) * maxCpus);
18
15
  }
19
16
  else {
20
17
  rounded = Math.floor(userPreference);
21
18
  }
22
- if (rounded > max) {
23
- throw new Error(`Maximum for --concurrency is ${max} (number of cores on this system)`);
19
+ if (rounded > maxCpus) {
20
+ throw new Error(`Maximum for --concurrency is ${maxCpus} (number of cores on this system)`);
24
21
  }
25
22
  if (rounded < min) {
26
23
  throw new Error(`Minimum for concurrency is ${min}.`);
@@ -0,0 +1 @@
1
+ export declare const getCpuCount: () => number;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ // Kubernetes uses the following command to spawn Docker containers:
3
+ // docker run --cpuset-cpus="0,1" to assign only 2 CPUs.
4
+ // However, Node.js returns the core count of the host system (up to 96!)
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getCpuCount = void 0;
7
+ const node_child_process_1 = require("node:child_process");
8
+ const node_os_1 = require("node:os");
9
+ // We also get it from nproc and use the minimum of the two.
10
+ const getConcurrencyFromNProc = () => {
11
+ try {
12
+ return parseInt((0, node_child_process_1.execSync)('nproc').toString().trim(), 10);
13
+ }
14
+ catch (error) {
15
+ return null;
16
+ }
17
+ };
18
+ const getCpuCount = () => {
19
+ const node = (0, node_os_1.cpus)().length;
20
+ const nproc = getConcurrencyFromNProc();
21
+ if (nproc === null) {
22
+ return node;
23
+ }
24
+ return Math.min(nproc, node);
25
+ };
26
+ exports.getCpuCount = getCpuCount;
@@ -1,6 +1,6 @@
1
1
  import type { AudioCodec } from './audio-codec';
2
2
  import type { Codec } from './codec';
3
3
  import type { FileExtension } from './file-extensions';
4
- export declare const getFileExtensionFromCodec: <T extends "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif">(codec: T, audioCodec: AudioCodec | null) => FileExtension;
5
- export declare const makeFileExtensionMap: () => Record<string, ("h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif")[]>;
4
+ export declare const getFileExtensionFromCodec: <T extends "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">(codec: T, audioCodec: AudioCodec | null) => FileExtension;
5
+ export declare const makeFileExtensionMap: () => Record<string, ("h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif")[]>;
6
6
  export declare const defaultCodecsForFileExtension: Record<FileExtension, Codec>;
@@ -1,15 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getIdealVideoThreadsFlag = void 0;
7
- const node_os_1 = __importDefault(require("node:os"));
4
+ const get_available_memory_1 = require("./get-available-memory");
5
+ const get_cpu_count_1 = require("./get-cpu-count");
8
6
  const MEMORY_USAGE_PER_THREAD = 400000000; // 400MB
9
7
  const RESERVED_MEMORY = 2000000000;
10
8
  const getIdealVideoThreadsFlag = () => {
11
- const freeMemory = node_os_1.default.freemem();
12
- const cpus = node_os_1.default.cpus().length;
9
+ const freeMemory = (0, get_available_memory_1.getAvailableMemory)();
10
+ const cpus = (0, get_cpu_count_1.getCpuCount)();
13
11
  const maxRecommendedBasedOnCpus = (cpus * 2) / 3;
14
12
  const maxRecommendedBasedOnMemory = (freeMemory - RESERVED_MEMORY) / MEMORY_USAGE_PER_THREAD;
15
13
  const maxRecommended = Math.min(maxRecommendedBasedOnCpus, maxRecommendedBasedOnMemory);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="react" />
3
1
  import execa from 'execa';
4
2
  import { HeadlessBrowser } from './browser/Browser';
5
3
  import { SymbolicateableError } from './error-handling/symbolicateable-error';
@@ -60,9 +58,9 @@ export declare const RenderInternals: {
60
58
  width: number;
61
59
  height: number;
62
60
  scale: number;
63
- codec: "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif";
61
+ codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
64
62
  }) => void;
65
- getFileExtensionFromCodec: <T extends "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif">(codec: T, audioCodec: "mp3" | "aac" | "pcm-16" | "opus" | null) => import("./file-extensions").FileExtension;
63
+ getFileExtensionFromCodec: <T extends "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">(codec: T, audioCodec: "mp3" | "aac" | "pcm-16" | "opus" | null) => import("./file-extensions").FileExtension;
66
64
  tmpDir: (str: string) => string;
67
65
  deleteDirectory: (directory: string) => void;
68
66
  isServeUrl: (potentialUrl: string) => boolean;
@@ -112,7 +110,7 @@ export declare const RenderInternals: {
112
110
  };
113
111
  registerErrorSymbolicationLock: () => number;
114
112
  unlockErrorSymbolicationLock: (id: number) => void;
115
- canUseParallelEncoding: (codec: "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif") => boolean;
113
+ canUseParallelEncoding: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => boolean;
116
114
  mimeContentType: typeof mimeContentType;
117
115
  mimeLookup: typeof mimeLookup;
118
116
  validateConcurrency: ({ setting, value, checkIfValidForCurrentMachine, }: {
@@ -129,8 +127,8 @@ export declare const RenderInternals: {
129
127
  DEFAULT_PIXEL_FORMAT: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le";
130
128
  validateJpegQuality: (q: number | undefined) => void;
131
129
  DEFAULT_TIMEOUT: number;
132
- DEFAULT_CODEC: "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif";
133
- isAudioCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif" | undefined) => boolean;
130
+ DEFAULT_CODEC: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
131
+ isAudioCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif" | undefined) => boolean;
134
132
  logLevels: readonly ["verbose", "info", "warn", "error"];
135
133
  isEqualOrBelowLogLevel: (currentLevel: "verbose" | "info" | "warn" | "error", level: "verbose" | "info" | "warn" | "error") => boolean;
136
134
  isValidLogLevel: (level: string) => boolean;
@@ -147,15 +145,15 @@ export declare const RenderInternals: {
147
145
  output: string;
148
146
  onProgress: (p: number) => void;
149
147
  numberOfFrames: number;
150
- codec: "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif";
148
+ codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
151
149
  fps: number;
152
150
  numberOfGifLoops: number | null;
153
151
  audioCodec: "mp3" | "aac" | "pcm-16" | "opus" | null;
154
152
  }) => Promise<void>;
155
153
  getMinConcurrency: () => number;
156
- getMaxConcurrency: () => any;
154
+ getMaxConcurrency: () => number;
157
155
  getDefaultAudioCodec: ({ codec, preferLossless, }: {
158
- codec: "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif";
156
+ codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
159
157
  preferLossless: boolean;
160
158
  }) => "mp3" | "aac" | "pcm-16" | "opus" | null;
161
159
  validAudioCodecs: readonly ["pcm-16", "aac", "mp3", "opus"];
@@ -216,10 +214,10 @@ export declare const RenderInternals: {
216
214
  };
217
215
  };
218
216
  };
219
- prores: {
217
+ mp3: {
220
218
  default: import("./file-extensions").FileExtension;
221
219
  forAudioCodec: {
222
- aac: {
220
+ mp3: {
223
221
  possible: import("./file-extensions").FileExtension[];
224
222
  default: import("./file-extensions").FileExtension;
225
223
  };
@@ -229,10 +227,10 @@ export declare const RenderInternals: {
229
227
  };
230
228
  };
231
229
  };
232
- mp3: {
230
+ aac: {
233
231
  default: import("./file-extensions").FileExtension;
234
232
  forAudioCodec: {
235
- mp3: {
233
+ aac: {
236
234
  possible: import("./file-extensions").FileExtension[];
237
235
  default: import("./file-extensions").FileExtension;
238
236
  };
@@ -242,22 +240,22 @@ export declare const RenderInternals: {
242
240
  };
243
241
  };
244
242
  };
245
- aac: {
243
+ wav: {
246
244
  default: import("./file-extensions").FileExtension;
247
245
  forAudioCodec: {
248
- aac: {
249
- possible: import("./file-extensions").FileExtension[];
250
- default: import("./file-extensions").FileExtension;
251
- };
252
246
  "pcm-16": {
253
247
  possible: import("./file-extensions").FileExtension[];
254
248
  default: import("./file-extensions").FileExtension;
255
249
  };
256
250
  };
257
251
  };
258
- wav: {
252
+ prores: {
259
253
  default: import("./file-extensions").FileExtension;
260
254
  forAudioCodec: {
255
+ aac: {
256
+ possible: import("./file-extensions").FileExtension[];
257
+ default: import("./file-extensions").FileExtension;
258
+ };
261
259
  "pcm-16": {
262
260
  possible: import("./file-extensions").FileExtension[];
263
261
  default: import("./file-extensions").FileExtension;
@@ -294,8 +292,8 @@ export declare const RenderInternals: {
294
292
  readonly vp9: readonly ["opus", "pcm-16"];
295
293
  readonly wav: readonly ["pcm-16"];
296
294
  };
297
- makeFileExtensionMap: () => Record<string, ("h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif")[]>;
298
- defaultCodecsForFileExtension: Record<import("./file-extensions").FileExtension, "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif">;
295
+ makeFileExtensionMap: () => Record<string, ("h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif")[]>;
296
+ defaultCodecsForFileExtension: Record<import("./file-extensions").FileExtension, "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">;
299
297
  getExecutablePath: (type: "compositor" | "ffmpeg" | "ffprobe" | "ffmpeg-cwd") => string;
300
298
  callFf: (bin: "ffmpeg" | "ffprobe", args: (string | null)[], options?: execa.Options<string> | undefined) => execa.ExecaChildProcess<string>;
301
299
  dynamicLibraryPathOptions: () => {
@@ -313,7 +311,7 @@ export declare const RenderInternals: {
313
311
  validStillImageFormats: readonly ["png", "jpeg", "pdf", "webp"];
314
312
  validVideoImageFormats: readonly ["png", "jpeg", "none"];
315
313
  DEFAULT_STILL_IMAGE_FORMAT: "png" | "jpeg" | "pdf" | "webp";
316
- DEFAULT_VIDEO_IMAGE_FORMAT: "none" | "png" | "jpeg";
314
+ DEFAULT_VIDEO_IMAGE_FORMAT: "png" | "jpeg" | "none";
317
315
  DEFAULT_JPEG_QUALITY: number;
318
316
  chalk: {
319
317
  enabled: () => boolean;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const audioBitrateOption: {
3
2
  name: string;
4
3
  cliFlag: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const validColorSpaces: readonly ["default", "bt709"];
3
2
  export type ColorSpace = (typeof validColorSpaces)[number];
4
3
  export declare const colorSpaceOption: {
@@ -7,6 +6,6 @@ export declare const colorSpaceOption: {
7
6
  description: () => JSX.Element;
8
7
  docLink: string;
9
8
  ssrName: string;
10
- type: "bt709" | "default";
9
+ type: "default" | "bt709";
11
10
  };
12
11
  export declare const validateColorSpace: (option: unknown) => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const crfOption: {
3
2
  name: string;
4
3
  cliFlag: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const enforceAudioOption: {
3
2
  name: string;
4
3
  cliFlag: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const jpegQualityOption: {
3
2
  name: string;
4
3
  cliFlag: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const muteOption: {
3
2
  name: string;
4
3
  cliFlag: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const offthreadVideoCacheSizeInBytesOption: {
3
2
  name: string;
4
3
  cliFlag: "offthreadvideo-cache-size-in-bytes";
@@ -17,7 +17,7 @@ const validateOffthreadVideoCacheSizeInBytes = (option) => {
17
17
  if (typeof option !== 'number') {
18
18
  throw new Error('Expected a number');
19
19
  }
20
- if (option < 0) {
20
+ if (option < 0 || option === 0) {
21
21
  throw new Error('Expected a positive number');
22
22
  }
23
23
  if (Number.isNaN(option)) {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const optionsMap: {
3
2
  readonly renderMedia: readonly [{
4
3
  name: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const scaleOption: {
3
2
  name: string;
4
3
  cliFlag: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const videoBitrate: {
3
2
  name: string;
4
3
  cliFlag: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const videoCodecOption: {
3
2
  name: string;
4
3
  cliFlag: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const webhookCustomDataOption: {
3
2
  name: string;
4
3
  cliFlag: "webhook-custom-data";
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.shouldUseParallelEncoding = void 0;
7
- const node_os_1 = __importDefault(require("node:os"));
4
+ const get_available_memory_1 = require("./get-available-memory");
8
5
  const estimateMemoryUsageForPrestitcher = ({ width, height, }) => {
9
6
  // Empirically we detected that per 1 million pixels, FFMPEG uses around 1GB of memory, relatively independent of
10
7
  // the duration of the video.
@@ -13,7 +10,7 @@ const estimateMemoryUsageForPrestitcher = ({ width, height, }) => {
13
10
  return memoryUsageOfPixel * width * height;
14
11
  };
15
12
  const shouldUseParallelEncoding = ({ width, height, }) => {
16
- const freeMemory = node_os_1.default.freemem();
13
+ const freeMemory = (0, get_available_memory_1.getAvailableMemory)();
17
14
  const estimatedUsage = estimateMemoryUsageForPrestitcher({
18
15
  height,
19
16
  width,
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { ClipRegion } from 'remotion';
3
2
  import type { Page } from './browser/BrowserPage';
4
3
  import type { StillImageFormat } from './image-format';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { ClipRegion } from 'remotion';
3
2
  import type { Page } from './browser/BrowserPage';
4
3
  import type { StillImageFormat } from './image-format';
@@ -98,6 +98,12 @@ const internalRenderMediaRaw = ({ proResProfile, x264Preset, crf, composition, s
98
98
  logLevel,
99
99
  tag: 'renderMedia()',
100
100
  }, 'Free memory:', freeMemory, 'Estimated usage parallel encoding', estimatedUsage);
101
+ const actualConcurrency = (0, get_concurrency_1.getActualConcurrency)(concurrency);
102
+ logger_1.Log.verboseAdvanced({
103
+ indent,
104
+ logLevel,
105
+ tag: 'renderMedia()',
106
+ }, 'Using concurrency:', actualConcurrency);
101
107
  logger_1.Log.verboseAdvanced({
102
108
  indent,
103
109
  logLevel,
@@ -233,7 +239,7 @@ const internalRenderMediaRaw = ({ proResProfile, x264Preset, crf, composition, s
233
239
  Promise.resolve(createPrestitcherIfNecessary())
234
240
  .then(() => {
235
241
  return (0, prepare_server_1.makeOrReuseServer)(reusedServer, {
236
- concurrency: (0, get_concurrency_1.getActualConcurrency)(concurrency),
242
+ concurrency: actualConcurrency,
237
243
  indent,
238
244
  port,
239
245
  remotionRoot: (0, find_closest_package_json_1.findRemotionRoot)(),
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { ClipRegion } from 'remotion';
3
2
  import type { Page } from './browser/BrowserPage';
4
3
  import type { StillImageFormat } from './image-format';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { ClipRegion } from 'remotion';
3
2
  import type { Page } from './browser/BrowserPage';
4
3
  import type { StillImageFormat } from './image-format';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
3
2
  import type { RenderAssetInfo } from './assets/download-map';
4
3
  import type { AudioCodec } from './audio-codec';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { TRenderAsset } from 'remotion';
3
2
  import type { DownloadMap } from './assets/download-map';
4
3
  import type { Page } from './browser/BrowserPage';
@@ -3,5 +3,5 @@ export declare const validateConcurrency: ({ setting, value, checkIfValidForCurr
3
3
  setting: string;
4
4
  checkIfValidForCurrentMachine: boolean;
5
5
  }) => void;
6
- export declare const getMaxConcurrency: () => any;
6
+ export declare const getMaxConcurrency: () => number;
7
7
  export declare const getMinConcurrency: () => number;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMinConcurrency = exports.getMaxConcurrency = exports.validateConcurrency = void 0;
4
+ const get_cpu_count_1 = require("./get-cpu-count");
4
5
  const validateConcurrency = ({ setting, value, checkIfValidForCurrentMachine, }) => {
5
6
  if (typeof value === 'undefined') {
6
7
  return;
@@ -30,7 +31,7 @@ const validateConcurrency = ({ setting, value, checkIfValidForCurrentMachine, })
30
31
  };
31
32
  exports.validateConcurrency = validateConcurrency;
32
33
  const getMaxConcurrency = () => {
33
- return require('os').cpus().length;
34
+ return (0, get_cpu_count_1.getCpuCount)();
34
35
  };
35
36
  exports.getMaxConcurrency = getMaxConcurrency;
36
37
  const getMinConcurrency = () => 1;
@@ -1,5 +1,5 @@
1
1
  import type { AudioCodec } from './audio-codec';
2
- export declare const validateOutputFilename: <T extends "h264" | "h265" | "vp8" | "vp9" | "prores" | "mp3" | "aac" | "wav" | "h264-mkv" | "gif">({ codec, audioCodec, extension, preferLossless, }: {
2
+ export declare const validateOutputFilename: <T extends "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">({ codec, audioCodec, extension, preferLossless, }: {
3
3
  codec: T;
4
4
  audioCodec: AudioCodec | null;
5
5
  extension: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/renderer",
3
- "version": "4.0.33",
3
+ "version": "4.0.35",
4
4
  "description": "Renderer for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "extract-zip": "2.0.1",
19
19
  "source-map": "^0.8.0-beta.0",
20
20
  "ws": "8.7.0",
21
- "remotion": "4.0.33"
21
+ "remotion": "4.0.35"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": ">=16.8.0",
@@ -40,13 +40,13 @@
40
40
  "vitest": "0.31.1"
41
41
  },
42
42
  "optionalDependencies": {
43
- "@remotion/compositor-darwin-arm64": "4.0.33",
44
- "@remotion/compositor-darwin-x64": "4.0.33",
45
- "@remotion/compositor-linux-arm64-gnu": "4.0.33",
46
- "@remotion/compositor-linux-arm64-musl": "4.0.33",
47
- "@remotion/compositor-linux-x64-gnu": "4.0.33",
48
- "@remotion/compositor-linux-x64-musl": "4.0.33",
49
- "@remotion/compositor-win32-x64-msvc": "4.0.33"
43
+ "@remotion/compositor-darwin-arm64": "4.0.35",
44
+ "@remotion/compositor-darwin-x64": "4.0.35",
45
+ "@remotion/compositor-linux-arm64-gnu": "4.0.35",
46
+ "@remotion/compositor-linux-arm64-musl": "4.0.35",
47
+ "@remotion/compositor-linux-x64-gnu": "4.0.35",
48
+ "@remotion/compositor-linux-x64-musl": "4.0.35",
49
+ "@remotion/compositor-win32-x64-msvc": "4.0.35"
50
50
  },
51
51
  "keywords": [
52
52
  "remotion",