@remotion/renderer 4.0.0-alpha4 → 4.0.0-alpha5

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 (121) hide show
  1. package/README.md +5 -43
  2. package/dist/assets/download-map.d.ts +0 -26
  3. package/dist/assets/download-map.js +0 -5
  4. package/dist/assets/get-audio-channels.d.ts +1 -2
  5. package/dist/assets/get-audio-channels.js +5 -9
  6. package/dist/audio-codec.d.ts +4 -3
  7. package/dist/audio-codec.js +3 -9
  8. package/dist/browser/BrowserFetcher.d.ts +0 -1
  9. package/dist/browser/BrowserFetcher.js +1 -2
  10. package/dist/browser/BrowserRunner.js +8 -2
  11. package/dist/browser/FrameManager.js +2 -3
  12. package/dist/browser/LaunchOptions.d.ts +1 -0
  13. package/dist/browser/Launcher.js +2 -1
  14. package/dist/browser/devtools-commands.d.ts +5 -1
  15. package/dist/browser/devtools-types.d.ts +78 -0
  16. package/dist/browser/is-target-closed-err.d.ts +1 -0
  17. package/dist/browser/is-target-closed-err.js +9 -0
  18. package/dist/call-ffmpeg.d.ts +14 -0
  19. package/dist/call-ffmpeg.js +37 -0
  20. package/dist/check-apple-silicon.js +2 -45
  21. package/dist/client.d.ts +67 -42
  22. package/dist/client.js +27 -1
  23. package/dist/codec-supports-media.d.ts +2 -1
  24. package/dist/codec-supports-media.js +20 -5
  25. package/dist/combine-videos.d.ts +0 -3
  26. package/dist/combine-videos.js +5 -9
  27. package/dist/compositor/compose.d.ts +3 -1
  28. package/dist/compositor/compose.js +34 -14
  29. package/dist/compositor/compositor.d.ts +12 -0
  30. package/dist/compositor/compositor.js +202 -0
  31. package/dist/compositor/get-executable-path.d.ts +1 -1
  32. package/dist/compositor/get-executable-path.js +27 -8
  33. package/dist/compositor/make-nonce.d.ts +1 -0
  34. package/dist/compositor/make-nonce.js +8 -0
  35. package/dist/compositor/payloads.d.ts +34 -7
  36. package/dist/create-ffmpeg-complex-filter.d.ts +5 -5
  37. package/dist/create-ffmpeg-complex-filter.js +2 -4
  38. package/dist/create-ffmpeg-merge-filter.d.ts +2 -5
  39. package/dist/create-ffmpeg-merge-filter.js +2 -10
  40. package/dist/create-silent-audio.d.ts +1 -4
  41. package/dist/create-silent-audio.js +3 -7
  42. package/dist/crf.js +8 -2
  43. package/dist/delete-directory.js +16 -16
  44. package/dist/file-extensions.d.ts +1 -12
  45. package/dist/file-extensions.js +1 -13
  46. package/dist/get-compositions.d.ts +3 -5
  47. package/dist/get-compositions.js +8 -11
  48. package/dist/get-extension-from-codec.d.ts +2 -2
  49. package/dist/get-frame-padded-index.d.ts +2 -1
  50. package/dist/guess-extension-for-media.d.ts +1 -3
  51. package/dist/guess-extension-for-media.js +4 -8
  52. package/dist/image-format.d.ts +12 -6
  53. package/dist/image-format.js +16 -13
  54. package/dist/index.d.ts +66 -59
  55. package/dist/index.js +15 -17
  56. package/dist/jpeg-quality.d.ts +1 -0
  57. package/dist/jpeg-quality.js +21 -0
  58. package/dist/merge-audio-track.d.ts +0 -2
  59. package/dist/merge-audio-track.js +3 -10
  60. package/dist/offthread-video-server.d.ts +8 -8
  61. package/dist/offthread-video-server.js +63 -56
  62. package/dist/open-browser.d.ts +1 -0
  63. package/dist/open-browser.js +7 -6
  64. package/dist/options/audio-bitrate.d.ts +2 -0
  65. package/dist/options/audio-bitrate.js +11 -0
  66. package/dist/options/crf.d.ts +2 -0
  67. package/dist/options/crf.js +11 -0
  68. package/dist/options/enforce-audio.d.ts +2 -0
  69. package/dist/options/enforce-audio.js +11 -0
  70. package/dist/options/jpeg-quality.d.ts +2 -0
  71. package/dist/options/jpeg-quality.js +11 -0
  72. package/dist/options/mute.d.ts +2 -0
  73. package/dist/options/mute.js +11 -0
  74. package/dist/options/option.d.ts +8 -0
  75. package/dist/options/option.js +2 -0
  76. package/dist/options/scale.d.ts +2 -0
  77. package/dist/options/scale.js +11 -0
  78. package/dist/options/video-bitrate.d.ts +2 -0
  79. package/dist/options/video-bitrate.js +11 -0
  80. package/dist/options/video-codec.d.ts +2 -0
  81. package/dist/options/video-codec.js +11 -0
  82. package/dist/perf.d.ts +1 -1
  83. package/dist/perf.js +9 -7
  84. package/dist/prepare-server.d.ts +3 -4
  85. package/dist/prepare-server.js +5 -5
  86. package/dist/preprocess-audio-track.d.ts +0 -4
  87. package/dist/preprocess-audio-track.js +4 -8
  88. package/dist/prespawn-ffmpeg.d.ts +6 -9
  89. package/dist/prespawn-ffmpeg.js +7 -12
  90. package/dist/prestitcher-memory-usage.d.ts +0 -4
  91. package/dist/prestitcher-memory-usage.js +2 -3
  92. package/dist/prores-profile.d.ts +1 -2
  93. package/dist/prores-profile.js +4 -4
  94. package/dist/provide-screenshot.d.ts +4 -5
  95. package/dist/provide-screenshot.js +2 -2
  96. package/dist/puppeteer-screenshot.d.ts +3 -3
  97. package/dist/puppeteer-screenshot.js +9 -32
  98. package/dist/render-frames.d.ts +13 -25
  99. package/dist/render-frames.js +29 -40
  100. package/dist/render-media.d.ts +16 -18
  101. package/dist/render-media.js +33 -43
  102. package/dist/render-still.d.ts +10 -8
  103. package/dist/render-still.js +14 -13
  104. package/dist/screenshot-dom-element.d.ts +4 -5
  105. package/dist/screenshot-dom-element.js +6 -3
  106. package/dist/screenshot-task.d.ts +2 -3
  107. package/dist/screenshot-task.js +38 -23
  108. package/dist/serve-handler/index.js +6 -4
  109. package/dist/serve-static.d.ts +2 -3
  110. package/dist/serve-static.js +24 -20
  111. package/dist/stitch-frames-to-video.d.ts +2 -12
  112. package/dist/stitch-frames-to-video.js +24 -33
  113. package/dist/take-frame-and-compose.d.ts +4 -5
  114. package/dist/take-frame-and-compose.js +12 -6
  115. package/dist/tmp-dir.js +1 -2
  116. package/dist/validate-concurrency.d.ts +2 -0
  117. package/dist/validate-concurrency.js +11 -5
  118. package/dist/validate-output-filename.d.ts +1 -1
  119. package/dist/validate-puppeteer-timeout.js +1 -0
  120. package/install-toolchain.mjs +36 -0
  121. package/package.json +11 -10
@@ -26,8 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.stitchFramesToVideo = exports.spawnFfmpeg = void 0;
30
- const execa_1 = __importDefault(require("execa"));
29
+ exports.stitchFramesToVideo = void 0;
31
30
  const fs_1 = __importStar(require("fs"));
32
31
  const path_1 = __importDefault(require("path"));
33
32
  const remotion_1 = require("remotion");
@@ -35,13 +34,14 @@ const calculate_asset_positions_1 = require("./assets/calculate-asset-positions"
35
34
  const convert_assets_to_file_urls_1 = require("./assets/convert-assets-to-file-urls");
36
35
  const download_and_map_assets_to_file_1 = require("./assets/download-and-map-assets-to-file");
37
36
  const audio_codec_1 = require("./audio-codec");
37
+ const call_ffmpeg_1 = require("./call-ffmpeg");
38
38
  const codec_1 = require("./codec");
39
39
  const codec_supports_media_1 = require("./codec-supports-media");
40
+ const get_executable_path_1 = require("./compositor/get-executable-path");
40
41
  const convert_number_of_gif_loops_to_ffmpeg_1 = require("./convert-number-of-gif-loops-to-ffmpeg");
41
42
  const crf_1 = require("./crf");
42
43
  const delete_directory_1 = require("./delete-directory");
43
44
  const does_have_m2_bug_1 = require("./does-have-m2-bug");
44
- const ffmpeg_flags_1 = require("./ffmpeg-flags");
45
45
  const find_closest_package_json_1 = require("./find-closest-package-json");
46
46
  const get_codec_name_1 = require("./get-codec-name");
47
47
  const get_extension_from_codec_1 = require("./get-extension-from-codec");
@@ -54,13 +54,12 @@ const preprocess_audio_track_1 = require("./preprocess-audio-track");
54
54
  const prores_profile_1 = require("./prores-profile");
55
55
  const truthy_1 = require("./truthy");
56
56
  const validate_even_dimensions_with_codec_1 = require("./validate-even-dimensions-with-codec");
57
- const validate_ffmpeg_1 = require("./validate-ffmpeg");
58
57
  const validate_videobitrate_1 = require("./validate-videobitrate");
59
58
  const packageJsonPath = path_1.default.join(__dirname, '..', 'package.json');
60
59
  const packageJson = fs_1.default.existsSync(packageJsonPath)
61
60
  ? JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'))
62
61
  : null;
63
- const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose, ffmpegExecutable, ffprobeExecutable, onProgress, downloadMap, remotionRoot, }) => {
62
+ const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose, onProgress, downloadMap, remotionRoot, }) => {
64
63
  const fileUrlAssets = await (0, convert_assets_to_file_urls_1.convertAssetsToFileUrls)({
65
64
  assets,
66
65
  onDownload: onDownload !== null && onDownload !== void 0 ? onDownload : (() => () => undefined),
@@ -78,14 +77,11 @@ const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose,
78
77
  const preprocessed = (await Promise.all(assetPositions.map(async (asset, index) => {
79
78
  const filterFile = path_1.default.join(downloadMap.audioMixing, `${index}.wav`);
80
79
  const result = await (0, preprocess_audio_track_1.preprocessAudioTrack)({
81
- ffmpegExecutable: ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : null,
82
- ffprobeExecutable: ffprobeExecutable !== null && ffprobeExecutable !== void 0 ? ffprobeExecutable : null,
83
80
  outName: filterFile,
84
81
  asset,
85
82
  expectedFrames,
86
83
  fps,
87
84
  downloadMap,
88
- remotionRoot,
89
85
  });
90
86
  preprocessProgress[index] = 1;
91
87
  updateProgress();
@@ -93,7 +89,6 @@ const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose,
93
89
  }))).filter(truthy_1.truthy);
94
90
  const outName = path_1.default.join(downloadMap.audioPreprocessing, `audio.wav`);
95
91
  await (0, merge_audio_track_1.mergeAudioTrack)({
96
- ffmpegExecutable: ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : null,
97
92
  files: preprocessed,
98
93
  outName,
99
94
  numberOfSeconds: Number((expectedFrames / fps).toFixed(3)),
@@ -108,7 +103,7 @@ const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose,
108
103
  return outName;
109
104
  };
110
105
  const spawnFfmpeg = async (options, remotionRoot) => {
111
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
106
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
112
107
  remotion_1.Internals.validateDimension(options.height, 'height', 'passed to `stitchFramesToVideo()`');
113
108
  remotion_1.Internals.validateDimension(options.width, 'width', 'passed to `stitchFramesToVideo()`');
114
109
  const codec = (_a = options.codec) !== null && _a !== void 0 ? _a : codec_1.DEFAULT_CODEC;
@@ -126,7 +121,6 @@ const spawnFfmpeg = async (options, remotionRoot) => {
126
121
  (0, validate_videobitrate_1.validateBitrate)(options.videoBitrate, 'videoBitrate');
127
122
  remotion_1.Internals.validateFps(options.fps, 'in `stitchFramesToVideo()`', false);
128
123
  const pixelFormat = (_b = options.pixelFormat) !== null && _b !== void 0 ? _b : pixel_format_1.DEFAULT_PIXEL_FORMAT;
129
- await (0, validate_ffmpeg_1.validateFfmpeg)((_c = options.ffmpegExecutable) !== null && _c !== void 0 ? _c : null, remotionRoot, 'ffmpeg');
130
124
  const encoderName = (0, get_codec_name_1.getCodecName)(codec);
131
125
  const proResProfileName = (0, get_prores_profile_name_1.getProResProfileName)(codec, options.proResProfile);
132
126
  const mediaSupport = (0, codec_supports_media_1.codecSupportsMedia)(codec);
@@ -139,14 +133,14 @@ const spawnFfmpeg = async (options, remotionRoot) => {
139
133
  throw new Error('The output format has neither audio nor video. This can happen if you are rendering an audio codec and the output file has no audio or the muted flag was passed.');
140
134
  }
141
135
  // Explanation: https://github.com/remotion-dev/remotion/issues/1647
142
- const resolvedAudioCodec = ((_d = options.internalOptions) === null || _d === void 0 ? void 0 : _d.preferLossless)
136
+ const resolvedAudioCodec = ((_c = options.internalOptions) === null || _c === void 0 ? void 0 : _c.preferLossless)
143
137
  ? (0, audio_codec_1.getDefaultAudioCodec)({ codec, preferLossless: true })
144
- : (_e = options.audioCodec) !== null && _e !== void 0 ? _e : (0, audio_codec_1.getDefaultAudioCodec)({ codec, preferLossless: false });
138
+ : (_d = options.audioCodec) !== null && _d !== void 0 ? _d : (0, audio_codec_1.getDefaultAudioCodec)({ codec, preferLossless: false });
145
139
  const tempFile = options.outputLocation
146
140
  ? null
147
141
  : path_1.default.join(options.assetsInfo.downloadMap.stitchFrames, `out.${(0, get_extension_from_codec_1.getFileExtensionFromCodec)(codec, resolvedAudioCodec)}`);
148
142
  if (options.verbose) {
149
- console.log('[verbose] ffmpeg', (_f = options.ffmpegExecutable) !== null && _f !== void 0 ? _f : 'ffmpeg in PATH');
143
+ console.log('[verbose] ffmpeg', (0, get_executable_path_1.getExecutablePath)('ffmpeg'));
150
144
  console.log('[verbose] encoder', encoderName);
151
145
  console.log('[verbose] audioCodec', resolvedAudioCodec);
152
146
  console.log('[verbose] pixelFormat', pixelFormat);
@@ -176,9 +170,7 @@ const spawnFfmpeg = async (options, remotionRoot) => {
176
170
  onDownload: options.onDownload,
177
171
  fps: options.fps,
178
172
  expectedFrames,
179
- verbose: (_g = options.verbose) !== null && _g !== void 0 ? _g : false,
180
- ffmpegExecutable: (_h = options.ffmpegExecutable) !== null && _h !== void 0 ? _h : null,
181
- ffprobeExecutable: (_j = options.ffprobeExecutable) !== null && _j !== void 0 ? _j : null,
173
+ verbose: (_e = options.verbose) !== null && _e !== void 0 ? _e : false,
182
174
  onProgress: (prog) => updateProgress(prog, 0),
183
175
  downloadMap: options.assetsInfo.downloadMap,
184
176
  remotionRoot,
@@ -188,22 +180,22 @@ const spawnFfmpeg = async (options, remotionRoot) => {
188
180
  if (!resolvedAudioCodec) {
189
181
  throw new TypeError('exporting audio but has no audio codec name. Report this in the Remotion repo.');
190
182
  }
191
- const ffmpegTask = (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)((_k = options.ffmpegExecutable) !== null && _k !== void 0 ? _k : null, remotionRoot, 'ffmpeg'), [
183
+ const ffmpegTask = (0, call_ffmpeg_1.callFf)('ffmpeg', [
192
184
  '-i',
193
185
  audio,
194
186
  '-c:a',
195
187
  (0, audio_codec_1.mapAudioCodecToFfmpegAudioCodecName)(resolvedAudioCodec),
196
188
  // Set bitrate up to 320k, for aac it might effectively be lower
197
189
  '-b:a',
198
- (_l = options.audioBitrate) !== null && _l !== void 0 ? _l : '320k',
190
+ (_f = options.audioBitrate) !== null && _f !== void 0 ? _f : '320k',
199
191
  options.force ? '-y' : null,
200
- (_m = options.outputLocation) !== null && _m !== void 0 ? _m : tempFile,
192
+ (_g = options.outputLocation) !== null && _g !== void 0 ? _g : tempFile,
201
193
  ].filter(remotion_1.Internals.truthy));
202
- (_o = options.cancelSignal) === null || _o === void 0 ? void 0 : _o.call(options, () => {
194
+ (_h = options.cancelSignal) === null || _h === void 0 ? void 0 : _h.call(options, () => {
203
195
  ffmpegTask.kill();
204
196
  });
205
197
  await ffmpegTask;
206
- (_p = options.onProgress) === null || _p === void 0 ? void 0 : _p.call(options, expectedFrames);
198
+ (_j = options.onProgress) === null || _j === void 0 ? void 0 : _j.call(options, expectedFrames);
207
199
  if (audio) {
208
200
  (0, delete_directory_1.deleteDirectory)(path_1.default.dirname(audio));
209
201
  }
@@ -228,8 +220,8 @@ const spawnFfmpeg = async (options, remotionRoot) => {
228
220
  }
229
221
  const ffmpegArgs = [
230
222
  ['-r', String(options.fps)],
231
- ...(((_q = options.internalOptions) === null || _q === void 0 ? void 0 : _q.preEncodedFileLocation)
232
- ? [['-i', (_r = options.internalOptions) === null || _r === void 0 ? void 0 : _r.preEncodedFileLocation]]
223
+ ...(((_k = options.internalOptions) === null || _k === void 0 ? void 0 : _k.preEncodedFileLocation)
224
+ ? [['-i', (_l = options.internalOptions) === null || _l === void 0 ? void 0 : _l.preEncodedFileLocation]]
233
225
  : [
234
226
  ['-f', 'image2'],
235
227
  ['-s', `${options.width}x${options.height}`],
@@ -237,16 +229,16 @@ const spawnFfmpeg = async (options, remotionRoot) => {
237
229
  ['-i', options.assetsInfo.imageSequenceName],
238
230
  ]),
239
231
  audio ? ['-i', audio] : null,
240
- ((_s = options.numberOfGifLoops) !== null && _s !== void 0 ? _s : null) === null
232
+ ((_m = options.numberOfGifLoops) !== null && _m !== void 0 ? _m : null) === null
241
233
  ? null
242
234
  : [
243
235
  '-loop',
244
- (0, convert_number_of_gif_loops_to_ffmpeg_1.convertNumberOfGifLoopsToFfmpegSyntax)((_t = options.numberOfGifLoops) !== null && _t !== void 0 ? _t : null),
236
+ (0, convert_number_of_gif_loops_to_ffmpeg_1.convertNumberOfGifLoopsToFfmpegSyntax)((_o = options.numberOfGifLoops) !== null && _o !== void 0 ? _o : null),
245
237
  ],
246
238
  // -c:v is the same as -vcodec as -codec:video
247
239
  // and specified the video codec.
248
240
  ['-c:v', encoderName],
249
- ...(((_u = options.internalOptions) === null || _u === void 0 ? void 0 : _u.preEncodedFileLocation)
241
+ ...(((_p = options.internalOptions) === null || _p === void 0 ? void 0 : _p.preEncodedFileLocation)
250
242
  ? []
251
243
  : [
252
244
  proResProfileName ? ['-profile:v', proResProfileName] : null,
@@ -274,7 +266,7 @@ const spawnFfmpeg = async (options, remotionRoot) => {
274
266
  [`Made with Remotion`, packageJson ? packageJson.version : null].join(' '),
275
267
  ],
276
268
  options.force ? '-y' : null,
277
- (_v = options.outputLocation) !== null && _v !== void 0 ? _v : tempFile,
269
+ (_q = options.outputLocation) !== null && _q !== void 0 ? _q : tempFile,
278
270
  ];
279
271
  if (options.verbose) {
280
272
  console.log('Generated FFMPEG command:');
@@ -288,15 +280,15 @@ const spawnFfmpeg = async (options, remotionRoot) => {
288
280
  console.log('Generated final FFMPEG command:');
289
281
  console.log(finalFfmpegString);
290
282
  }
291
- const task = (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)((_w = options.ffmpegExecutable) !== null && _w !== void 0 ? _w : null, remotionRoot, 'ffmpeg'), finalFfmpegString, {
283
+ const task = (0, call_ffmpeg_1.callFf)('ffmpeg', finalFfmpegString, {
292
284
  cwd: options.dir,
293
285
  });
294
- (_x = options.cancelSignal) === null || _x === void 0 ? void 0 : _x.call(options, () => {
286
+ (_r = options.cancelSignal) === null || _r === void 0 ? void 0 : _r.call(options, () => {
295
287
  task.kill();
296
288
  });
297
289
  let ffmpegOutput = '';
298
290
  let isFinished = false;
299
- (_y = task.stderr) === null || _y === void 0 ? void 0 : _y.on('data', (data) => {
291
+ (_s = task.stderr) === null || _s === void 0 ? void 0 : _s.on('data', (data) => {
300
292
  var _a;
301
293
  const str = data.toString();
302
294
  ffmpegOutput += str;
@@ -339,7 +331,6 @@ const spawnFfmpeg = async (options, remotionRoot) => {
339
331
  getLogs: () => ffmpegOutput,
340
332
  };
341
333
  };
342
- exports.spawnFfmpeg = spawnFfmpeg;
343
334
  /**
344
335
  * @description Takes a series of images and audio information generated by renderFrames() and encodes it to a video.
345
336
  * @see [Documentation](https://www.remotion.dev/docs/renderer/stitch-frames-to-video)
@@ -347,7 +338,7 @@ exports.spawnFfmpeg = spawnFfmpeg;
347
338
  const stitchFramesToVideo = async (options) => {
348
339
  var _a, _b;
349
340
  const remotionRoot = (0, find_closest_package_json_1.findRemotionRoot)();
350
- const { task, getLogs } = await (0, exports.spawnFfmpeg)(options, remotionRoot);
341
+ const { task, getLogs } = await spawnFfmpeg(options, remotionRoot);
351
342
  const happyPath = task.catch(() => {
352
343
  throw new Error(getLogs());
353
344
  });
@@ -1,12 +1,11 @@
1
- /// <reference types="node" />
2
1
  import type { TAsset } from 'remotion';
3
2
  import type { DownloadMap } from './assets/download-map';
4
3
  import type { Page } from './browser/BrowserPage';
5
- import type { ImageFormat } from './image-format';
6
- export declare const takeFrameAndCompose: ({ freePage, imageFormat, quality, frame, width, height, output, scale, downloadMap, wantsBuffer, }: {
4
+ import type { StillImageFormat, VideoImageFormat } from './image-format';
5
+ export declare const takeFrameAndCompose: ({ freePage, imageFormat, jpegQuality, frame, width, height, output, scale, downloadMap, wantsBuffer, }: {
7
6
  freePage: Page;
8
- imageFormat: ImageFormat;
9
- quality: number | undefined;
7
+ imageFormat: VideoImageFormat | StillImageFormat;
8
+ jpegQuality: number | undefined;
10
9
  frame: number;
11
10
  height: number;
12
11
  width: number;
@@ -10,7 +10,7 @@ const compose_1 = require("./compositor/compose");
10
10
  const provide_screenshot_1 = require("./provide-screenshot");
11
11
  const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
12
12
  const truthy_1 = require("./truthy");
13
- const takeFrameAndCompose = async ({ freePage, imageFormat, quality, frame, width, height, output, scale, downloadMap, wantsBuffer, }) => {
13
+ const takeFrameAndCompose = async ({ freePage, imageFormat, jpegQuality, frame, width, height, output, scale, downloadMap, wantsBuffer, }) => {
14
14
  var _a;
15
15
  const [clipRegion, collectedAssets] = await Promise.all([
16
16
  (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
@@ -40,7 +40,7 @@ const takeFrameAndCompose = async ({ freePage, imageFormat, quality, frame, widt
40
40
  ? null
41
41
  : {
42
42
  tmpFile: path_1.default.join(downloadMap.compositingDir, `${frame}.${imageFormat}`),
43
- finalOutfie: output !== null && output !== void 0 ? output : path_1.default.join(downloadMap.compositingDir, `${frame}-final.${imageFormat}`),
43
+ finalOutFile: output !== null && output !== void 0 ? output : path_1.default.join(downloadMap.compositingDir, `${frame}-final.${imageFormat}`),
44
44
  clipRegion: clipRegion,
45
45
  };
46
46
  if (clipRegion !== 'hide') {
@@ -48,7 +48,7 @@ const takeFrameAndCompose = async ({ freePage, imageFormat, quality, frame, widt
48
48
  const buf = await (0, provide_screenshot_1.provideScreenshot)({
49
49
  page: freePage,
50
50
  imageFormat,
51
- quality,
51
+ jpegQuality,
52
52
  options: {
53
53
  frame,
54
54
  output: shouldMakeBuffer ? null : (_a = needsComposing === null || needsComposing === void 0 ? void 0 : needsComposing.tmpFile) !== null && _a !== void 0 ? _a : output,
@@ -62,6 +62,12 @@ const takeFrameAndCompose = async ({ freePage, imageFormat, quality, frame, widt
62
62
  }
63
63
  }
64
64
  if (needsComposing) {
65
+ if (imageFormat === 'pdf') {
66
+ throw new Error("You cannot use compositor APIs (like <Clipper>) if `imageFormat` is 'pdf'.");
67
+ }
68
+ if (imageFormat === 'webp') {
69
+ throw new Error("You cannot use compositor APIs (like <Clipper>) if `imageFormat` is 'webp'.");
70
+ }
65
71
  await (0, compose_1.compose)({
66
72
  height: height * scale,
67
73
  width: width * scale,
@@ -81,13 +87,13 @@ const takeFrameAndCompose = async ({ freePage, imageFormat, quality, frame, widt
81
87
  },
82
88
  },
83
89
  ].filter(truthy_1.truthy),
84
- output: needsComposing.finalOutfie,
90
+ output: needsComposing.finalOutFile,
85
91
  downloadMap,
86
92
  imageFormat: imageFormat === 'jpeg' ? 'Jpeg' : 'Png',
87
93
  });
88
94
  if (wantsBuffer) {
89
- const buffer = await fs_1.default.promises.readFile(needsComposing.finalOutfie);
90
- await fs_1.default.promises.unlink(needsComposing.finalOutfie);
95
+ const buffer = await fs_1.default.promises.readFile(needsComposing.finalOutFile);
96
+ await fs_1.default.promises.unlink(needsComposing.finalOutFile);
91
97
  return { buffer, collectedAssets };
92
98
  }
93
99
  }
package/dist/tmp-dir.js CHANGED
@@ -40,10 +40,9 @@ const randomHash = () => {
40
40
  .join('');
41
41
  };
42
42
  const tmpDir = (str) => {
43
- var _a;
44
43
  const newDir = path_1.default.join(os_1.default.tmpdir(), str + randomHash());
45
44
  if (fs_1.default.existsSync(newDir)) {
46
- ((_a = fs_1.default.rmSync) !== null && _a !== void 0 ? _a : fs_1.default.rmdirSync)(newDir, {
45
+ fs_1.default.rmSync(newDir, {
47
46
  recursive: true,
48
47
  force: true,
49
48
  });
@@ -1 +1,3 @@
1
1
  export declare const validateConcurrency: (value: unknown, setting: string) => void;
2
+ export declare const getMaxConcurrency: () => any;
3
+ export declare const getMinConcurrency: () => number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateConcurrency = void 0;
3
+ exports.getMinConcurrency = exports.getMaxConcurrency = exports.validateConcurrency = void 0;
4
4
  const validateConcurrency = (value, setting) => {
5
5
  if (typeof value === 'undefined') {
6
6
  return;
@@ -15,11 +15,11 @@ const validateConcurrency = (value, setting) => {
15
15
  if (value % 1 !== 0) {
16
16
  throw new Error(setting + ' must be an integer, but is ' + value);
17
17
  }
18
- if (value < 1) {
19
- throw new Error(setting + ' must be at least 1, but is ' + value);
18
+ if (value < (0, exports.getMinConcurrency)()) {
19
+ throw new Error(`${setting} must be at least ${(0, exports.getMinConcurrency)()}, but is ${JSON.stringify(value)}`);
20
20
  }
21
- if (value > require('os').cpus().length) {
22
- throw new Error(`${setting} is set higher than the amount of CPU cores available. Available CPU cores: ${require('os').cpus().length}, value set: ${value}`);
21
+ if (value > (0, exports.getMaxConcurrency)()) {
22
+ throw new Error(`${setting} is set higher than the amount of CPU cores available. Available CPU cores: ${(0, exports.getMaxConcurrency)()}, value set: ${value}`);
23
23
  }
24
24
  }
25
25
  else if (!/^\d+(\.\d+)?%$/.test(value)) {
@@ -27,3 +27,9 @@ const validateConcurrency = (value, setting) => {
27
27
  }
28
28
  };
29
29
  exports.validateConcurrency = validateConcurrency;
30
+ const getMaxConcurrency = () => {
31
+ return require('os').cpus().length;
32
+ };
33
+ exports.getMaxConcurrency = getMaxConcurrency;
34
+ const getMinConcurrency = () => 1;
35
+ exports.getMinConcurrency = getMinConcurrency;
@@ -1,5 +1,5 @@
1
1
  import type { AudioCodec } from './audio-codec';
2
- export declare const validateOutputFilename: <T extends "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">({ codec, audioCodec, extension, preferLossless, }: {
2
+ export declare const validateOutputFilename: <T extends "aac" | "mp3" | "h264" | "h265" | "vp8" | "vp9" | "wav" | "prores" | "h264-mkv" | "gif">({ codec, audioCodec, extension, preferLossless, }: {
3
3
  codec: T;
4
4
  audioCodec: AudioCodec | null;
5
5
  extension: string;
@@ -8,6 +8,7 @@ const validatePuppeteerTimeout = (timeoutInMilliseconds) => {
8
8
  if (typeof timeoutInMilliseconds !== 'number') {
9
9
  throw new TypeError(`'timeoutInMilliseconds' should be a number, but is: ${JSON.stringify(timeoutInMilliseconds)}`);
10
10
  }
11
+ // Value also appears in packages/cli/src/editor/components/RenderModal/RenderModalAdvanced.tsx
11
12
  if (timeoutInMilliseconds < 7000 && process.env.NODE_ENV !== 'test') {
12
13
  throw new TypeError(`'timeoutInMilliseconds' should be bigger or equal than 7000, but is ${timeoutInMilliseconds}`);
13
14
  }
@@ -0,0 +1,36 @@
1
+ import {execSync} from 'child_process';
2
+ import {existsSync, mkdirSync, unlinkSync} from 'fs';
3
+ import {toolchains} from './toolchains.mjs';
4
+
5
+ const unpatched = [
6
+ 'x86_64-apple-darwin',
7
+ 'aarch64-apple-darwin',
8
+ 'x86_64-pc-windows-gnu',
9
+ ];
10
+
11
+ for (const toolchain of toolchains) {
12
+ process.stdout.write(toolchain + '...');
13
+
14
+ execSync(
15
+ `curl https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/${toolchain}.zip -o ${toolchain}.zip`
16
+ );
17
+
18
+ if (!existsSync('toolchains')) {
19
+ mkdirSync('toolchains');
20
+ }
21
+
22
+ if (!existsSync('toolchains/' + toolchain)) {
23
+ mkdirSync('toolchains/' + toolchain);
24
+ }
25
+
26
+ execSync(`tar -xzf ../../${toolchain}.zip`, {
27
+ cwd: `toolchains/${toolchain}`,
28
+ });
29
+
30
+ unlinkSync(`${toolchain}.zip`);
31
+ process.stdout.write('Done.\n');
32
+ }
33
+
34
+ for (const target of unpatched) {
35
+ execSync(`rustup target add ${target}`);
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/renderer",
3
- "version": "4.0.0-alpha4",
3
+ "version": "4.0.0-alpha5",
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": "4.0.0-alpha4",
19
+ "remotion": "4.0.0-alpha5",
20
20
  "source-map": "^0.8.0-beta.0",
21
21
  "ws": "8.7.0"
22
22
  },
@@ -38,16 +38,17 @@
38
38
  "react": "18.0.0",
39
39
  "react-dom": "18.0.0",
40
40
  "typescript": "^4.7.0",
41
- "vitest": "0.24.3"
41
+ "vitest": "0.24.3",
42
+ "zod": "^3.21.4"
42
43
  },
43
44
  "optionalDependencies": {
44
- "@remotion/compositor-darwin-arm64": "4.0.0-alpha4",
45
- "@remotion/compositor-darwin-x64": "4.0.0-alpha4",
46
- "@remotion/compositor-linux-arm64-gnu": "4.0.0-alpha4",
47
- "@remotion/compositor-linux-arm64-musl": "4.0.0-alpha4",
48
- "@remotion/compositor-linux-x64-gnu": "4.0.0-alpha4",
49
- "@remotion/compositor-linux-x64-musl": "4.0.0-alpha4",
50
- "@remotion/compositor-win32-x64-msvc": "4.0.0-alpha4"
45
+ "@remotion/compositor-darwin-arm64": "4.0.0-alpha5",
46
+ "@remotion/compositor-darwin-x64": "4.0.0-alpha5",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.0.0-alpha5",
48
+ "@remotion/compositor-linux-arm64-musl": "4.0.0-alpha5",
49
+ "@remotion/compositor-linux-x64-gnu": "4.0.0-alpha5",
50
+ "@remotion/compositor-linux-x64-musl": "4.0.0-alpha5",
51
+ "@remotion/compositor-win32-x64-msvc": "4.0.0-alpha5"
51
52
  },
52
53
  "keywords": [
53
54
  "remotion",