@remotion/renderer 4.0.157 → 4.0.159

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.
@@ -37,10 +37,18 @@ const startCompositor = ({ type, payload, logLevel, indent, binariesDirectory =
37
37
  });
38
38
  (0, make_file_executable_1.makeFileExecutableIfItIsNot)(bin);
39
39
  const fullCommand = (0, compose_1.serializeCommand)(type, payload);
40
+ const cwd = node_path_1.default.dirname(bin);
40
41
  const child = (0, node_child_process_1.spawn)(bin, [JSON.stringify(fullCommand)], {
41
- cwd: node_path_1.default.dirname(bin),
42
+ cwd,
43
+ env: process.platform === 'darwin'
44
+ ? {
45
+ // Should work out of the box, but sometimes it doesn't
46
+ // https://github.com/remotion-dev/remotion/issues/3862
47
+ DYLD_LIBRARY_PATH: cwd,
48
+ }
49
+ : undefined,
42
50
  });
43
- const stderrChunks = [];
51
+ let stderrChunks = [];
44
52
  let outputBuffer = Buffer.from('');
45
53
  const separator = Buffer.from('remotion_buffer:');
46
54
  const waiters = new Map();
@@ -168,6 +176,9 @@ const startCompositor = ({ type, payload, logLevel, indent, binariesDirectory =
168
176
  waiters.clear();
169
177
  reject === null || reject === void 0 ? void 0 : reject(error);
170
178
  }
179
+ // Need to manually free up memory
180
+ outputBuffer = Buffer.from('');
181
+ stderrChunks = [];
171
182
  });
172
183
  return {
173
184
  waitForDone: () => {
@@ -39,6 +39,7 @@ const prores_profile_1 = require("./prores-profile");
39
39
  const render_frames_1 = require("./render-frames");
40
40
  const repro_1 = require("./repro");
41
41
  const stitch_frames_to_video_1 = require("./stitch-frames-to-video");
42
+ const succeed_or_cancel_1 = require("./succeed-or-cancel");
42
43
  const validate_1 = require("./validate");
43
44
  const validate_even_dimensions_with_codec_1 = require("./validate-even-dimensions-with-codec");
44
45
  const validate_every_nth_frame_1 = require("./validate-every-nth-frame");
@@ -368,57 +369,55 @@ const internalRenderMediaRaw = ({ proResProfile, x264Preset, crf, composition, s
368
369
  (0, ensure_output_directory_1.ensureOutputDirectory)(absoluteOutputLocation);
369
370
  }
370
371
  const stitchStart = Date.now();
371
- return Promise.all([
372
- (0, stitch_frames_to_video_1.internalStitchFramesToVideo)({
373
- width: composition.width * scale,
374
- height: composition.height * scale,
375
- fps,
376
- outputLocation: absoluteOutputLocation,
377
- preEncodedFileLocation,
378
- preferLossless,
379
- indent,
380
- force: overwrite,
381
- pixelFormat,
382
- codec,
383
- proResProfile,
384
- crf,
385
- assetsInfo,
386
- onProgress: (frame) => {
387
- stitchStage = 'muxing';
388
- if (preEncodedFileLocation) {
389
- muxedFrames = frame;
390
- }
391
- else {
392
- muxedFrames = frame;
393
- encodedFrames = frame;
394
- }
395
- if (encodedFrames === totalFramesToRender) {
396
- encodedDoneIn = Date.now() - stitchStart;
397
- }
398
- if (frame > 0) {
399
- callUpdate();
400
- }
401
- },
402
- onDownload,
403
- numberOfGifLoops,
404
- logLevel,
405
- cancelSignal: cancelStitcher.cancelSignal,
406
- muted: disableAudio,
407
- enforceAudioTrack,
408
- ffmpegOverride: ffmpegOverride !== null && ffmpegOverride !== void 0 ? ffmpegOverride : null,
409
- audioBitrate,
410
- videoBitrate,
411
- encodingBufferSize,
412
- encodingMaxRate,
413
- audioCodec,
414
- x264Preset: x264Preset !== null && x264Preset !== void 0 ? x264Preset : null,
415
- colorSpace,
416
- binariesDirectory,
417
- separateAudioTo,
418
- }),
419
- ]);
372
+ return (0, stitch_frames_to_video_1.internalStitchFramesToVideo)({
373
+ width: composition.width * scale,
374
+ height: composition.height * scale,
375
+ fps,
376
+ outputLocation: absoluteOutputLocation,
377
+ preEncodedFileLocation,
378
+ preferLossless,
379
+ indent,
380
+ force: overwrite,
381
+ pixelFormat,
382
+ codec,
383
+ proResProfile,
384
+ crf,
385
+ assetsInfo,
386
+ onProgress: (frame) => {
387
+ stitchStage = 'muxing';
388
+ if (preEncodedFileLocation) {
389
+ muxedFrames = frame;
390
+ }
391
+ else {
392
+ muxedFrames = frame;
393
+ encodedFrames = frame;
394
+ }
395
+ if (encodedFrames === totalFramesToRender) {
396
+ encodedDoneIn = Date.now() - stitchStart;
397
+ }
398
+ if (frame > 0) {
399
+ callUpdate();
400
+ }
401
+ },
402
+ onDownload,
403
+ numberOfGifLoops,
404
+ logLevel,
405
+ cancelSignal: cancelStitcher.cancelSignal,
406
+ muted: disableAudio,
407
+ enforceAudioTrack,
408
+ ffmpegOverride: ffmpegOverride !== null && ffmpegOverride !== void 0 ? ffmpegOverride : null,
409
+ audioBitrate,
410
+ videoBitrate,
411
+ encodingBufferSize,
412
+ encodingMaxRate,
413
+ audioCodec,
414
+ x264Preset: x264Preset !== null && x264Preset !== void 0 ? x264Preset : null,
415
+ colorSpace,
416
+ binariesDirectory,
417
+ separateAudioTo,
418
+ });
420
419
  })
421
- .then(([buffer]) => {
420
+ .then((buffer) => {
422
421
  logger_1.Log.verbose({ indent, logLevel }, 'Stitching done in', encodedDoneIn + 'ms');
423
422
  slowestFrames.sort((a, b) => b.time - a.time);
424
423
  const result = {
@@ -478,14 +477,11 @@ const internalRenderMediaRaw = ({ proResProfile, x264Preset, crf, composition, s
478
477
  });
479
478
  });
480
479
  });
481
- return Promise.race([
480
+ return (0, succeed_or_cancel_1.succeedOrCancel)({
482
481
  happyPath,
483
- new Promise((_resolve, reject) => {
484
- cancelSignal === null || cancelSignal === void 0 ? void 0 : cancelSignal(() => {
485
- reject(new Error(make_cancel_signal_1.cancelErrorMessages.renderMedia));
486
- });
487
- }),
488
- ]);
482
+ cancelSignal,
483
+ cancelMessage: make_cancel_signal_1.cancelErrorMessages.renderMedia,
484
+ });
489
485
  };
490
486
  exports.internalRenderMedia = (0, wrap_with_error_handling_1.wrapWithErrorHandling)(internalRenderMediaRaw);
491
487
  /**
@@ -16,6 +16,15 @@ const innerSetPropsAndEnv = async ({ serializedInputPropsWithCustomSchema, envVa
16
16
  const urlToVisit = (0, normalize_serve_url_1.normalizeServeUrl)(serveUrl);
17
17
  await page.evaluateOnNewDocument((timeout) => {
18
18
  window.remotion_puppeteerTimeout = timeout;
19
+ // To make getRemotionEnvironment() work
20
+ if (window.process === undefined) {
21
+ // @ts-expect-error
22
+ window.process = {};
23
+ }
24
+ if (window.process.env === undefined) {
25
+ window.process.env = {};
26
+ }
27
+ window.process.env.NODE_ENV = 'production';
19
28
  }, actualTimeout);
20
29
  await page.evaluateOnNewDocument((input) => {
21
30
  window.remotion_inputProps = input;
@@ -285,9 +285,9 @@ const innerStitchFramesToVideo = async ({ assetsInfo, audioBitrate, audioCodec:
285
285
  });
286
286
  });
287
287
  };
288
- const internalStitchFramesToVideo = async (options) => {
288
+ const internalStitchFramesToVideo = (options) => {
289
289
  const remotionRoot = (0, find_closest_package_json_1.findRemotionRoot)();
290
- const task = await innerStitchFramesToVideo(options, remotionRoot);
290
+ const task = innerStitchFramesToVideo(options, remotionRoot);
291
291
  return Promise.race([
292
292
  task,
293
293
  new Promise((_resolve, reject) => {
@@ -0,0 +1,6 @@
1
+ import { type CancelSignal } from './make-cancel-signal';
2
+ export declare const succeedOrCancel: <T>({ happyPath, cancelSignal, cancelMessage, }: {
3
+ happyPath: Promise<T>;
4
+ cancelSignal: CancelSignal | undefined;
5
+ cancelMessage: string;
6
+ }) => Promise<T>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.succeedOrCancel = void 0;
4
+ const succeedOrCancel = ({ happyPath, cancelSignal, cancelMessage, }) => {
5
+ if (!cancelSignal) {
6
+ return happyPath;
7
+ }
8
+ let resolveCancel = () => undefined;
9
+ const cancelProm = new Promise((_resolve, reject) => {
10
+ cancelSignal === null || cancelSignal === void 0 ? void 0 : cancelSignal(() => {
11
+ resolveCancel = _resolve;
12
+ reject(new Error(cancelMessage));
13
+ });
14
+ });
15
+ return Promise.race([
16
+ happyPath.then((result) => {
17
+ process.nextTick(() => resolveCancel === null || resolveCancel === void 0 ? void 0 : resolveCancel(undefined));
18
+ return result;
19
+ }),
20
+ cancelProm,
21
+ ]);
22
+ };
23
+ exports.succeedOrCancel = succeedOrCancel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/renderer",
3
- "version": "4.0.157",
3
+ "version": "4.0.159",
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.157"
21
+ "remotion": "4.0.159"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": ">=16.8.0",
@@ -43,13 +43,13 @@
43
43
  "@types/ws": "8.5.10"
44
44
  },
45
45
  "optionalDependencies": {
46
- "@remotion/compositor-darwin-arm64": "4.0.157",
47
- "@remotion/compositor-darwin-x64": "4.0.157",
48
- "@remotion/compositor-linux-arm64-gnu": "4.0.157",
49
- "@remotion/compositor-linux-x64-gnu": "4.0.157",
50
- "@remotion/compositor-linux-arm64-musl": "4.0.157",
51
- "@remotion/compositor-linux-x64-musl": "4.0.157",
52
- "@remotion/compositor-win32-x64-msvc": "4.0.157"
46
+ "@remotion/compositor-darwin-arm64": "4.0.159",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.0.159",
48
+ "@remotion/compositor-darwin-x64": "4.0.159",
49
+ "@remotion/compositor-linux-x64-gnu": "4.0.159",
50
+ "@remotion/compositor-linux-arm64-musl": "4.0.159",
51
+ "@remotion/compositor-linux-x64-musl": "4.0.159",
52
+ "@remotion/compositor-win32-x64-msvc": "4.0.159"
53
53
  },
54
54
  "keywords": [
55
55
  "remotion",