@remotion/renderer 4.0.0-alpha5 → 4.0.0-alpha7

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/dist/assets/download-and-map-assets-to-file.js +6 -6
  2. package/dist/assets/download-file.d.ts +3 -2
  3. package/dist/assets/download-file.js +18 -3
  4. package/dist/assets/download-map.js +7 -7
  5. package/dist/assets/read-file.d.ts +1 -1
  6. package/dist/assets/read-file.js +2 -2
  7. package/dist/assets/sanitize-filepath.js +2 -2
  8. package/dist/browser/BrowserFetcher.js +13 -13
  9. package/dist/browser/BrowserRunner.d.ts +1 -1
  10. package/dist/browser/BrowserRunner.js +9 -22
  11. package/dist/browser/LaunchOptions.d.ts +1 -2
  12. package/dist/browser/Launcher.js +7 -15
  13. package/dist/browser/NodeWebSocketTransport.js +4 -4
  14. package/dist/browser/get-download-destination.js +8 -8
  15. package/dist/call-ffmpeg.js +8 -3
  16. package/dist/chalk/index.d.ts +54 -0
  17. package/dist/chalk/index.js +135 -0
  18. package/dist/chalk/is-color-supported.d.ts +1 -0
  19. package/dist/chalk/is-color-supported.js +37 -0
  20. package/dist/client.d.ts +41 -41
  21. package/dist/combine-videos.js +6 -6
  22. package/dist/compositor/compose.js +12 -7
  23. package/dist/compositor/compositor.d.ts +2 -2
  24. package/dist/compositor/compositor.js +13 -8
  25. package/dist/compositor/get-executable-path.js +1 -10
  26. package/dist/create-ffmpeg-complex-filter.d.ts +1 -4
  27. package/dist/delete-directory.js +3 -3
  28. package/dist/does-have-m2-bug.js +2 -2
  29. package/dist/ensure-output-directory.js +5 -5
  30. package/dist/ffmpeg-filter-file.js +7 -7
  31. package/dist/find-closest-package-json.js +6 -6
  32. package/dist/get-compositions.d.ts +4 -0
  33. package/dist/get-compositions.js +2 -1
  34. package/dist/get-concurrency.js +3 -3
  35. package/dist/get-extension-from-codec.d.ts +2 -2
  36. package/dist/get-extension-of-filename.js +2 -2
  37. package/dist/get-local-browser-executable.js +4 -4
  38. package/dist/get-video-threads-flag.js +3 -3
  39. package/dist/index.d.ts +111 -36
  40. package/dist/index.js +9 -0
  41. package/dist/logger.d.ts +22 -0
  42. package/dist/logger.js +61 -0
  43. package/dist/merge-audio-track.js +2 -2
  44. package/dist/mime-types.js +2 -2
  45. package/dist/offthread-video-server.d.ts +3 -2
  46. package/dist/offthread-video-server.js +4 -4
  47. package/dist/open-browser.d.ts +1 -1
  48. package/dist/open-browser.js +1 -1
  49. package/dist/options/jpeg-quality.js +1 -1
  50. package/dist/prepare-server.d.ts +2 -1
  51. package/dist/prepare-server.js +7 -5
  52. package/dist/prespawn-ffmpeg.d.ts +1 -0
  53. package/dist/prespawn-ffmpeg.js +37 -14
  54. package/dist/prestitcher-memory-usage.js +2 -2
  55. package/dist/provide-screenshot.d.ts +1 -0
  56. package/dist/puppeteer-screenshot.d.ts +1 -0
  57. package/dist/puppeteer-screenshot.js +1 -1
  58. package/dist/render-frames.d.ts +4 -0
  59. package/dist/render-frames.js +9 -7
  60. package/dist/render-media.d.ts +4 -1
  61. package/dist/render-media.js +47 -26
  62. package/dist/render-still.d.ts +6 -0
  63. package/dist/render-still.js +20 -7
  64. package/dist/resolve-asset-src.js +2 -2
  65. package/dist/screenshot-dom-element.d.ts +1 -0
  66. package/dist/screenshot-task.d.ts +1 -0
  67. package/dist/screenshot-task.js +2 -2
  68. package/dist/serve-handler/index.d.ts +1 -1
  69. package/dist/serve-handler/index.js +15 -15
  70. package/dist/serve-handler/is-path-inside.js +3 -3
  71. package/dist/serve-static.d.ts +1 -0
  72. package/dist/serve-static.js +3 -2
  73. package/dist/stitch-frames-to-video.d.ts +2 -0
  74. package/dist/stitch-frames-to-video.js +62 -39
  75. package/dist/take-frame-and-compose.d.ts +1 -0
  76. package/dist/take-frame-and-compose.js +6 -6
  77. package/dist/tmp-dir.js +7 -7
  78. package/dist/validate-output-filename.d.ts +1 -1
  79. package/install-toolchain.mjs +2 -2
  80. package/package.json +9 -9
  81. package/types/ws/index.d.ts +5 -5
  82. package/dist/assets/get-video-stream-duration.d.ts +0 -9
  83. package/dist/assets/get-video-stream-duration.js +0 -71
  84. package/dist/calculate-sar-dar-pixels.d.ts +0 -9
  85. package/dist/calculate-sar-dar-pixels.js +0 -19
  86. package/dist/determine-resize-params.d.ts +0 -1
  87. package/dist/determine-resize-params.js +0 -10
  88. package/dist/determine-vcodec-ffmpeg-flags.d.ts +0 -2
  89. package/dist/determine-vcodec-ffmpeg-flags.js +0 -13
  90. package/dist/ensure-ffmpeg.d.ts +0 -18
  91. package/dist/ensure-ffmpeg.js +0 -58
  92. package/dist/ensure-presentation-timestamp.d.ts +0 -15
  93. package/dist/ensure-presentation-timestamp.js +0 -88
  94. package/dist/extract-frame-from-video.d.ts +0 -17
  95. package/dist/extract-frame-from-video.js +0 -191
  96. package/dist/ffmpeg-executable.d.ts +0 -1
  97. package/dist/ffmpeg-executable.js +0 -2
  98. package/dist/ffmpeg-flags.d.ts +0 -31
  99. package/dist/ffmpeg-flags.js +0 -245
  100. package/dist/frame-to-ffmpeg-timestamp.d.ts +0 -1
  101. package/dist/frame-to-ffmpeg-timestamp.js +0 -8
  102. package/dist/get-can-extract-frames-fast.d.ts +0 -14
  103. package/dist/get-can-extract-frames-fast.js +0 -71
  104. package/dist/get-frame-of-video-slow.d.ts +0 -15
  105. package/dist/get-frame-of-video-slow.js +0 -72
  106. package/dist/get-video-info.d.ts +0 -8
  107. package/dist/get-video-info.js +0 -59
  108. package/dist/is-beyond-last-frame.d.ts +0 -3
  109. package/dist/is-beyond-last-frame.js +0 -12
  110. package/dist/last-frame-from-video-cache.d.ts +0 -18
  111. package/dist/last-frame-from-video-cache.js +0 -55
  112. package/dist/legacy-webpack-config.d.ts +0 -9
  113. package/dist/legacy-webpack-config.js +0 -13
  114. package/dist/quality.d.ts +0 -1
  115. package/dist/quality.js +0 -21
  116. package/dist/try-to-extract-frame-of-video-fast.d.ts +0 -13
  117. package/dist/try-to-extract-frame-of-video-fast.js +0 -55
  118. package/dist/validate-ffmpeg.d.ts +0 -7
  119. package/dist/validate-ffmpeg.js +0 -77
  120. package/dist/warn-about-ffmpeg-version.d.ts +0 -5
  121. package/dist/warn-about-ffmpeg-version.js +0 -37
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.serveHandler = void 0;
7
- const fs_1 = require("fs");
8
- const path_1 = __importDefault(require("path"));
9
- const url_1 = __importDefault(require("url"));
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const node_url_1 = __importDefault(require("node:url"));
10
10
  const mime_types_1 = require("../mime-types");
11
11
  // Packages
12
12
  const is_path_inside_1 = require("./is-path-inside");
13
13
  const range_parser_1 = require("./range-parser");
14
14
  const getHeaders = (absolutePath, stats) => {
15
- const { base } = path_1.default.parse(absolutePath);
15
+ const { base } = node_path_1.default.parse(absolutePath);
16
16
  let defaultHeaders = {};
17
17
  if (stats) {
18
18
  defaultHeaders = {
@@ -28,19 +28,19 @@ const getHeaders = (absolutePath, stats) => {
28
28
  return defaultHeaders;
29
29
  };
30
30
  const getPossiblePaths = (relativePath, extension) => [
31
- path_1.default.join(relativePath, `index${extension}`),
31
+ node_path_1.default.join(relativePath, `index${extension}`),
32
32
  relativePath.endsWith('/')
33
33
  ? relativePath.replace(/\/$/g, extension)
34
34
  : relativePath + extension,
35
- ].filter((item) => path_1.default.basename(item) !== extension);
35
+ ].filter((item) => node_path_1.default.basename(item) !== extension);
36
36
  const findRelated = async (current, relativePath) => {
37
37
  const possible = getPossiblePaths(relativePath, '.html');
38
38
  let stats = null;
39
39
  for (let index = 0; index < possible.length; index++) {
40
40
  const related = possible[index];
41
- const absolutePath = path_1.default.join(current, related);
41
+ const absolutePath = node_path_1.default.join(current, related);
42
42
  try {
43
- stats = await fs_1.promises.lstat(absolutePath);
43
+ stats = await node_fs_1.promises.lstat(absolutePath);
44
44
  }
45
45
  catch (err) {
46
46
  if (err.code !== 'ENOENT' &&
@@ -75,10 +75,10 @@ const internalError = (absolutePath, response) => {
75
75
  };
76
76
  const serveHandler = async (request, response, config) => {
77
77
  const cwd = process.cwd();
78
- const current = path_1.default.resolve(cwd, config.public);
78
+ const current = node_path_1.default.resolve(cwd, config.public);
79
79
  let relativePath = null;
80
80
  try {
81
- relativePath = decodeURIComponent(url_1.default.parse(request.url).pathname);
81
+ relativePath = decodeURIComponent(node_url_1.default.parse(request.url).pathname);
82
82
  }
83
83
  catch (err) {
84
84
  return sendError('/', response, {
@@ -87,7 +87,7 @@ const serveHandler = async (request, response, config) => {
87
87
  message: 'Bad Request',
88
88
  });
89
89
  }
90
- let absolutePath = path_1.default.join(current, relativePath);
90
+ let absolutePath = node_path_1.default.join(current, relativePath);
91
91
  // Prevent path traversal vulnerabilities. We could do this
92
92
  // by ourselves, but using the package covers all the edge cases.
93
93
  if (!(0, is_path_inside_1.isPathInside)(absolutePath, current)) {
@@ -109,9 +109,9 @@ const serveHandler = async (request, response, config) => {
109
109
  // directory exists requires loading all the file paths and then checking if
110
110
  // one of them includes the path of the directory. As that's a very
111
111
  // performance-expensive thing to do, we need to ensure it's not happening if not really necessary.
112
- if (path_1.default.extname(relativePath) !== '') {
112
+ if (node_path_1.default.extname(relativePath) !== '') {
113
113
  try {
114
- stats = await fs_1.promises.lstat(absolutePath);
114
+ stats = await node_fs_1.promises.lstat(absolutePath);
115
115
  }
116
116
  catch (err) {
117
117
  if (err.code !== 'ENOENT' &&
@@ -135,7 +135,7 @@ const serveHandler = async (request, response, config) => {
135
135
  }
136
136
  }
137
137
  try {
138
- stats = await fs_1.promises.lstat(absolutePath);
138
+ stats = await node_fs_1.promises.lstat(absolutePath);
139
139
  }
140
140
  catch (err) {
141
141
  if (err.code !== 'ENOENT' &&
@@ -190,7 +190,7 @@ const serveHandler = async (request, response, config) => {
190
190
  }
191
191
  let stream = null;
192
192
  try {
193
- stream = (0, fs_1.createReadStream)(absolutePath, streamOpts !== null && streamOpts !== void 0 ? streamOpts : {});
193
+ stream = (0, node_fs_1.createReadStream)(absolutePath, streamOpts !== null && streamOpts !== void 0 ? streamOpts : {});
194
194
  }
195
195
  catch (err) {
196
196
  return internalError(absolutePath, response);
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isPathInside = void 0;
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  const isPathInside = function (thePath, potentialParent) {
9
9
  // For inside-directory checking, we want to allow trailing slashes, so normalize.
10
10
  thePath = stripTrailingSep(thePath);
@@ -15,12 +15,12 @@ const isPathInside = function (thePath, potentialParent) {
15
15
  potentialParent = potentialParent.toLowerCase();
16
16
  }
17
17
  return (thePath.lastIndexOf(potentialParent, 0) === 0 &&
18
- (thePath[potentialParent.length] === path_1.default.sep ||
18
+ (thePath[potentialParent.length] === node_path_1.default.sep ||
19
19
  thePath[potentialParent.length] === undefined));
20
20
  };
21
21
  exports.isPathInside = isPathInside;
22
22
  function stripTrailingSep(thePath) {
23
- if (thePath[thePath.length - 1] === path_1.default.sep) {
23
+ if (thePath[thePath.length - 1] === node_path_1.default.sep) {
24
24
  return thePath.slice(0, -1);
25
25
  }
26
26
  return thePath;
@@ -8,6 +8,7 @@ export declare const serveStatic: (path: string | null, options: {
8
8
  remotionRoot: string;
9
9
  concurrency: number;
10
10
  verbose: boolean;
11
+ indent: boolean;
11
12
  }) => Promise<{
12
13
  port: number;
13
14
  close: () => Promise<void>;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.serveStatic = void 0;
7
- const http_1 = __importDefault(require("http"));
7
+ const node_http_1 = __importDefault(require("node:http"));
8
8
  const get_port_1 = require("./get-port");
9
9
  const offthread_video_server_1 = require("./offthread-video-server");
10
10
  const serve_handler_1 = require("./serve-handler");
@@ -15,9 +15,10 @@ const serveStatic = async (path, options) => {
15
15
  downloadMap: options.downloadMap,
16
16
  concurrency: options.concurrency,
17
17
  verbose: options.verbose,
18
+ indent: options.indent,
18
19
  });
19
20
  const connections = {};
20
- const server = http_1.default.createServer((request, response) => {
21
+ const server = node_http_1.default.createServer((request, response) => {
21
22
  var _a;
22
23
  if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.startsWith('/proxy')) {
23
24
  return offthreadRequest(request, response);
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
2
3
  import type { RenderAssetInfo } from './assets/download-map';
3
4
  import type { AudioCodec } from './audio-codec';
@@ -35,6 +36,7 @@ export declare type StitcherOptions = {
35
36
  muted?: boolean;
36
37
  enforceAudioTrack?: boolean;
37
38
  ffmpegOverride?: FfmpegOverrideFn;
39
+ indent: boolean;
38
40
  };
39
41
  /**
40
42
  * @description Takes a series of images and audio information generated by renderFrames() and encodes it to a video.
@@ -27,8 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.stitchFramesToVideo = void 0;
30
- const fs_1 = __importStar(require("fs"));
31
- const path_1 = __importDefault(require("path"));
30
+ const node_fs_1 = __importStar(require("node:fs"));
31
+ const node_path_1 = __importDefault(require("node:path"));
32
32
  const remotion_1 = require("remotion");
33
33
  const calculate_asset_positions_1 = require("./assets/calculate-asset-positions");
34
34
  const convert_assets_to_file_urls_1 = require("./assets/convert-assets-to-file-urls");
@@ -37,7 +37,6 @@ const audio_codec_1 = require("./audio-codec");
37
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");
@@ -46,6 +45,7 @@ const find_closest_package_json_1 = require("./find-closest-package-json");
46
45
  const get_codec_name_1 = require("./get-codec-name");
47
46
  const get_extension_from_codec_1 = require("./get-extension-from-codec");
48
47
  const get_prores_profile_name_1 = require("./get-prores-profile-name");
48
+ const logger_1 = require("./logger");
49
49
  const make_cancel_signal_1 = require("./make-cancel-signal");
50
50
  const merge_audio_track_1 = require("./merge-audio-track");
51
51
  const parse_ffmpeg_progress_1 = require("./parse-ffmpeg-progress");
@@ -55,11 +55,11 @@ 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
57
  const validate_videobitrate_1 = require("./validate-videobitrate");
58
- const packageJsonPath = path_1.default.join(__dirname, '..', 'package.json');
59
- const packageJson = fs_1.default.existsSync(packageJsonPath)
60
- ? JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'))
58
+ const packageJsonPath = node_path_1.default.join(__dirname, '..', 'package.json');
59
+ const packageJson = node_fs_1.default.existsSync(packageJsonPath)
60
+ ? JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, 'utf-8'))
61
61
  : null;
62
- const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose, onProgress, downloadMap, remotionRoot, }) => {
62
+ const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose, onProgress, downloadMap, remotionRoot, indent, }) => {
63
63
  const fileUrlAssets = await (0, convert_assets_to_file_urls_1.convertAssetsToFileUrls)({
64
64
  assets,
65
65
  onDownload: onDownload !== null && onDownload !== void 0 ? onDownload : (() => () => undefined),
@@ -67,15 +67,13 @@ const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose,
67
67
  });
68
68
  (0, download_and_map_assets_to_file_1.markAllAssetsAsDownloaded)(downloadMap);
69
69
  const assetPositions = (0, calculate_asset_positions_1.calculateAssetPositions)(fileUrlAssets);
70
- if (verbose) {
71
- console.log('asset positions', assetPositions);
72
- }
70
+ logger_1.Log.verboseAdvanced({ indent, logLevel: verbose ? 'verbose' : 'info', tag: 'audio' }, 'asset positions', JSON.stringify(assetPositions));
73
71
  const preprocessProgress = new Array(assetPositions.length).fill(0);
74
72
  const updateProgress = () => {
75
73
  onProgress(preprocessProgress.reduce((a, b) => a + b, 0) / assetPositions.length);
76
74
  };
77
75
  const preprocessed = (await Promise.all(assetPositions.map(async (asset, index) => {
78
- const filterFile = path_1.default.join(downloadMap.audioMixing, `${index}.wav`);
76
+ const filterFile = node_path_1.default.join(downloadMap.audioMixing, `${index}.wav`);
79
77
  const result = await (0, preprocess_audio_track_1.preprocessAudioTrack)({
80
78
  outName: filterFile,
81
79
  asset,
@@ -87,7 +85,7 @@ const getAssetsData = async ({ assets, onDownload, fps, expectedFrames, verbose,
87
85
  updateProgress();
88
86
  return result;
89
87
  }))).filter(truthy_1.truthy);
90
- const outName = path_1.default.join(downloadMap.audioPreprocessing, `audio.wav`);
88
+ const outName = node_path_1.default.join(downloadMap.audioPreprocessing, `audio.wav`);
91
89
  await (0, merge_audio_track_1.mergeAudioTrack)({
92
90
  files: preprocessed,
93
91
  outName,
@@ -138,20 +136,42 @@ const spawnFfmpeg = async (options, remotionRoot) => {
138
136
  : (_d = options.audioCodec) !== null && _d !== void 0 ? _d : (0, audio_codec_1.getDefaultAudioCodec)({ codec, preferLossless: false });
139
137
  const tempFile = options.outputLocation
140
138
  ? null
141
- : path_1.default.join(options.assetsInfo.downloadMap.stitchFrames, `out.${(0, get_extension_from_codec_1.getFileExtensionFromCodec)(codec, resolvedAudioCodec)}`);
142
- if (options.verbose) {
143
- console.log('[verbose] ffmpeg', (0, get_executable_path_1.getExecutablePath)('ffmpeg'));
144
- console.log('[verbose] encoder', encoderName);
145
- console.log('[verbose] audioCodec', resolvedAudioCodec);
146
- console.log('[verbose] pixelFormat', pixelFormat);
147
- if (options.ffmpegOverride) {
148
- console.log('[verbose] ffmpegOverride', options.ffmpegOverride);
149
- }
150
- console.log('[verbose] codec', codec);
151
- console.log('[verbose] shouldRenderAudio', shouldRenderAudio);
152
- console.log('[verbose] shouldRenderVideo', shouldRenderVideo);
153
- console.log('[verbose] proResProfileName', proResProfileName);
154
- }
139
+ : node_path_1.default.join(options.assetsInfo.downloadMap.stitchFrames, `out.${(0, get_extension_from_codec_1.getFileExtensionFromCodec)(codec, resolvedAudioCodec)}`);
140
+ logger_1.Log.verboseAdvanced({
141
+ indent: options.indent,
142
+ logLevel: options.verbose ? 'verbose' : 'info',
143
+ tag: 'encoder',
144
+ }, 'encoder', encoderName);
145
+ logger_1.Log.verboseAdvanced({
146
+ indent: options.indent,
147
+ logLevel: options.verbose ? 'verbose' : 'info',
148
+ tag: 'encoder',
149
+ }, 'audioCodec', resolvedAudioCodec);
150
+ logger_1.Log.verboseAdvanced({
151
+ indent: options.indent,
152
+ logLevel: options.verbose ? 'verbose' : 'info',
153
+ tag: 'encoder',
154
+ }, 'pixelFormat', pixelFormat);
155
+ logger_1.Log.verboseAdvanced({
156
+ indent: options.indent,
157
+ logLevel: options.verbose ? 'verbose' : 'info',
158
+ tag: 'encoder',
159
+ }, 'codec', codec);
160
+ logger_1.Log.verboseAdvanced({
161
+ indent: options.indent,
162
+ logLevel: options.verbose ? 'verbose' : 'info',
163
+ tag: 'encoder',
164
+ }, 'shouldRenderAudio', shouldRenderAudio);
165
+ logger_1.Log.verboseAdvanced({
166
+ indent: options.indent,
167
+ logLevel: options.verbose ? 'verbose' : 'info',
168
+ tag: 'encoder',
169
+ }, 'shouldRenderVideo', shouldRenderVideo);
170
+ logger_1.Log.verboseAdvanced({
171
+ indent: options.indent,
172
+ logLevel: options.verbose ? 'verbose' : 'info',
173
+ tag: 'encoder',
174
+ }, 'proResProfileName', proResProfileName);
155
175
  (0, crf_1.validateQualitySettings)({
156
176
  crf: options.crf,
157
177
  codec,
@@ -174,6 +194,7 @@ const spawnFfmpeg = async (options, remotionRoot) => {
174
194
  onProgress: (prog) => updateProgress(prog, 0),
175
195
  downloadMap: options.assetsInfo.downloadMap,
176
196
  remotionRoot,
197
+ indent: options.indent,
177
198
  })
178
199
  : null;
179
200
  if (mediaSupport.audio && !mediaSupport.video) {
@@ -197,11 +218,11 @@ const spawnFfmpeg = async (options, remotionRoot) => {
197
218
  await ffmpegTask;
198
219
  (_j = options.onProgress) === null || _j === void 0 ? void 0 : _j.call(options, expectedFrames);
199
220
  if (audio) {
200
- (0, delete_directory_1.deleteDirectory)(path_1.default.dirname(audio));
221
+ (0, delete_directory_1.deleteDirectory)(node_path_1.default.dirname(audio));
201
222
  }
202
223
  const file = await new Promise((resolve, reject) => {
203
224
  if (tempFile) {
204
- fs_1.promises
225
+ node_fs_1.promises
205
226
  .readFile(tempFile)
206
227
  .then((f) => {
207
228
  return resolve(f);
@@ -219,10 +240,10 @@ const spawnFfmpeg = async (options, remotionRoot) => {
219
240
  };
220
241
  }
221
242
  const ffmpegArgs = [
222
- ['-r', String(options.fps)],
223
243
  ...(((_k = options.internalOptions) === null || _k === void 0 ? void 0 : _k.preEncodedFileLocation)
224
244
  ? [['-i', (_l = options.internalOptions) === null || _l === void 0 ? void 0 : _l.preEncodedFileLocation]]
225
245
  : [
246
+ ['-r', String(options.fps)],
226
247
  ['-f', 'image2'],
227
248
  ['-s', `${options.width}x${options.height}`],
228
249
  ['-start_number', String(options.assetsInfo.firstFrameIndex)],
@@ -268,18 +289,20 @@ const spawnFfmpeg = async (options, remotionRoot) => {
268
289
  options.force ? '-y' : null,
269
290
  (_q = options.outputLocation) !== null && _q !== void 0 ? _q : tempFile,
270
291
  ];
271
- if (options.verbose) {
272
- console.log('Generated FFMPEG command:');
273
- console.log(ffmpegArgs);
274
- }
275
292
  const ffmpegString = ffmpegArgs.flat(2).filter(Boolean);
276
293
  const finalFfmpegString = options.ffmpegOverride
277
294
  ? options.ffmpegOverride({ type: 'stitcher', args: ffmpegString })
278
295
  : ffmpegString;
279
- if (options.verbose && options.ffmpegOverride) {
280
- console.log('Generated final FFMPEG command:');
281
- console.log(finalFfmpegString);
282
- }
296
+ logger_1.Log.verboseAdvanced({
297
+ indent: options.indent,
298
+ logLevel: options.verbose ? 'verbose' : 'info',
299
+ tag: 'encoder',
300
+ }, 'Generated final FFMPEG command:');
301
+ logger_1.Log.verboseAdvanced({
302
+ indent: options.indent,
303
+ logLevel: options.verbose ? 'verbose' : 'info',
304
+ tag: 'encoder',
305
+ }, finalFfmpegString.join(' '));
283
306
  const task = (0, call_ffmpeg_1.callFf)('ffmpeg', finalFfmpegString, {
284
307
  cwd: options.dir,
285
308
  });
@@ -317,12 +340,12 @@ const spawnFfmpeg = async (options, remotionRoot) => {
317
340
  (0, delete_directory_1.deleteDirectory)(options.assetsInfo.downloadMap.stitchFrames);
318
341
  return null;
319
342
  }
320
- return fs_1.promises
343
+ return node_fs_1.promises
321
344
  .readFile(tempFile)
322
345
  .then((file) => {
323
346
  return Promise.all([
324
347
  file,
325
- (0, delete_directory_1.deleteDirectory)(path_1.default.dirname(tempFile)),
348
+ (0, delete_directory_1.deleteDirectory)(node_path_1.default.dirname(tempFile)),
326
349
  (0, delete_directory_1.deleteDirectory)(options.assetsInfo.downloadMap.stitchFrames),
327
350
  ]);
328
351
  })
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import type { TAsset } from 'remotion';
2
3
  import type { DownloadMap } from './assets/download-map';
3
4
  import type { Page } from './browser/BrowserPage';
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.takeFrameAndCompose = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  const compose_1 = require("./compositor/compose");
10
10
  const provide_screenshot_1 = require("./provide-screenshot");
11
11
  const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
@@ -39,8 +39,8 @@ const takeFrameAndCompose = async ({ freePage, imageFormat, jpegQuality, frame,
39
39
  const needsComposing = clipRegion === null
40
40
  ? null
41
41
  : {
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}`),
42
+ tmpFile: node_path_1.default.join(downloadMap.compositingDir, `${frame}.${imageFormat}`),
43
+ finalOutFile: output !== null && output !== void 0 ? output : node_path_1.default.join(downloadMap.compositingDir, `${frame}-final.${imageFormat}`),
44
44
  clipRegion: clipRegion,
45
45
  };
46
46
  if (clipRegion !== 'hide') {
@@ -92,8 +92,8 @@ const takeFrameAndCompose = async ({ freePage, imageFormat, jpegQuality, frame,
92
92
  imageFormat: imageFormat === 'jpeg' ? 'Jpeg' : 'Png',
93
93
  });
94
94
  if (wantsBuffer) {
95
- const buffer = await fs_1.default.promises.readFile(needsComposing.finalOutFile);
96
- await fs_1.default.promises.unlink(needsComposing.finalOutFile);
95
+ const buffer = await node_fs_1.default.promises.readFile(needsComposing.finalOutFile);
96
+ await node_fs_1.default.promises.unlink(needsComposing.finalOutFile);
97
97
  return { buffer, collectedAssets };
98
98
  }
99
99
  }
package/dist/tmp-dir.js CHANGED
@@ -27,9 +27,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.tmpDir = void 0;
30
- const fs_1 = __importStar(require("fs"));
31
- const os_1 = __importDefault(require("os"));
32
- const path_1 = __importDefault(require("path"));
30
+ const node_fs_1 = __importStar(require("node:fs"));
31
+ const node_os_1 = __importDefault(require("node:os"));
32
+ const node_path_1 = __importDefault(require("node:path"));
33
33
  const alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789';
34
34
  const randomHash = () => {
35
35
  return new Array(10)
@@ -40,14 +40,14 @@ const randomHash = () => {
40
40
  .join('');
41
41
  };
42
42
  const tmpDir = (str) => {
43
- const newDir = path_1.default.join(os_1.default.tmpdir(), str + randomHash());
44
- if (fs_1.default.existsSync(newDir)) {
45
- fs_1.default.rmSync(newDir, {
43
+ const newDir = node_path_1.default.join(node_os_1.default.tmpdir(), str + randomHash());
44
+ if (node_fs_1.default.existsSync(newDir)) {
45
+ node_fs_1.default.rmSync(newDir, {
46
46
  recursive: true,
47
47
  force: true,
48
48
  });
49
49
  }
50
- (0, fs_1.mkdirSync)(newDir);
50
+ (0, node_fs_1.mkdirSync)(newDir);
51
51
  return newDir;
52
52
  };
53
53
  exports.tmpDir = tmpDir;
@@ -1,5 +1,5 @@
1
1
  import type { AudioCodec } from './audio-codec';
2
- export declare const validateOutputFilename: <T extends "aac" | "mp3" | "h264" | "h265" | "vp8" | "vp9" | "wav" | "prores" | "h264-mkv" | "gif">({ codec, audioCodec, extension, preferLossless, }: {
2
+ export declare const validateOutputFilename: <T extends "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">({ codec, audioCodec, extension, preferLossless, }: {
3
3
  codec: T;
4
4
  audioCodec: AudioCodec | null;
5
5
  extension: string;
@@ -1,5 +1,5 @@
1
- import {execSync} from 'child_process';
2
- import {existsSync, mkdirSync, unlinkSync} from 'fs';
1
+ import {execSync} from 'node:child_process';
2
+ import {existsSync, mkdirSync, unlinkSync} from 'node:fs';
3
3
  import {toolchains} from './toolchains.mjs';
4
4
 
5
5
  const unpatched = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/renderer",
3
- "version": "4.0.0-alpha5",
3
+ "version": "4.0.0-alpha7",
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-alpha5",
19
+ "remotion": "4.0.0-alpha7",
20
20
  "source-map": "^0.8.0-beta.0",
21
21
  "ws": "8.7.0"
22
22
  },
@@ -42,13 +42,13 @@
42
42
  "zod": "^3.21.4"
43
43
  },
44
44
  "optionalDependencies": {
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"
45
+ "@remotion/compositor-darwin-arm64": "4.0.0-alpha7",
46
+ "@remotion/compositor-darwin-x64": "4.0.0-alpha7",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.0.0-alpha7",
48
+ "@remotion/compositor-linux-arm64-musl": "4.0.0-alpha7",
49
+ "@remotion/compositor-linux-x64-gnu": "4.0.0-alpha7",
50
+ "@remotion/compositor-linux-x64-musl": "4.0.0-alpha7",
51
+ "@remotion/compositor-win32-x64-msvc": "4.0.0-alpha7"
52
52
  },
53
53
  "keywords": [
54
54
  "remotion",
@@ -6,7 +6,8 @@
6
6
  /* eslint-disable no-dupe-class-members */
7
7
  /// <reference types="node" />
8
8
 
9
- import {EventEmitter} from 'events';
9
+ import type {Server as HTTPSServer} from 'https';
10
+ import {EventEmitter} from 'node:events';
10
11
  import type {
11
12
  Agent,
12
13
  ClientRequest,
@@ -14,12 +15,11 @@ import type {
14
15
  IncomingMessage,
15
16
  OutgoingHttpHeaders,
16
17
  Server as HTTPServer,
17
- } from 'http';
18
- import type {Server as HTTPSServer} from 'https';
18
+ } from 'node:http';
19
+ import type {URL} from 'node:url';
20
+ import type {ZlibOptions} from 'node:zlib';
19
21
  import type {Duplex, DuplexOptions} from 'stream';
20
22
  import type {SecureContextOptions} from 'tls';
21
- import type {URL} from 'url';
22
- import type {ZlibOptions} from 'zlib';
23
23
  declare class WebSocket extends EventEmitter {
24
24
  /** The connection is not yet open. */
25
25
  static readonly CONNECTING: 0;
@@ -1,9 +0,0 @@
1
- import type { FfmpegExecutable } from '../ffmpeg-executable';
2
- import type { DownloadMap, VideoDurationResult } from './download-map';
3
- export declare const parseVideoStreamDuration: (stdout: string) => VideoDurationResult;
4
- export declare function getVideoStreamDurationwithoutCache({ src, ffprobeExecutable, remotionRoot, }: {
5
- src: string;
6
- ffprobeExecutable: FfmpegExecutable;
7
- remotionRoot: string;
8
- }): Promise<VideoDurationResult>;
9
- export declare const getVideoStreamDuration: (downloadMap: DownloadMap, src: string, ffprobeExecutable: FfmpegExecutable, remotionRoot: string) => Promise<VideoDurationResult>;
@@ -1,71 +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.getVideoStreamDuration = exports.getVideoStreamDurationwithoutCache = exports.parseVideoStreamDuration = void 0;
7
- const execa_1 = __importDefault(require("execa"));
8
- const ffmpeg_flags_1 = require("../ffmpeg-flags");
9
- const p_limit_1 = require("../p-limit");
10
- const limit = (0, p_limit_1.pLimit)(1);
11
- const parseAlternativeDuration = (stdout) => {
12
- const webmDuration = stdout.match(/TAG:DURATION=([0-9.]+):([0-9.]+):([0-9.]+)/);
13
- if (!webmDuration) {
14
- return null;
15
- }
16
- const [, hours, minutes, seconds] = webmDuration;
17
- const hoursAsNumber = Number(hours);
18
- if (Number.isNaN(hoursAsNumber)) {
19
- return null;
20
- }
21
- const minutesAsNumber = Number(minutes);
22
- if (Number.isNaN(minutesAsNumber)) {
23
- return null;
24
- }
25
- const secondsAsNumber = Number(seconds);
26
- if (Number.isNaN(secondsAsNumber)) {
27
- return null;
28
- }
29
- return secondsAsNumber + minutesAsNumber * 60 + hoursAsNumber * 3600;
30
- };
31
- const parseVideoStreamDuration = (stdout) => {
32
- const duration = stdout.match(/duration=([0-9.]+)/);
33
- const alternativeDuration = parseAlternativeDuration(stdout);
34
- const fps = stdout.match(/r_frame_rate=([0-9.]+)\/([0-9.]+)/);
35
- const result = {
36
- duration: duration ? parseFloat(duration[1]) : alternativeDuration,
37
- fps: fps ? parseInt(fps[1], 10) / parseInt(fps[2], 10) : null,
38
- };
39
- return result;
40
- };
41
- exports.parseVideoStreamDuration = parseVideoStreamDuration;
42
- async function getVideoStreamDurationwithoutCache({ src, ffprobeExecutable, remotionRoot, }) {
43
- const args = [
44
- ['-v', 'error'],
45
- ['-select_streams', 'v:0'],
46
- ['-show_entries', 'stream'],
47
- [src],
48
- ]
49
- .reduce((acc, val) => acc.concat(val), [])
50
- .filter(Boolean);
51
- const task = await (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)(ffprobeExecutable, remotionRoot, 'ffprobe'), args);
52
- const result = (0, exports.parseVideoStreamDuration)(task.stdout);
53
- return result;
54
- }
55
- exports.getVideoStreamDurationwithoutCache = getVideoStreamDurationwithoutCache;
56
- async function getVideoStreamDurationUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot) {
57
- if (downloadMap.videoDurationResultCache[src]) {
58
- return downloadMap.videoDurationResultCache[src];
59
- }
60
- const result = await getVideoStreamDurationwithoutCache({
61
- src,
62
- ffprobeExecutable,
63
- remotionRoot,
64
- });
65
- downloadMap.videoDurationResultCache[src] = result;
66
- return result;
67
- }
68
- const getVideoStreamDuration = (downloadMap, src, ffprobeExecutable, remotionRoot) => {
69
- return limit(() => getVideoStreamDurationUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot));
70
- };
71
- exports.getVideoStreamDuration = getVideoStreamDuration;
@@ -1,9 +0,0 @@
1
- export declare const calculateDisplayVideoSize: ({ darX, darY, x, y, }: {
2
- x: number;
3
- y: number;
4
- darX: number;
5
- darY: number;
6
- }) => {
7
- width: number;
8
- height: number;
9
- };
@@ -1,19 +0,0 @@
1
- "use strict";
2
- // https://superuser.com/questions/907933/correct-aspect-ratio-without-re-encoding-video-file
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.calculateDisplayVideoSize = void 0;
5
- const calculateDisplayVideoSize = ({ darX, darY, x, y, }) => {
6
- // We know two equations:
7
- // newWidth / newHeight = darX / darY
8
- // and:
9
- // x * y = (newWidth * newHeight)
10
- // I solved it then on pen and paper and simplified the formula:
11
- const dimensions = x * y;
12
- const newWidth = Math.sqrt(dimensions * (darX / darY));
13
- const newHeight = dimensions / newWidth;
14
- return {
15
- height: Math.round(newHeight),
16
- width: Math.round(newWidth),
17
- };
18
- };
19
- exports.calculateDisplayVideoSize = calculateDisplayVideoSize;
@@ -1 +0,0 @@
1
- export declare const determineResizeParams: (needsResize: [number, number] | null) => string[];
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.determineResizeParams = void 0;
4
- const determineResizeParams = (needsResize) => {
5
- if (needsResize === null) {
6
- return [];
7
- }
8
- return ['-s', `${needsResize[0]}x${needsResize[1]}`];
9
- };
10
- exports.determineResizeParams = determineResizeParams;