@remotion/renderer 4.0.0-alpha.217 → 4.0.0-alpha4

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 (142) hide show
  1. package/README.md +18 -12
  2. package/dist/assets/get-audio-channels.d.ts +2 -1
  3. package/dist/assets/get-audio-channels.js +9 -5
  4. package/dist/assets/get-video-stream-duration.d.ts +5 -2
  5. package/dist/assets/get-video-stream-duration.js +12 -6
  6. package/dist/audio-codec.d.ts +3 -4
  7. package/dist/audio-codec.js +9 -3
  8. package/dist/browser/BrowserFetcher.d.ts +16 -63
  9. package/dist/browser/BrowserFetcher.js +126 -213
  10. package/dist/browser/BrowserRunner.js +2 -8
  11. package/dist/browser/FrameManager.js +3 -2
  12. package/dist/browser/LaunchOptions.d.ts +0 -1
  13. package/dist/browser/Launcher.js +3 -9
  14. package/dist/browser/PuppeteerNode.d.ts +0 -3
  15. package/dist/browser/PuppeteerNode.js +0 -5
  16. package/dist/browser/create-browser-fetcher.js +34 -48
  17. package/dist/browser/devtools-commands.d.ts +1 -5
  18. package/dist/browser/devtools-types.d.ts +0 -78
  19. package/dist/check-apple-silicon.js +45 -2
  20. package/dist/client.d.ts +5 -29
  21. package/dist/client.js +1 -26
  22. package/dist/codec-supports-media.d.ts +1 -1
  23. package/dist/codec-supports-media.js +1 -1
  24. package/dist/combine-videos.d.ts +3 -0
  25. package/dist/combine-videos.js +9 -5
  26. package/dist/compositor/compose.js +2 -3
  27. package/dist/compositor/get-executable-path.d.ts +1 -1
  28. package/dist/compositor/get-executable-path.js +8 -15
  29. package/dist/create-ffmpeg-complex-filter.d.ts +4 -1
  30. package/dist/create-ffmpeg-complex-filter.js +4 -2
  31. package/dist/create-ffmpeg-merge-filter.d.ts +5 -2
  32. package/dist/create-ffmpeg-merge-filter.js +10 -2
  33. package/dist/create-silent-audio.d.ts +4 -1
  34. package/dist/create-silent-audio.js +7 -3
  35. package/dist/delete-directory.js +16 -16
  36. package/dist/ensure-presentation-timestamp.d.ts +9 -2
  37. package/dist/ensure-presentation-timestamp.js +13 -5
  38. package/dist/extract-frame-from-video.d.ts +3 -0
  39. package/dist/extract-frame-from-video.js +29 -7
  40. package/dist/file-extensions.d.ts +12 -1
  41. package/dist/file-extensions.js +13 -1
  42. package/dist/get-can-extract-frames-fast.d.ts +4 -1
  43. package/dist/get-can-extract-frames-fast.js +12 -1
  44. package/dist/get-compositions.d.ts +5 -2
  45. package/dist/get-compositions.js +11 -6
  46. package/dist/get-frame-of-video-slow.d.ts +4 -1
  47. package/dist/get-frame-of-video-slow.js +11 -3
  48. package/dist/get-frame-padded-index.d.ts +1 -2
  49. package/dist/get-local-browser-executable.js +3 -12
  50. package/dist/get-video-info.d.ts +5 -2
  51. package/dist/get-video-info.js +12 -6
  52. package/dist/guess-extension-for-media.d.ts +3 -1
  53. package/dist/guess-extension-for-media.js +8 -4
  54. package/dist/image-format.d.ts +6 -12
  55. package/dist/image-format.js +13 -16
  56. package/dist/index.d.ts +25 -36
  57. package/dist/index.js +15 -17
  58. package/dist/last-frame-from-video-cache.d.ts +4 -0
  59. package/dist/last-frame-from-video-cache.js +1 -0
  60. package/dist/merge-audio-track.d.ts +2 -0
  61. package/dist/merge-audio-track.js +10 -3
  62. package/dist/offthread-video-server.d.ts +4 -1
  63. package/dist/offthread-video-server.js +3 -1
  64. package/dist/open-browser.d.ts +0 -1
  65. package/dist/open-browser.js +6 -7
  66. package/dist/perf.d.ts +1 -1
  67. package/dist/perf.js +7 -9
  68. package/dist/prepare-server.d.ts +4 -1
  69. package/dist/prepare-server.js +5 -1
  70. package/dist/preprocess-audio-track.d.ts +4 -0
  71. package/dist/preprocess-audio-track.js +8 -4
  72. package/dist/prespawn-ffmpeg.d.ts +9 -6
  73. package/dist/prespawn-ffmpeg.js +12 -7
  74. package/dist/prestitcher-memory-usage.d.ts +4 -0
  75. package/dist/prestitcher-memory-usage.js +3 -2
  76. package/dist/prores-profile.d.ts +2 -1
  77. package/dist/prores-profile.js +4 -4
  78. package/dist/provide-screenshot.d.ts +4 -4
  79. package/dist/provide-screenshot.js +2 -2
  80. package/dist/puppeteer-screenshot.d.ts +2 -3
  81. package/dist/puppeteer-screenshot.js +32 -9
  82. package/dist/render-frames.d.ts +25 -12
  83. package/dist/render-frames.js +40 -27
  84. package/dist/render-media.d.ts +18 -16
  85. package/dist/render-media.js +43 -31
  86. package/dist/render-still.d.ts +8 -9
  87. package/dist/render-still.js +13 -12
  88. package/dist/screenshot-dom-element.d.ts +4 -4
  89. package/dist/screenshot-dom-element.js +3 -6
  90. package/dist/screenshot-task.d.ts +2 -2
  91. package/dist/screenshot-task.js +23 -38
  92. package/dist/serve-handler/index.js +4 -6
  93. package/dist/serve-static.d.ts +3 -0
  94. package/dist/serve-static.js +3 -3
  95. package/dist/stitch-frames-to-video.d.ts +11 -2
  96. package/dist/stitch-frames-to-video.js +33 -24
  97. package/dist/take-frame-and-compose.d.ts +4 -4
  98. package/dist/take-frame-and-compose.js +6 -12
  99. package/dist/tmp-dir.js +2 -1
  100. package/dist/try-to-extract-frame-of-video-fast.d.ts +4 -1
  101. package/dist/try-to-extract-frame-of-video-fast.js +7 -3
  102. package/dist/validate-concurrency.d.ts +0 -2
  103. package/dist/validate-concurrency.js +5 -11
  104. package/dist/validate-puppeteer-timeout.js +0 -1
  105. package/package.json +68 -71
  106. package/dist/browser/is-target-closed-err.d.ts +0 -1
  107. package/dist/browser/is-target-closed-err.js +0 -9
  108. package/dist/call-ffmpeg.d.ts +0 -17
  109. package/dist/call-ffmpeg.js +0 -34
  110. package/dist/compositor/compositor.d.ts +0 -15
  111. package/dist/compositor/compositor.js +0 -193
  112. package/dist/compositor/make-nonce.d.ts +0 -1
  113. package/dist/compositor/make-nonce.js +0 -8
  114. package/dist/jpeg-quality.d.ts +0 -1
  115. package/dist/jpeg-quality.js +0 -21
  116. package/dist/options/audio-bitrate.d.ts +0 -2
  117. package/dist/options/audio-bitrate.js +0 -11
  118. package/dist/options/crf.d.ts +0 -2
  119. package/dist/options/crf.js +0 -11
  120. package/dist/options/enforce-audio.d.ts +0 -2
  121. package/dist/options/enforce-audio.js +0 -11
  122. package/dist/options/jpeg-quality.d.ts +0 -2
  123. package/dist/options/jpeg-quality.js +0 -11
  124. package/dist/options/mute.d.ts +0 -2
  125. package/dist/options/mute.js +0 -11
  126. package/dist/options/option.d.ts +0 -8
  127. package/dist/options/option.js +0 -2
  128. package/dist/options/scale.d.ts +0 -2
  129. package/dist/options/scale.js +0 -11
  130. package/dist/options/video-bitrate.d.ts +0 -2
  131. package/dist/options/video-bitrate.js +0 -11
  132. package/dist/options/video-codec.d.ts +0 -2
  133. package/dist/options/video-codec.js +0 -11
  134. package/ffmpeg/SOURCE.md +0 -1
  135. package/ffmpeg/linux-arm-musl.gz +0 -0
  136. package/ffmpeg/linux-arm.gz +0 -0
  137. package/ffmpeg/linux-x64-musl.gz +0 -0
  138. package/ffmpeg/linux-x64.gz +0 -0
  139. package/ffmpeg/macos-arm.gz +0 -0
  140. package/ffmpeg/macos-x64.gz +0 -0
  141. package/ffmpeg/windows.gz +0 -0
  142. package/install-toolchain.mjs +0 -42
@@ -26,7 +26,8 @@ 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 = void 0;
29
+ exports.stitchFramesToVideo = exports.spawnFfmpeg = void 0;
30
+ const execa_1 = __importDefault(require("execa"));
30
31
  const fs_1 = __importStar(require("fs"));
31
32
  const path_1 = __importDefault(require("path"));
32
33
  const remotion_1 = require("remotion");
@@ -34,14 +35,13 @@ const calculate_asset_positions_1 = require("./assets/calculate-asset-positions"
34
35
  const convert_assets_to_file_urls_1 = require("./assets/convert-assets-to-file-urls");
35
36
  const download_and_map_assets_to_file_1 = require("./assets/download-and-map-assets-to-file");
36
37
  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");
41
40
  const convert_number_of_gif_loops_to_ffmpeg_1 = require("./convert-number-of-gif-loops-to-ffmpeg");
42
41
  const crf_1 = require("./crf");
43
42
  const delete_directory_1 = require("./delete-directory");
44
43
  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,12 +54,13 @@ 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");
57
58
  const validate_videobitrate_1 = require("./validate-videobitrate");
58
59
  const packageJsonPath = path_1.default.join(__dirname, '..', 'package.json');
59
60
  const packageJson = fs_1.default.existsSync(packageJsonPath)
60
61
  ? JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'))
61
62
  : null;
62
- const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose, onProgress, downloadMap, remotionRoot, }) => {
63
+ const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose, ffmpegExecutable, ffprobeExecutable, onProgress, downloadMap, remotionRoot, }) => {
63
64
  const fileUrlAssets = await (0, convert_assets_to_file_urls_1.convertAssetsToFileUrls)({
64
65
  assets,
65
66
  onDownload: onDownload !== null && onDownload !== void 0 ? onDownload : (() => () => undefined),
@@ -77,11 +78,14 @@ const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose,
77
78
  const preprocessed = (await Promise.all(assetPositions.map(async (asset, index) => {
78
79
  const filterFile = path_1.default.join(downloadMap.audioMixing, `${index}.wav`);
79
80
  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,
80
83
  outName: filterFile,
81
84
  asset,
82
85
  expectedFrames,
83
86
  fps,
84
87
  downloadMap,
88
+ remotionRoot,
85
89
  });
86
90
  preprocessProgress[index] = 1;
87
91
  updateProgress();
@@ -89,6 +93,7 @@ const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose,
89
93
  }))).filter(truthy_1.truthy);
90
94
  const outName = path_1.default.join(downloadMap.audioPreprocessing, `audio.wav`);
91
95
  await (0, merge_audio_track_1.mergeAudioTrack)({
96
+ ffmpegExecutable: ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : null,
92
97
  files: preprocessed,
93
98
  outName,
94
99
  numberOfSeconds: Number((expectedFrames / fps).toFixed(3)),
@@ -103,7 +108,7 @@ const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose,
103
108
  return outName;
104
109
  };
105
110
  const spawnFfmpeg = async (options, remotionRoot) => {
106
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
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;
107
112
  remotion_1.Internals.validateDimension(options.height, 'height', 'passed to `stitchFramesToVideo()`');
108
113
  remotion_1.Internals.validateDimension(options.width, 'width', 'passed to `stitchFramesToVideo()`');
109
114
  const codec = (_a = options.codec) !== null && _a !== void 0 ? _a : codec_1.DEFAULT_CODEC;
@@ -121,6 +126,7 @@ const spawnFfmpeg = async (options, remotionRoot) => {
121
126
  (0, validate_videobitrate_1.validateBitrate)(options.videoBitrate, 'videoBitrate');
122
127
  remotion_1.Internals.validateFps(options.fps, 'in `stitchFramesToVideo()`', false);
123
128
  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');
124
130
  const encoderName = (0, get_codec_name_1.getCodecName)(codec);
125
131
  const proResProfileName = (0, get_prores_profile_name_1.getProResProfileName)(codec, options.proResProfile);
126
132
  const mediaSupport = (0, codec_supports_media_1.codecSupportsMedia)(codec);
@@ -133,14 +139,14 @@ const spawnFfmpeg = async (options, remotionRoot) => {
133
139
  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.');
134
140
  }
135
141
  // Explanation: https://github.com/remotion-dev/remotion/issues/1647
136
- const resolvedAudioCodec = ((_c = options.internalOptions) === null || _c === void 0 ? void 0 : _c.preferLossless)
142
+ const resolvedAudioCodec = ((_d = options.internalOptions) === null || _d === void 0 ? void 0 : _d.preferLossless)
137
143
  ? (0, audio_codec_1.getDefaultAudioCodec)({ codec, preferLossless: true })
138
- : (_d = options.audioCodec) !== null && _d !== void 0 ? _d : (0, audio_codec_1.getDefaultAudioCodec)({ codec, preferLossless: false });
144
+ : (_e = options.audioCodec) !== null && _e !== void 0 ? _e : (0, audio_codec_1.getDefaultAudioCodec)({ codec, preferLossless: false });
139
145
  const tempFile = options.outputLocation
140
146
  ? null
141
147
  : path_1.default.join(options.assetsInfo.downloadMap.stitchFrames, `out.${(0, get_extension_from_codec_1.getFileExtensionFromCodec)(codec, resolvedAudioCodec)}`);
142
148
  if (options.verbose) {
143
- console.log('[verbose] ffmpeg', (0, get_executable_path_1.getExecutablePath)('ffmpeg'));
149
+ console.log('[verbose] ffmpeg', (_f = options.ffmpegExecutable) !== null && _f !== void 0 ? _f : 'ffmpeg in PATH');
144
150
  console.log('[verbose] encoder', encoderName);
145
151
  console.log('[verbose] audioCodec', resolvedAudioCodec);
146
152
  console.log('[verbose] pixelFormat', pixelFormat);
@@ -170,7 +176,9 @@ const spawnFfmpeg = async (options, remotionRoot) => {
170
176
  onDownload: options.onDownload,
171
177
  fps: options.fps,
172
178
  expectedFrames,
173
- verbose: (_e = options.verbose) !== null && _e !== void 0 ? _e : false,
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,
174
182
  onProgress: (prog) => updateProgress(prog, 0),
175
183
  downloadMap: options.assetsInfo.downloadMap,
176
184
  remotionRoot,
@@ -180,22 +188,22 @@ const spawnFfmpeg = async (options, remotionRoot) => {
180
188
  if (!resolvedAudioCodec) {
181
189
  throw new TypeError('exporting audio but has no audio codec name. Report this in the Remotion repo.');
182
190
  }
183
- const ffmpegTask = (0, call_ffmpeg_1.callFf)('ffmpeg', [
191
+ const ffmpegTask = (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)((_k = options.ffmpegExecutable) !== null && _k !== void 0 ? _k : null, remotionRoot, 'ffmpeg'), [
184
192
  '-i',
185
193
  audio,
186
194
  '-c:a',
187
195
  (0, audio_codec_1.mapAudioCodecToFfmpegAudioCodecName)(resolvedAudioCodec),
188
196
  // Set bitrate up to 320k, for aac it might effectively be lower
189
197
  '-b:a',
190
- (_f = options.audioBitrate) !== null && _f !== void 0 ? _f : '320k',
198
+ (_l = options.audioBitrate) !== null && _l !== void 0 ? _l : '320k',
191
199
  options.force ? '-y' : null,
192
- (_g = options.outputLocation) !== null && _g !== void 0 ? _g : tempFile,
200
+ (_m = options.outputLocation) !== null && _m !== void 0 ? _m : tempFile,
193
201
  ].filter(remotion_1.Internals.truthy));
194
- (_h = options.cancelSignal) === null || _h === void 0 ? void 0 : _h.call(options, () => {
202
+ (_o = options.cancelSignal) === null || _o === void 0 ? void 0 : _o.call(options, () => {
195
203
  ffmpegTask.kill();
196
204
  });
197
205
  await ffmpegTask;
198
- (_j = options.onProgress) === null || _j === void 0 ? void 0 : _j.call(options, expectedFrames);
206
+ (_p = options.onProgress) === null || _p === void 0 ? void 0 : _p.call(options, expectedFrames);
199
207
  if (audio) {
200
208
  (0, delete_directory_1.deleteDirectory)(path_1.default.dirname(audio));
201
209
  }
@@ -220,8 +228,8 @@ const spawnFfmpeg = async (options, remotionRoot) => {
220
228
  }
221
229
  const ffmpegArgs = [
222
230
  ['-r', String(options.fps)],
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]]
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]]
225
233
  : [
226
234
  ['-f', 'image2'],
227
235
  ['-s', `${options.width}x${options.height}`],
@@ -229,16 +237,16 @@ const spawnFfmpeg = async (options, remotionRoot) => {
229
237
  ['-i', options.assetsInfo.imageSequenceName],
230
238
  ]),
231
239
  audio ? ['-i', audio] : null,
232
- ((_m = options.numberOfGifLoops) !== null && _m !== void 0 ? _m : null) === null
240
+ ((_s = options.numberOfGifLoops) !== null && _s !== void 0 ? _s : null) === null
233
241
  ? null
234
242
  : [
235
243
  '-loop',
236
- (0, convert_number_of_gif_loops_to_ffmpeg_1.convertNumberOfGifLoopsToFfmpegSyntax)((_o = options.numberOfGifLoops) !== null && _o !== void 0 ? _o : null),
244
+ (0, convert_number_of_gif_loops_to_ffmpeg_1.convertNumberOfGifLoopsToFfmpegSyntax)((_t = options.numberOfGifLoops) !== null && _t !== void 0 ? _t : null),
237
245
  ],
238
246
  // -c:v is the same as -vcodec as -codec:video
239
247
  // and specified the video codec.
240
248
  ['-c:v', encoderName],
241
- ...(((_p = options.internalOptions) === null || _p === void 0 ? void 0 : _p.preEncodedFileLocation)
249
+ ...(((_u = options.internalOptions) === null || _u === void 0 ? void 0 : _u.preEncodedFileLocation)
242
250
  ? []
243
251
  : [
244
252
  proResProfileName ? ['-profile:v', proResProfileName] : null,
@@ -266,7 +274,7 @@ const spawnFfmpeg = async (options, remotionRoot) => {
266
274
  [`Made with Remotion`, packageJson ? packageJson.version : null].join(' '),
267
275
  ],
268
276
  options.force ? '-y' : null,
269
- (_q = options.outputLocation) !== null && _q !== void 0 ? _q : tempFile,
277
+ (_v = options.outputLocation) !== null && _v !== void 0 ? _v : tempFile,
270
278
  ];
271
279
  if (options.verbose) {
272
280
  console.log('Generated FFMPEG command:');
@@ -280,15 +288,15 @@ const spawnFfmpeg = async (options, remotionRoot) => {
280
288
  console.log('Generated final FFMPEG command:');
281
289
  console.log(finalFfmpegString);
282
290
  }
283
- const task = (0, call_ffmpeg_1.callFf)('ffmpeg', finalFfmpegString, {
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, {
284
292
  cwd: options.dir,
285
293
  });
286
- (_r = options.cancelSignal) === null || _r === void 0 ? void 0 : _r.call(options, () => {
294
+ (_x = options.cancelSignal) === null || _x === void 0 ? void 0 : _x.call(options, () => {
287
295
  task.kill();
288
296
  });
289
297
  let ffmpegOutput = '';
290
298
  let isFinished = false;
291
- (_s = task.stderr) === null || _s === void 0 ? void 0 : _s.on('data', (data) => {
299
+ (_y = task.stderr) === null || _y === void 0 ? void 0 : _y.on('data', (data) => {
292
300
  var _a;
293
301
  const str = data.toString();
294
302
  ffmpegOutput += str;
@@ -331,6 +339,7 @@ const spawnFfmpeg = async (options, remotionRoot) => {
331
339
  getLogs: () => ffmpegOutput,
332
340
  };
333
341
  };
342
+ exports.spawnFfmpeg = spawnFfmpeg;
334
343
  /**
335
344
  * @description Takes a series of images and audio information generated by renderFrames() and encodes it to a video.
336
345
  * @see [Documentation](https://www.remotion.dev/docs/renderer/stitch-frames-to-video)
@@ -338,7 +347,7 @@ const spawnFfmpeg = async (options, remotionRoot) => {
338
347
  const stitchFramesToVideo = async (options) => {
339
348
  var _a, _b;
340
349
  const remotionRoot = (0, find_closest_package_json_1.findRemotionRoot)();
341
- const { task, getLogs } = await spawnFfmpeg(options, remotionRoot);
350
+ const { task, getLogs } = await (0, exports.spawnFfmpeg)(options, remotionRoot);
342
351
  const happyPath = task.catch(() => {
343
352
  throw new Error(getLogs());
344
353
  });
@@ -2,11 +2,11 @@
2
2
  import type { TAsset } from 'remotion';
3
3
  import type { DownloadMap } from './assets/download-map';
4
4
  import type { Page } from './browser/BrowserPage';
5
- import type { StillImageFormat, VideoImageFormat } from './image-format';
6
- export declare const takeFrameAndCompose: ({ freePage, imageFormat, jpegQuality, frame, width, height, output, scale, downloadMap, wantsBuffer, }: {
5
+ import type { ImageFormat } from './image-format';
6
+ export declare const takeFrameAndCompose: ({ freePage, imageFormat, quality, frame, width, height, output, scale, downloadMap, wantsBuffer, }: {
7
7
  freePage: Page;
8
- imageFormat: VideoImageFormat | StillImageFormat;
9
- jpegQuality: number | undefined;
8
+ imageFormat: ImageFormat;
9
+ quality: number | undefined;
10
10
  frame: number;
11
11
  height: number;
12
12
  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, jpegQuality, frame, width, height, output, scale, downloadMap, wantsBuffer, }) => {
13
+ const takeFrameAndCompose = async ({ freePage, imageFormat, quality, 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, jpegQuality, frame,
40
40
  ? null
41
41
  : {
42
42
  tmpFile: path_1.default.join(downloadMap.compositingDir, `${frame}.${imageFormat}`),
43
- finalOutFile: output !== null && output !== void 0 ? output : path_1.default.join(downloadMap.compositingDir, `${frame}-final.${imageFormat}`),
43
+ finalOutfie: 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, jpegQuality, frame,
48
48
  const buf = await (0, provide_screenshot_1.provideScreenshot)({
49
49
  page: freePage,
50
50
  imageFormat,
51
- jpegQuality,
51
+ quality,
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,12 +62,6 @@ const takeFrameAndCompose = async ({ freePage, imageFormat, jpegQuality, frame,
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
- }
71
65
  await (0, compose_1.compose)({
72
66
  height: height * scale,
73
67
  width: width * scale,
@@ -87,13 +81,13 @@ const takeFrameAndCompose = async ({ freePage, imageFormat, jpegQuality, frame,
87
81
  },
88
82
  },
89
83
  ].filter(truthy_1.truthy),
90
- output: needsComposing.finalOutFile,
84
+ output: needsComposing.finalOutfie,
91
85
  downloadMap,
92
86
  imageFormat: imageFormat === 'jpeg' ? 'Jpeg' : 'Png',
93
87
  });
94
88
  if (wantsBuffer) {
95
- const buffer = await fs_1.default.promises.readFile(needsComposing.finalOutFile);
96
- await fs_1.default.promises.unlink(needsComposing.finalOutFile);
89
+ const buffer = await fs_1.default.promises.readFile(needsComposing.finalOutfie);
90
+ await fs_1.default.promises.unlink(needsComposing.finalOutfie);
97
91
  return { buffer, collectedAssets };
98
92
  }
99
93
  }
package/dist/tmp-dir.js CHANGED
@@ -40,9 +40,10 @@ const randomHash = () => {
40
40
  .join('');
41
41
  };
42
42
  const tmpDir = (str) => {
43
+ var _a;
43
44
  const newDir = path_1.default.join(os_1.default.tmpdir(), str + randomHash());
44
45
  if (fs_1.default.existsSync(newDir)) {
45
- fs_1.default.rmSync(newDir, {
46
+ ((_a = fs_1.default.rmSync) !== null && _a !== void 0 ? _a : fs_1.default.rmdirSync)(newDir, {
46
47
  recursive: true,
47
48
  force: true,
48
49
  });
@@ -1,7 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import type { OffthreadVideoImageFormat } from 'remotion';
3
3
  import type { NeedsResize, SpecialVCodecForTransparency } from './assets/download-map';
4
- export declare const tryToExtractFrameOfVideoFast: ({ specialVCodecForTransparency, imageFormat, needsResize, src, actualOffset, }: {
4
+ import type { FfmpegExecutable } from './ffmpeg-executable';
5
+ export declare const tryToExtractFrameOfVideoFast: ({ ffmpegExecutable, remotionRoot, specialVCodecForTransparency, imageFormat, needsResize, src, actualOffset, }: {
6
+ ffmpegExecutable: FfmpegExecutable;
7
+ remotionRoot: string;
5
8
  imageFormat: OffthreadVideoImageFormat;
6
9
  needsResize: NeedsResize;
7
10
  src: string;
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.tryToExtractFrameOfVideoFast = void 0;
4
- const call_ffmpeg_1 = require("./call-ffmpeg");
7
+ const execa_1 = __importDefault(require("execa"));
5
8
  const determine_resize_params_1 = require("./determine-resize-params");
6
9
  const determine_vcodec_ffmpeg_flags_1 = require("./determine-vcodec-ffmpeg-flags");
10
+ const ffmpeg_flags_1 = require("./ffmpeg-flags");
7
11
  const truthy_1 = require("./truthy");
8
- const tryToExtractFrameOfVideoFast = async ({ specialVCodecForTransparency, imageFormat, needsResize, src, actualOffset, }) => {
9
- const { stdout, stderr } = (0, call_ffmpeg_1.callFf)('ffmpeg', [
12
+ const tryToExtractFrameOfVideoFast = async ({ ffmpegExecutable, remotionRoot, specialVCodecForTransparency, imageFormat, needsResize, src, actualOffset, }) => {
13
+ const { stdout, stderr } = (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)(ffmpegExecutable, remotionRoot, 'ffmpeg'), [
10
14
  '-ss',
11
15
  actualOffset,
12
16
  ...(0, determine_vcodec_ffmpeg_flags_1.determineVcodecFfmpegFlags)(specialVCodecForTransparency),
@@ -1,3 +1 @@
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.getMinConcurrency = exports.getMaxConcurrency = exports.validateConcurrency = void 0;
3
+ 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 < (0, exports.getMinConcurrency)()) {
19
- throw new Error(`${setting} must be at least ${(0, exports.getMinConcurrency)()}, but is ${JSON.stringify(value)}`);
18
+ if (value < 1) {
19
+ throw new Error(setting + ' must be at least 1, but is ' + value);
20
20
  }
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}`);
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}`);
23
23
  }
24
24
  }
25
25
  else if (!/^\d+(\.\d+)?%$/.test(value)) {
@@ -27,9 +27,3 @@ 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;
@@ -8,7 +8,6 @@ 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
12
11
  if (timeoutInMilliseconds < 7000 && process.env.NODE_ENV !== 'test') {
13
12
  throw new TypeError(`'timeoutInMilliseconds' should be bigger or equal than 7000, but is ${timeoutInMilliseconds}`);
14
13
  }
package/package.json CHANGED
@@ -1,72 +1,69 @@
1
1
  {
2
- "name": "@remotion/renderer",
3
- "version": "4.0.0-alpha.217+27eff7599",
4
- "description": "Renderer for Remotion",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "sideEffects": false,
8
- "scripts": {
9
- "lint": "eslint src --ext ts,tsx",
10
- "test": "vitest --run",
11
- "watch": "tsc -w",
12
- "build": "node build.mjs && tsc -d",
13
- "build-all": "node build.mjs --all",
14
- "prepublishOnly": "node build.mjs --all"
15
- },
16
- "author": "Jonny Burger <jonny@remotion.dev>",
17
- "license": "SEE LICENSE IN LICENSE.md",
18
- "repository": {
19
- "url": "https://github.com/remotion-dev/remotion"
20
- },
21
- "bugs": {
22
- "url": "https://github.com/remotion-dev/remotion/issues"
23
- },
24
- "dependencies": {
25
- "execa": "5.1.1",
26
- "extract-zip": "2.0.1",
27
- "remotion": "4.0.0-alpha.217+27eff7599",
28
- "source-map": "^0.8.0-beta.0",
29
- "ws": "8.7.0"
30
- },
31
- "peerDependencies": {
32
- "react": ">=16.8.0",
33
- "react-dom": ">=16.8.0"
34
- },
35
- "devDependencies": {
36
- "@jonny/eslint-config": "3.0.266",
37
- "@testing-library/dom": "^8.16.0",
38
- "@testing-library/react": "13.3.0",
39
- "@types/node": "^16.7.5",
40
- "@types/progress": "2.0.5",
41
- "@types/react": "18.0.26",
42
- "@types/react-dom": "18.0.10",
43
- "eslint": "8.25.0",
44
- "prettier": "^2.7.1",
45
- "prettier-plugin-organize-imports": "^2.3.4",
46
- "react": "18.0.0",
47
- "react-dom": "18.0.0",
48
- "typescript": "^4.7.0",
49
- "vitest": "0.24.3",
50
- "zod": "^3.21.4"
51
- },
52
- "optionalDependencies": {
53
- "@remotion/compositor-darwin-arm64": "4.0.0-alpha.217+27eff7599",
54
- "@remotion/compositor-darwin-x64": "4.0.0-alpha.217+27eff7599",
55
- "@remotion/compositor-linux-arm64-gnu": "4.0.0-alpha.217+27eff7599",
56
- "@remotion/compositor-linux-arm64-musl": "4.0.0-alpha.217+27eff7599",
57
- "@remotion/compositor-linux-x64-gnu": "4.0.0-alpha.217+27eff7599",
58
- "@remotion/compositor-linux-x64-musl": "4.0.0-alpha.217+27eff7599",
59
- "@remotion/compositor-win32-x64-msvc": "4.0.0-alpha.217+27eff7599"
60
- },
61
- "keywords": [
62
- "remotion",
63
- "ffmpeg",
64
- "video",
65
- "react",
66
- "player"
67
- ],
68
- "publishConfig": {
69
- "access": "public"
70
- },
71
- "gitHead": "27eff759935b19b666e29f4f46dd5bdd6214e188"
72
- }
2
+ "name": "@remotion/renderer",
3
+ "version": "4.0.0-alpha4",
4
+ "description": "Renderer for Remotion",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "sideEffects": false,
8
+ "author": "Jonny Burger <jonny@remotion.dev>",
9
+ "license": "SEE LICENSE IN LICENSE.md",
10
+ "repository": {
11
+ "url": "https://github.com/remotion-dev/remotion"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/remotion-dev/remotion/issues"
15
+ },
16
+ "dependencies": {
17
+ "execa": "5.1.1",
18
+ "extract-zip": "2.0.1",
19
+ "remotion": "4.0.0-alpha4",
20
+ "source-map": "^0.8.0-beta.0",
21
+ "ws": "8.7.0"
22
+ },
23
+ "peerDependencies": {
24
+ "react": ">=16.8.0",
25
+ "react-dom": ">=16.8.0"
26
+ },
27
+ "devDependencies": {
28
+ "@jonny/eslint-config": "3.0.266",
29
+ "@testing-library/dom": "^8.16.0",
30
+ "@testing-library/react": "13.3.0",
31
+ "@types/node": "^16.7.5",
32
+ "@types/progress": "2.0.5",
33
+ "@types/react": "18.0.26",
34
+ "@types/react-dom": "18.0.10",
35
+ "eslint": "8.25.0",
36
+ "prettier": "^2.7.1",
37
+ "prettier-plugin-organize-imports": "^2.3.4",
38
+ "react": "18.0.0",
39
+ "react-dom": "18.0.0",
40
+ "typescript": "^4.7.0",
41
+ "vitest": "0.24.3"
42
+ },
43
+ "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"
51
+ },
52
+ "keywords": [
53
+ "remotion",
54
+ "ffmpeg",
55
+ "video",
56
+ "react",
57
+ "player"
58
+ ],
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "scripts": {
63
+ "lint": "eslint src --ext ts,tsx",
64
+ "test": "vitest --run",
65
+ "watch": "tsc -w",
66
+ "build": "node build.mjs && tsc -d",
67
+ "build-all": "node build.mjs --all"
68
+ }
69
+ }
@@ -1 +0,0 @@
1
- export declare const isTargetClosedErr: (error: Error | undefined) => boolean | undefined;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTargetClosedErr = void 0;
4
- const isTargetClosedErr = (error) => {
5
- var _a, _b;
6
- return (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('Target closed')) ||
7
- ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('Session closed')));
8
- };
9
- exports.isTargetClosedErr = isTargetClosedErr;
@@ -1,17 +0,0 @@
1
- import execa from 'execa';
2
- export declare const callFfExtraOptions: () => {
3
- env: {
4
- DYLD_LIBRARY_PATH: string;
5
- PATH?: undefined;
6
- LD_LIBRARY_PATH?: undefined;
7
- } | {
8
- PATH: string;
9
- DYLD_LIBRARY_PATH?: undefined;
10
- LD_LIBRARY_PATH?: undefined;
11
- } | {
12
- LD_LIBRARY_PATH: string;
13
- DYLD_LIBRARY_PATH?: undefined;
14
- PATH?: undefined;
15
- };
16
- };
17
- export declare const callFf: (bin: 'ffmpeg' | 'ffprobe', args: (string | null)[], options?: execa.Options<string>) => execa.ExecaChildProcess<string>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.callFf = exports.callFfExtraOptions = void 0;
7
- const execa_1 = __importDefault(require("execa"));
8
- const path_1 = __importDefault(require("path"));
9
- const get_executable_path_1 = require("./compositor/get-executable-path");
10
- const truthy_1 = require("./truthy");
11
- const callFfExtraOptions = () => {
12
- const lib = path_1.default.join((0, get_executable_path_1.getExecutablePath)('ffmpeg-cwd'), 'remotion', 'lib');
13
- return {
14
- env: process.platform === 'darwin'
15
- ? {
16
- DYLD_LIBRARY_PATH: lib,
17
- }
18
- : process.platform === 'win32'
19
- ? {
20
- PATH: `${process.env.PATH};${lib}`,
21
- }
22
- : {
23
- LD_LIBRARY_PATH: lib,
24
- },
25
- };
26
- };
27
- exports.callFfExtraOptions = callFfExtraOptions;
28
- const callFf = (bin, args, options) => {
29
- return (0, execa_1.default)((0, get_executable_path_1.getExecutablePath)(bin), args.filter(truthy_1.truthy), {
30
- ...(0, exports.callFfExtraOptions)(),
31
- ...options,
32
- });
33
- };
34
- exports.callFf = callFf;
@@ -1,15 +0,0 @@
1
- /// <reference types="node" />
2
- import type { CompositorCommand } from './payloads';
3
- export declare type Compositor = {
4
- finishCommands: () => void;
5
- executeCommand: <T extends keyof CompositorCommand>(type: T, payload: CompositorCommand[T]) => Promise<Buffer>;
6
- waitForDone: () => Promise<void>;
7
- };
8
- export declare const spawnCompositorOrReuse: <T extends keyof CompositorCommand>({ initiatePayload, renderId, type, }: {
9
- type: T;
10
- initiatePayload: CompositorCommand[T];
11
- renderId: string;
12
- }) => Compositor;
13
- export declare const releaseCompositorWithId: (renderId: string) => void;
14
- export declare const waitForCompositorWithIdToQuit: (renderId: string) => Promise<void>;
15
- export declare const startCompositor: <T extends keyof CompositorCommand>(type: T, payload: CompositorCommand[T]) => Compositor;