@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
@@ -1,10 +1,12 @@
1
+ import execa from 'execa';
1
2
  import type { Codec } from './codec';
3
+ import type { FfmpegExecutable } from './ffmpeg-executable';
2
4
  import type { FfmpegOverrideFn } from './ffmpeg-override';
3
- import type { VideoImageFormat } from './image-format';
5
+ import type { ImageFormat } from './image-format';
4
6
  import type { CancelSignal } from './make-cancel-signal';
5
7
  import type { PixelFormat } from './pixel-format';
6
8
  import type { ProResProfile } from './prores-profile';
7
- declare type PreStitcherOptions = {
9
+ declare type PreSticherOptions = {
8
10
  fps: number;
9
11
  width: number;
10
12
  height: number;
@@ -15,13 +17,14 @@ declare type PreStitcherOptions = {
15
17
  onProgress: (progress: number) => void;
16
18
  proResProfile: ProResProfile | undefined;
17
19
  verbose: boolean;
18
- imageFormat: VideoImageFormat;
20
+ ffmpegExecutable: FfmpegExecutable | undefined;
21
+ imageFormat: ImageFormat;
19
22
  ffmpegOverride: FfmpegOverrideFn;
20
23
  signal: CancelSignal;
21
24
  videoBitrate: string | null;
22
25
  };
23
- export declare const prespawnFfmpeg: (options: PreStitcherOptions) => {
24
- task: import("execa").ExecaChildProcess<string>;
26
+ export declare const prespawnFfmpeg: (options: PreSticherOptions, remotionRoot: string) => Promise<{
27
+ task: execa.ExecaChildProcess<string>;
25
28
  getLogs: () => string;
26
- };
29
+ }>;
27
30
  export {};
@@ -1,18 +1,22 @@
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.prespawnFfmpeg = void 0;
7
+ const execa_1 = __importDefault(require("execa"));
4
8
  const remotion_1 = require("remotion");
5
- const call_ffmpeg_1 = require("./call-ffmpeg");
6
9
  const codec_1 = require("./codec");
7
- const get_executable_path_1 = require("./compositor/get-executable-path");
8
10
  const crf_1 = require("./crf");
11
+ const ffmpeg_flags_1 = require("./ffmpeg-flags");
9
12
  const get_codec_name_1 = require("./get-codec-name");
10
13
  const get_prores_profile_name_1 = require("./get-prores-profile-name");
11
14
  const parse_ffmpeg_progress_1 = require("./parse-ffmpeg-progress");
12
15
  const pixel_format_1 = require("./pixel-format");
13
16
  const validate_even_dimensions_with_codec_1 = require("./validate-even-dimensions-with-codec");
14
- const prespawnFfmpeg = (options) => {
15
- var _a, _b, _c;
17
+ const validate_ffmpeg_1 = require("./validate-ffmpeg");
18
+ const prespawnFfmpeg = async (options, remotionRoot) => {
19
+ var _a, _b, _c, _d, _e, _f;
16
20
  remotion_1.Internals.validateDimension(options.height, 'height', 'passed to `stitchFramesToVideo()`');
17
21
  remotion_1.Internals.validateDimension(options.width, 'width', 'passed to `stitchFramesToVideo()`');
18
22
  const codec = (_a = options.codec) !== null && _a !== void 0 ? _a : codec_1.DEFAULT_CODEC;
@@ -24,6 +28,7 @@ const prespawnFfmpeg = (options) => {
24
28
  scale: 1,
25
29
  });
26
30
  const pixelFormat = (_b = options.pixelFormat) !== null && _b !== void 0 ? _b : pixel_format_1.DEFAULT_PIXEL_FORMAT;
31
+ await (0, validate_ffmpeg_1.validateFfmpeg)((_c = options.ffmpegExecutable) !== null && _c !== void 0 ? _c : null, remotionRoot, 'ffmpeg');
27
32
  const encoderName = (0, get_codec_name_1.getCodecName)(codec);
28
33
  const proResProfileName = (0, get_prores_profile_name_1.getProResProfileName)(codec, options.proResProfile);
29
34
  if (encoderName === null) {
@@ -31,7 +36,7 @@ const prespawnFfmpeg = (options) => {
31
36
  }
32
37
  const supportsCrf = codec !== 'prores';
33
38
  if (options.verbose) {
34
- console.log('[verbose] ffmpeg', (0, get_executable_path_1.getExecutablePath)('ffmpeg'));
39
+ console.log('[verbose] ffmpeg', (_d = options.ffmpegExecutable) !== null && _d !== void 0 ? _d : 'ffmpeg in PATH');
35
40
  console.log('[verbose] encoder', encoderName);
36
41
  console.log('[verbose] pixelFormat', pixelFormat);
37
42
  if (supportsCrf) {
@@ -75,12 +80,12 @@ const prespawnFfmpeg = (options) => {
75
80
  const finalFfmpegString = options.ffmpegOverride
76
81
  ? options.ffmpegOverride({ type: 'pre-stitcher', args: ffmpegString })
77
82
  : ffmpegString;
78
- const task = (0, call_ffmpeg_1.callFf)('ffmpeg', finalFfmpegString);
83
+ const task = (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)((_e = options.ffmpegExecutable) !== null && _e !== void 0 ? _e : null, remotionRoot, 'ffmpeg'), finalFfmpegString);
79
84
  options.signal(() => {
80
85
  task.kill();
81
86
  });
82
87
  let ffmpegOutput = '';
83
- (_c = task.stderr) === null || _c === void 0 ? void 0 : _c.on('data', (data) => {
88
+ (_f = task.stderr) === null || _f === void 0 ? void 0 : _f.on('data', (data) => {
84
89
  const str = data.toString();
85
90
  ffmpegOutput += str;
86
91
  if (options.onProgress) {
@@ -1,3 +1,7 @@
1
+ export declare const estimateMemoryUsageForPrestitcher: ({ width, height, }: {
2
+ width: number;
3
+ height: number;
4
+ }) => number;
1
5
  export declare const shouldUseParallelEncoding: ({ width, height, }: {
2
6
  width: number;
3
7
  height: number;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.shouldUseParallelEncoding = void 0;
6
+ exports.shouldUseParallelEncoding = exports.estimateMemoryUsageForPrestitcher = void 0;
7
7
  const os_1 = __importDefault(require("os"));
8
8
  const estimateMemoryUsageForPrestitcher = ({ width, height, }) => {
9
9
  // Empirically we detected that per 1 million pixels, FFMPEG uses around 1GB of memory, relatively independent of
@@ -12,9 +12,10 @@ const estimateMemoryUsageForPrestitcher = ({ width, height, }) => {
12
12
  const memoryUsageOfPixel = memoryUsageFor4K / 1000000;
13
13
  return memoryUsageOfPixel * width * height;
14
14
  };
15
+ exports.estimateMemoryUsageForPrestitcher = estimateMemoryUsageForPrestitcher;
15
16
  const shouldUseParallelEncoding = ({ width, height, }) => {
16
17
  const freeMemory = os_1.default.freemem();
17
- const estimatedUsage = estimateMemoryUsageForPrestitcher({
18
+ const estimatedUsage = (0, exports.estimateMemoryUsageForPrestitcher)({
18
19
  height,
19
20
  width,
20
21
  });
@@ -1,7 +1,8 @@
1
1
  import type { Codec } from './codec';
2
- export declare const proResProfileOptions: readonly ["4444-xq", "4444", "hq", "standard", "light", "proxy"];
2
+ declare const proResProfileOptions: readonly ["4444-xq", "4444", "hq", "standard", "light", "proxy"];
3
3
  export declare type ProResProfile = typeof proResProfileOptions[number];
4
4
  export declare const validateSelectedCodecAndProResCombination: ({ codec, proResProfile, }: {
5
5
  codec: Codec;
6
6
  proResProfile: ProResProfile | undefined;
7
7
  }) => void;
8
+ export {};
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateSelectedCodecAndProResCombination = exports.proResProfileOptions = void 0;
4
- exports.proResProfileOptions = [
3
+ exports.validateSelectedCodecAndProResCombination = void 0;
4
+ const proResProfileOptions = [
5
5
  '4444-xq',
6
6
  '4444',
7
7
  'hq',
@@ -14,8 +14,8 @@ const validateSelectedCodecAndProResCombination = ({ codec, proResProfile, }) =>
14
14
  throw new TypeError(`You have set a ProRes profile but the codec is "${codec}". Set the codec to "prores" or remove the ProRes profile.`);
15
15
  }
16
16
  if (proResProfile !== undefined &&
17
- !exports.proResProfileOptions.includes(proResProfile)) {
18
- throw new TypeError(`The ProRes profile "${proResProfile}" is not valid. Valid options are ${exports.proResProfileOptions
17
+ !proResProfileOptions.includes(proResProfile)) {
18
+ throw new TypeError(`The ProRes profile "${proResProfile}" is not valid. Valid options are ${proResProfileOptions
19
19
  .map((p) => `"${p}"`)
20
20
  .join(', ')}`);
21
21
  }
@@ -1,11 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import type { ClipRegion } from 'remotion';
3
3
  import type { Page } from './browser/BrowserPage';
4
- import type { StillImageFormat } from './image-format';
5
- export declare const provideScreenshot: ({ page, imageFormat, options, jpegQuality, height, width, clipRegion, }: {
4
+ import type { ImageFormat } from './image-format';
5
+ export declare const provideScreenshot: ({ page, imageFormat, options, quality, height, width, clipRegion, }: {
6
6
  page: Page;
7
- imageFormat: StillImageFormat;
8
- jpegQuality: number | undefined;
7
+ imageFormat: ImageFormat;
8
+ quality: number | undefined;
9
9
  options: {
10
10
  frame: number;
11
11
  output: string | null;
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.provideScreenshot = void 0;
4
4
  const screenshot_dom_element_1 = require("./screenshot-dom-element");
5
- const provideScreenshot = ({ page, imageFormat, options, jpegQuality, height, width, clipRegion, }) => {
5
+ const provideScreenshot = ({ page, imageFormat, options, quality, height, width, clipRegion, }) => {
6
6
  return (0, screenshot_dom_element_1.screenshotDOMElement)({
7
7
  page,
8
8
  opts: {
9
9
  path: options.output,
10
10
  },
11
11
  imageFormat,
12
- jpegQuality,
12
+ quality,
13
13
  height,
14
14
  width,
15
15
  clipRegion,
@@ -1,12 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import type { ClipRegion } from 'remotion';
3
3
  import type { Page } from './browser/BrowserPage';
4
- import type { StillImageFormat } from './image-format';
5
4
  export declare const screenshot: (options: {
6
5
  page: Page;
7
- type: StillImageFormat;
6
+ type: 'png' | 'jpeg';
8
7
  path?: string;
9
- jpegQuality?: number;
8
+ quality?: number;
10
9
  omitBackground: boolean;
11
10
  width: number;
12
11
  height: number;
@@ -27,22 +27,45 @@ exports.screenshot = void 0;
27
27
  const assert = __importStar(require("assert"));
28
28
  const screenshot_task_1 = require("./screenshot-task");
29
29
  const screenshot = (options) => {
30
- if (options.jpegQuality) {
31
- assert.ok(options.type === 'jpeg', `options.quality is unsupported for the ${options.type} screenshots`);
32
- assert.ok(typeof options.jpegQuality === 'number', 'Expected options.quality to be a number but found ' +
33
- typeof options.jpegQuality);
34
- assert.ok(Number.isInteger(options.jpegQuality), 'Expected options.quality to be an integer');
35
- assert.ok(options.jpegQuality >= 0 && options.jpegQuality <= 100, 'Expected options.quality to be between 0 and 100 (inclusive), got ' +
36
- options.jpegQuality);
30
+ let screenshotType = null;
31
+ // options.type takes precedence over inferring the type from options.path
32
+ // because it may be a 0-length file with no extension created beforehand
33
+ // (i.e. as a temp file).
34
+ if (options.type) {
35
+ assert.ok(options.type === 'png' || options.type === 'jpeg', 'Unknown options.type value: ' + options.type);
36
+ screenshotType = options.type;
37
+ }
38
+ else if (options.path) {
39
+ const filePath = options.path;
40
+ const extension = filePath
41
+ .slice(filePath.lastIndexOf('.') + 1)
42
+ .toLowerCase();
43
+ if (extension === 'png')
44
+ screenshotType = 'png';
45
+ else if (extension === 'jpg' || extension === 'jpeg')
46
+ screenshotType = 'jpeg';
47
+ assert.ok(screenshotType, `Unsupported screenshot type for extension \`.${extension}\``);
48
+ }
49
+ if (!screenshotType)
50
+ screenshotType = 'png';
51
+ if (options.quality) {
52
+ assert.ok(screenshotType === 'jpeg', 'options.quality is unsupported for the ' +
53
+ screenshotType +
54
+ ' screenshots');
55
+ assert.ok(typeof options.quality === 'number', 'Expected options.quality to be a number but found ' +
56
+ typeof options.quality);
57
+ assert.ok(Number.isInteger(options.quality), 'Expected options.quality to be an integer');
58
+ assert.ok(options.quality >= 0 && options.quality <= 100, 'Expected options.quality to be between 0 and 100 (inclusive), got ' +
59
+ options.quality);
37
60
  }
38
61
  return options.page.screenshotTaskQueue.postTask(() => (0, screenshot_task_1.screenshotTask)({
39
62
  page: options.page,
40
- format: options.type,
63
+ format: screenshotType,
41
64
  height: options.height,
42
65
  width: options.width,
43
66
  omitBackground: options.omitBackground,
44
67
  path: options.path,
45
- jpegQuality: options.jpegQuality,
68
+ quality: options.quality,
46
69
  clipRegion: options.clipRegion,
47
70
  }));
48
71
  };
@@ -1,27 +1,41 @@
1
1
  /// <reference types="node" />
2
- import type { AnySmallCompMetadata } from 'remotion';
2
+ import type { SmallTCompMetadata } from 'remotion';
3
3
  import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
4
4
  import type { DownloadMap } from './assets/download-map';
5
5
  import type { BrowserExecutable } from './browser-executable';
6
6
  import type { BrowserLog } from './browser-log';
7
7
  import type { Browser } from './browser/Browser';
8
+ import type { FfmpegExecutable } from './ffmpeg-executable';
8
9
  import type { FrameRange } from './frame-range';
9
- import type { VideoImageFormat } from './image-format';
10
+ import type { ImageFormat } from './image-format';
11
+ import type { ServeUrlOrWebpackBundle } from './legacy-webpack-config';
10
12
  import type { CancelSignal } from './make-cancel-signal';
11
13
  import type { ChromiumOptions } from './open-browser';
12
14
  import type { OnStartData, RenderFramesOutput } from './types';
15
+ declare type ConfigOrComposition = {
16
+ /**
17
+ * @deprecated This field has been renamed to `composition`
18
+ */
19
+ config: SmallTCompMetadata;
20
+ } | {
21
+ composition: SmallTCompMetadata;
22
+ };
23
+ declare type ConcurrencyOrParallelism = {
24
+ concurrency?: number | string | null;
25
+ } | {
26
+ /**
27
+ * @deprecated This field has been renamed to `concurrency`
28
+ */
29
+ parallelism?: number | null;
30
+ };
13
31
  declare type RenderFramesOptions = {
14
32
  onStart: (data: OnStartData) => void;
15
33
  onFrameUpdate: (framesRendered: number, frameIndex: number, timeToRenderInMilliseconds: number) => void;
16
34
  outputDir: string | null;
17
35
  inputProps: unknown;
18
36
  envVariables?: Record<string, string>;
19
- imageFormat: VideoImageFormat;
20
- /**
21
- * @deprecated Renamed to "jpegQuality"
22
- */
23
- quality?: never;
24
- jpegQuality?: number;
37
+ imageFormat: ImageFormat;
38
+ quality?: number;
25
39
  frameRange?: FrameRange | null;
26
40
  everyNthFrame?: number;
27
41
  dumpBrowserLogs?: boolean;
@@ -33,17 +47,16 @@ declare type RenderFramesOptions = {
33
47
  timeoutInMilliseconds?: number;
34
48
  chromiumOptions?: ChromiumOptions;
35
49
  scale?: number;
50
+ ffmpegExecutable?: FfmpegExecutable;
51
+ ffprobeExecutable?: FfmpegExecutable;
36
52
  port?: number | null;
37
53
  cancelSignal?: CancelSignal;
38
- composition: AnySmallCompMetadata;
39
54
  /**
40
55
  * @deprecated Only for Remotion internal usage
41
56
  */
42
57
  downloadMap?: DownloadMap;
43
58
  muted?: boolean;
44
- concurrency?: number | string | null;
45
- serveUrl: string;
46
- };
59
+ } & ConfigOrComposition & ConcurrencyOrParallelism & ServeUrlOrWebpackBundle;
47
60
  /**
48
61
  * @description Renders a series of images using Puppeteer and computes information for mixing audio.
49
62
  * @see [Documentation](https://www.remotion.dev/docs/renderer/render-frames)
@@ -11,7 +11,6 @@ const remotion_1 = require("remotion");
11
11
  const download_and_map_assets_to_file_1 = require("./assets/download-and-map-assets-to-file");
12
12
  const download_map_1 = require("./assets/download-map");
13
13
  const browser_1 = require("./browser");
14
- const is_target_closed_err_1 = require("./browser/is-target-closed-err");
15
14
  const compress_assets_1 = require("./compress-assets");
16
15
  const cycle_browser_tabs_1 = require("./cycle-browser-tabs");
17
16
  const handle_javascript_exception_1 = require("./error-handling/handle-javascript-exception");
@@ -21,13 +20,14 @@ const get_duration_from_frame_range_1 = require("./get-duration-from-frame-range
21
20
  const get_frame_padded_index_1 = require("./get-frame-padded-index");
22
21
  const get_frame_to_render_1 = require("./get-frame-to-render");
23
22
  const image_format_1 = require("./image-format");
24
- const jpeg_quality_1 = require("./jpeg-quality");
23
+ const legacy_webpack_config_1 = require("./legacy-webpack-config");
25
24
  const make_cancel_signal_1 = require("./make-cancel-signal");
26
25
  const open_browser_1 = require("./open-browser");
27
26
  const perf_1 = require("./perf");
28
27
  const pool_1 = require("./pool");
29
28
  const prepare_server_1 = require("./prepare-server");
30
29
  const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
30
+ const quality_1 = require("./quality");
31
31
  const replace_browser_1 = require("./replace-browser");
32
32
  const seek_to_frame_1 = require("./seek-to-frame");
33
33
  const set_props_and_env_1 = require("./set-props-and-env");
@@ -35,7 +35,25 @@ const take_frame_and_compose_1 = require("./take-frame-and-compose");
35
35
  const truthy_1 = require("./truthy");
36
36
  const validate_scale_1 = require("./validate-scale");
37
37
  const MAX_RETRIES_PER_FRAME = 1;
38
- const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, jpegQuality, quality, imageFormat = image_format_1.DEFAULT_VIDEO_IMAGE_FORMAT, frameRange, onError, envVariables, onBrowserLog, onFrameBuffer, onDownload, pagesArray, serveUrl, composition, timeoutInMilliseconds, scale = 1, actualConcurrency, everyNthFrame = 1, proxyPort, cancelSignal, downloadMap, muted, makeBrowser, browserReplacer, }) => {
38
+ const getComposition = (others) => {
39
+ if ('composition' in others) {
40
+ return others.composition;
41
+ }
42
+ if ('config' in others) {
43
+ return others.config;
44
+ }
45
+ return undefined;
46
+ };
47
+ const getConcurrency = (others) => {
48
+ if ('concurrency' in others) {
49
+ return others.concurrency;
50
+ }
51
+ if ('parallelism' in others) {
52
+ return others.parallelism;
53
+ }
54
+ return undefined;
55
+ };
56
+ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, quality, imageFormat = image_format_1.DEFAULT_IMAGE_FORMAT, frameRange, onError, envVariables, onBrowserLog, onFrameBuffer, onDownload, pagesArray, serveUrl, composition, timeoutInMilliseconds, scale = 1, actualConcurrency, everyNthFrame = 1, proxyPort, cancelSignal, downloadMap, muted, makeBrowser, browserReplacer, }) => {
39
57
  if (outputDir) {
40
58
  if (!fs_1.default.existsSync(outputDir)) {
41
59
  fs_1.default.mkdirSync(outputDir, {
@@ -43,9 +61,6 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, jpeg
43
61
  });
44
62
  }
45
63
  }
46
- if (quality) {
47
- throw new Error(`The "quality" option has been renamed. Use "jpegQuality" instead.`);
48
- }
49
64
  const downloadPromises = [];
50
65
  const realFrameRange = (0, get_frame_to_render_1.getRealFrameRange)(composition.durationInFrames, frameRange !== null && frameRange !== void 0 ? frameRange : null);
51
66
  const framesToRender = (0, get_duration_from_frame_range_1.getFramesToRender)(realFrameRange, everyNthFrame);
@@ -170,7 +185,7 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, jpeg
170
185
  lastFrame,
171
186
  totalFrames: framesToRender.length,
172
187
  })),
173
- jpegQuality,
188
+ quality,
174
189
  width,
175
190
  scale,
176
191
  downloadMap,
@@ -218,21 +233,16 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, jpeg
218
233
  });
219
234
  };
220
235
  const renderFrameAndRetryTargetClose = async (frame, index, retriesLeft, attempt) => {
236
+ var _a, _b;
221
237
  try {
222
- await Promise.race([
223
- renderFrame(frame, index),
224
- new Promise((_, reject) => {
225
- cancelSignal === null || cancelSignal === void 0 ? void 0 : cancelSignal(() => {
226
- reject(new Error(make_cancel_signal_1.cancelErrorMessages.renderFrames));
227
- });
228
- }),
229
- ]);
238
+ await renderFrame(frame, index);
230
239
  }
231
240
  catch (err) {
232
- if ((0, make_cancel_signal_1.isUserCancelledRender)(err)) {
241
+ if (!((_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.includes('Target closed')) &&
242
+ !((_b = err === null || err === void 0 ? void 0 : err.message) === null || _b === void 0 ? void 0 : _b.includes('Session closed'))) {
233
243
  throw err;
234
244
  }
235
- if (!(0, is_target_closed_err_1.isTargetClosedErr)(err)) {
245
+ if ((0, make_cancel_signal_1.isUserCancelledRender)(err)) {
236
246
  throw err;
237
247
  }
238
248
  if (stopped) {
@@ -282,7 +292,8 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, jpeg
282
292
  */
283
293
  const renderFrames = (options) => {
284
294
  var _a, _b, _c;
285
- const { composition, concurrency } = options;
295
+ const composition = getComposition(options);
296
+ const concurrency = getConcurrency(options);
286
297
  if (!composition) {
287
298
  throw new Error('No `composition` option has been specified for renderFrames()');
288
299
  }
@@ -294,10 +305,11 @@ const renderFrames = (options) => {
294
305
  component: 'in the `config` object passed to `renderFrames()`',
295
306
  allowFloats: false,
296
307
  });
297
- if (options.jpegQuality !== undefined && options.imageFormat !== 'jpeg') {
298
- throw new Error("You can only pass the `jpegQuality` option if `imageFormat` is 'jpeg'.");
308
+ if (options.quality !== undefined && options.imageFormat !== 'jpeg') {
309
+ throw new Error("You can only pass the `quality` option if `imageFormat` is 'jpeg'.");
299
310
  }
300
- (0, jpeg_quality_1.validateJpegQuality)(options.jpegQuality);
311
+ const selectedServeUrl = (0, legacy_webpack_config_1.getServeUrlWithFallback)(options);
312
+ (0, quality_1.validateQuality)(options.quality);
301
313
  (0, validate_scale_1.validateScale)(options.scale);
302
314
  const makeBrowser = () => {
303
315
  var _a;
@@ -314,7 +326,7 @@ const renderFrames = (options) => {
314
326
  const actualConcurrency = (0, get_concurrency_1.getActualConcurrency)(concurrency !== null && concurrency !== void 0 ? concurrency : null);
315
327
  const openedPages = [];
316
328
  return new Promise((resolve, reject) => {
317
- var _a;
329
+ var _a, _b, _c;
318
330
  const cleanup = [];
319
331
  if (!options.downloadMap) {
320
332
  cleanup.push(() => (0, download_map_1.cleanDownloadMap)(downloadMap));
@@ -331,10 +343,12 @@ const renderFrames = (options) => {
331
343
  }),
332
344
  Promise.all([
333
345
  (0, prepare_server_1.prepareServer)({
334
- webpackConfigOrServeUrl: options.serveUrl,
346
+ webpackConfigOrServeUrl: selectedServeUrl,
335
347
  onDownload,
336
348
  onError,
337
- port: (_a = options.port) !== null && _a !== void 0 ? _a : null,
349
+ ffmpegExecutable: (_a = options.ffmpegExecutable) !== null && _a !== void 0 ? _a : null,
350
+ ffprobeExecutable: (_b = options.ffprobeExecutable) !== null && _b !== void 0 ? _b : null,
351
+ port: (_c = options.port) !== null && _c !== void 0 ? _c : null,
338
352
  downloadMap,
339
353
  remotionRoot: (0, find_closest_package_json_1.findRemotionRoot)(),
340
354
  }),
@@ -370,10 +384,9 @@ const renderFrames = (options) => {
370
384
  // If new browser was opened, then closing the browser as a cleanup.
371
385
  if (options.puppeteerInstance) {
372
386
  Promise.all(openedPages.map((p) => p.close())).catch((err) => {
373
- if ((0, is_target_closed_err_1.isTargetClosedErr)(err)) {
374
- return;
387
+ if (!(err === null || err === void 0 ? void 0 : err.message.includes('Target closed'))) {
388
+ console.log('Unable to close browser tab', err);
375
389
  }
376
- console.log('Unable to close browser tab', err);
377
390
  });
378
391
  }
379
392
  else {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { AnySmallCompMetadata } from 'remotion';
2
+ import type { SmallTCompMetadata } from 'remotion';
3
3
  import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
4
4
  import type { DownloadMap } from './assets/download-map';
5
5
  import type { AudioCodec } from './audio-codec';
@@ -7,9 +7,10 @@ import type { BrowserExecutable } from './browser-executable';
7
7
  import type { BrowserLog } from './browser-log';
8
8
  import type { Browser as PuppeteerBrowser } from './browser/Browser';
9
9
  import type { Codec } from './codec';
10
+ import type { FfmpegExecutable } from './ffmpeg-executable';
10
11
  import type { FfmpegOverrideFn } from './ffmpeg-override';
11
12
  import type { FrameRange } from './frame-range';
12
- import type { VideoImageFormat } from './image-format';
13
+ import type { ServeUrlOrWebpackBundle } from './legacy-webpack-config';
13
14
  import type { CancelSignal } from './make-cancel-signal';
14
15
  import type { ChromiumOptions } from './open-browser';
15
16
  import type { PixelFormat } from './pixel-format';
@@ -20,6 +21,7 @@ export declare type SlowFrame = {
20
21
  frame: number;
21
22
  time: number;
22
23
  };
24
+ export declare type OnSlowestFrames = (frames: SlowFrame[]) => void;
23
25
  export declare type RenderMediaOnProgress = (progress: {
24
26
  renderedFrames: number;
25
27
  encodedFrames: number;
@@ -31,17 +33,15 @@ export declare type RenderMediaOnProgress = (progress: {
31
33
  export declare type RenderMediaOptions = {
32
34
  outputLocation?: string | null;
33
35
  codec: Codec;
34
- composition: AnySmallCompMetadata;
36
+ composition: SmallTCompMetadata;
35
37
  inputProps?: unknown;
36
38
  crf?: number | null;
37
- imageFormat?: VideoImageFormat;
39
+ imageFormat?: 'png' | 'jpeg' | 'none';
40
+ ffmpegExecutable?: FfmpegExecutable;
41
+ ffprobeExecutable?: FfmpegExecutable;
38
42
  pixelFormat?: PixelFormat;
39
43
  envVariables?: Record<string, string>;
40
- /**
41
- * @deprecated Renamed to `jpegQuality`
42
- */
43
- quality?: never;
44
- jpegQuality?: number;
44
+ quality?: number;
45
45
  frameRange?: FrameRange | null;
46
46
  everyNthFrame?: number;
47
47
  numberOfGifLoops?: number | null;
@@ -76,20 +76,22 @@ export declare type RenderMediaOptions = {
76
76
  ffmpegOverride?: FfmpegOverrideFn;
77
77
  audioBitrate?: string | null;
78
78
  videoBitrate?: string | null;
79
+ onSlowestFrames?: OnSlowestFrames;
79
80
  disallowParallelEncoding?: boolean;
80
- printLog?: (...data: unknown[]) => void;
81
81
  audioCodec?: AudioCodec | null;
82
- serveUrl: string;
82
+ } & ServeUrlOrWebpackBundle & ConcurrencyOrParallelism;
83
+ declare type ConcurrencyOrParallelism = {
83
84
  concurrency?: number | string | null;
84
- };
85
- declare type RenderMediaResult = {
86
- buffer: Buffer | null;
87
- slowestFrames: SlowFrame[];
85
+ } | {
86
+ /**
87
+ * @deprecated This field has been renamed to `concurrency`
88
+ */
89
+ parallelism?: number | null;
88
90
  };
89
91
  /**
90
92
  *
91
93
  * @description Render a video from a composition
92
94
  * @see [Documentation](https://www.remotion.dev/docs/renderer/render-media)
93
95
  */
94
- export declare const renderMedia: ({ proResProfile, crf, composition, inputProps, pixelFormat, codec, envVariables, frameRange, puppeteerInstance, outputLocation, onProgress, overwrite, onDownload, dumpBrowserLogs, onBrowserLog, onStart, timeoutInMilliseconds, chromiumOptions, scale, browserExecutable, port, cancelSignal, muted, enforceAudioTrack, ffmpegOverride, audioBitrate, videoBitrate, audioCodec, ...options }: RenderMediaOptions) => Promise<RenderMediaResult>;
96
+ export declare const renderMedia: ({ proResProfile, crf, composition, ffmpegExecutable, ffprobeExecutable, inputProps, pixelFormat, codec, envVariables, frameRange, puppeteerInstance, outputLocation, onProgress, overwrite, onDownload, dumpBrowserLogs, onBrowserLog, onStart, timeoutInMilliseconds, chromiumOptions, scale, browserExecutable, port, cancelSignal, muted, enforceAudioTrack, ffmpegOverride, audioBitrate, videoBitrate, onSlowestFrames, audioCodec, ...options }: RenderMediaOptions) => Promise<Buffer | null>;
95
97
  export {};