@remotion/renderer 3.2.8 → 3.2.11

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.
@@ -11,10 +11,11 @@ export declare const downloadAsset: ({ src, onDownload, downloadMap, }: {
11
11
  downloadMap: DownloadMap;
12
12
  }) => Promise<string>;
13
13
  export declare const markAllAssetsAsDownloaded: (downloadMap: DownloadMap) => void;
14
- export declare const getSanitizedFilenameForAssetUrl: ({ src, downloadDir, contentDisposition, }: {
14
+ export declare const getSanitizedFilenameForAssetUrl: ({ src, downloadDir, contentDisposition, contentType, }: {
15
15
  src: string;
16
16
  downloadDir: string;
17
17
  contentDisposition: string | null;
18
+ contentType: string | null;
18
19
  }) => string;
19
20
  export declare const downloadAndMapAssetsToFileUrl: ({ asset, onDownload, downloadMap, }: {
20
21
  asset: TAsset;
@@ -1,14 +1,38 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.downloadAndMapAssetsToFileUrl = exports.getSanitizedFilenameForAssetUrl = exports.markAllAssetsAsDownloaded = exports.downloadAsset = void 0;
7
30
  const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
31
+ const path_1 = __importStar(require("path"));
9
32
  const remotion_1 = require("remotion");
10
33
  const compress_assets_1 = require("../compress-assets");
11
34
  const ensure_output_directory_1 = require("../ensure-output-directory");
35
+ const mime_types_1 = require("../mime-types");
12
36
  const download_file_1 = require("./download-file");
13
37
  const sanitize_filepath_1 = require("./sanitize-filepath");
14
38
  const waitForAssetToBeDownloaded = ({ src, downloadDir, downloadMap, }) => {
@@ -121,6 +145,7 @@ const downloadAsset = async ({ src, onDownload, downloadMap, }) => {
121
145
  contentDisposition: null,
122
146
  downloadDir,
123
147
  src,
148
+ contentType: null,
124
149
  });
125
150
  (0, ensure_output_directory_1.ensureOutputDirectory)(output);
126
151
  const [assetDetails, assetData] = src.substring('data:'.length).split(',');
@@ -146,7 +171,12 @@ const downloadAsset = async ({ src, onDownload, downloadMap, }) => {
146
171
  onProgress: (progress) => {
147
172
  onProgress === null || onProgress === void 0 ? void 0 : onProgress(progress);
148
173
  },
149
- to: (contentDisposition) => (0, exports.getSanitizedFilenameForAssetUrl)({ contentDisposition, downloadDir, src }),
174
+ to: (contentDisposition, contentType) => (0, exports.getSanitizedFilenameForAssetUrl)({
175
+ contentDisposition,
176
+ downloadDir,
177
+ src,
178
+ contentType,
179
+ }),
150
180
  });
151
181
  notifyAssetIsDownloaded({ src, downloadMap, downloadDir, to });
152
182
  return to;
@@ -161,7 +191,7 @@ const markAllAssetsAsDownloaded = (downloadMap) => {
161
191
  });
162
192
  };
163
193
  exports.markAllAssetsAsDownloaded = markAllAssetsAsDownloaded;
164
- const getFilename = ({ contentDisposition, src, }) => {
194
+ const getFilename = ({ contentDisposition, src, contentType, }) => {
165
195
  const filenameProbe = 'filename=';
166
196
  if (contentDisposition === null || contentDisposition === void 0 ? void 0 : contentDisposition.includes(filenameProbe)) {
167
197
  const start = contentDisposition.indexOf(filenameProbe);
@@ -176,13 +206,26 @@ const getFilename = ({ contentDisposition, src, }) => {
176
206
  };
177
207
  }
178
208
  const { pathname, search } = new URL(src);
209
+ const ext = (0, path_1.extname)(pathname);
210
+ // Has no file extension, check if we can derive it from contentType
211
+ if (!ext && contentType) {
212
+ const matchedExt = (0, mime_types_1.getExt)(contentType);
213
+ return {
214
+ pathname: `${pathname}.${matchedExt}`,
215
+ search,
216
+ };
217
+ }
179
218
  return { pathname, search };
180
219
  };
181
- const getSanitizedFilenameForAssetUrl = ({ src, downloadDir, contentDisposition, }) => {
220
+ const getSanitizedFilenameForAssetUrl = ({ src, downloadDir, contentDisposition, contentType, }) => {
182
221
  if ((0, compress_assets_1.isAssetCompressed)(src)) {
183
222
  return src;
184
223
  }
185
- const { pathname, search } = getFilename({ contentDisposition, src });
224
+ const { pathname, search } = getFilename({
225
+ contentDisposition,
226
+ contentType,
227
+ src,
228
+ });
186
229
  const split = pathname.split('.');
187
230
  const fileExtension = split.length > 1 && split[split.length - 1]
188
231
  ? `.${split[split.length - 1]}`
@@ -1,6 +1,6 @@
1
1
  export declare const downloadFile: ({ onProgress, url, to: toFn, }: {
2
2
  url: string;
3
- to: (contentDisposition: string | null) => string;
3
+ to: (contentDisposition: string | null, contentType: string | null) => string;
4
4
  onProgress: ((progress: {
5
5
  percent: number | null;
6
6
  downloaded: number;
@@ -8,9 +8,10 @@ const downloadFile = ({ onProgress, url, to: toFn, }) => {
8
8
  return new Promise((resolve, reject) => {
9
9
  (0, read_file_1.readFile)(url)
10
10
  .then((res) => {
11
- var _a;
11
+ var _a, _b;
12
12
  const contentDisposition = (_a = res.headers['content-disposition']) !== null && _a !== void 0 ? _a : null;
13
- const to = toFn(contentDisposition);
13
+ const contentType = (_b = res.headers['content-type']) !== null && _b !== void 0 ? _b : null;
14
+ const to = toFn(contentDisposition, contentType);
14
15
  (0, ensure_output_directory_1.ensureOutputDirectory)(to);
15
16
  const sizeHeader = res.headers['content-length'];
16
17
  const totalSize = typeof sizeHeader === 'undefined' ? null : Number(sizeHeader);
@@ -1 +1 @@
1
- export declare const guessExtensionForVideo: (src: string) => Promise<"mp3" | "wav" | "webm" | "mp4">;
1
+ export declare const guessExtensionForVideo: (src: string) => Promise<"mp3" | "webm" | "wav" | "mp4">;
@@ -22,6 +22,6 @@ const guessExtensionForVideo = async (src) => {
22
22
  if (stderr.includes('Video: h264')) {
23
23
  return 'mp4';
24
24
  }
25
- throw new Error(`A media file ${src} which has no file extension and whose format could not be guessed. Is this a valid media file?`);
25
+ throw new Error(`The media file "${src}" has no file extension and the format could not be guessed. Tips: a) Ensure this is a valid video or audio file b) Add a file extension to the URL like ".mp4" c) Set a "Content-Type" or "Content-Disposition" header if possible.`);
26
26
  };
27
27
  exports.guessExtensionForVideo = guessExtensionForVideo;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import execa from 'execa';
3
2
  import { SymbolicateableError } from './error-handling/symbolicateable-error';
4
3
  import { mimeContentType, mimeLookup } from './mime-types';
@@ -61,14 +60,14 @@ export declare const RenderInternals: {
61
60
  width: number;
62
61
  height: number;
63
62
  scale: number;
64
- codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
63
+ codec: "mp3" | "wav" | "h264" | "h265" | "vp8" | "vp9" | "aac" | "prores" | "h264-mkv" | "gif";
65
64
  }) => void;
66
65
  normalizeServeUrl: (unnormalized: string) => string;
67
66
  spawnFfmpeg: (options: import("./stitch-frames-to-video").StitcherOptions) => Promise<{
68
67
  task: Promise<Buffer | null>;
69
68
  getLogs: () => string;
70
69
  }>;
71
- getFileExtensionFromCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif", type: "chunk" | "final") => "mp3" | "aac" | "wav" | "gif" | "webm" | "mp4" | "mov" | "mkv";
70
+ getFileExtensionFromCodec: (codec: "mp3" | "wav" | "h264" | "h265" | "vp8" | "vp9" | "aac" | "prores" | "h264-mkv" | "gif", type: "chunk" | "final") => "mp3" | "webm" | "wav" | "mp4" | "aac" | "gif" | "mkv" | "mov";
72
71
  tmpDir: (str: string) => string;
73
72
  deleteDirectory: (directory: string) => Promise<void>;
74
73
  isServeUrl: (potentialUrl: string) => boolean;
@@ -77,7 +76,7 @@ export declare const RenderInternals: {
77
76
  validatePuppeteerTimeout: (timeoutInMilliseconds: unknown) => void;
78
77
  downloadFile: ({ onProgress, url, to: toFn, }: {
79
78
  url: string;
80
- to: (contentDisposition: string | null) => string;
79
+ to: (contentDisposition: string | null, contentType: string | null) => string;
81
80
  onProgress: ((progress: {
82
81
  percent: number | null;
83
82
  downloaded: number;
@@ -116,17 +115,17 @@ export declare const RenderInternals: {
116
115
  };
117
116
  registerErrorSymbolicationLock: () => number;
118
117
  unlockErrorSymbolicationLock: (id: number) => void;
119
- canUseParallelEncoding: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => boolean;
118
+ canUseParallelEncoding: (codec: "mp3" | "wav" | "h264" | "h265" | "vp8" | "vp9" | "aac" | "prores" | "h264-mkv" | "gif") => boolean;
120
119
  mimeContentType: typeof mimeContentType;
121
120
  mimeLookup: typeof mimeLookup;
122
121
  validateConcurrency: (value: unknown, setting: string) => void;
123
122
  validPixelFormats: readonly ["yuv420p", "yuva420p", "yuv422p", "yuv444p", "yuv420p10le", "yuv422p10le", "yuv444p10le", "yuva444p10le"];
124
123
  DEFAULT_BROWSER: import("./browser").Browser;
125
124
  validateFrameRange: (frameRange: import("./frame-range").FrameRange | null) => void;
126
- DEFAULT_OPENGL_RENDERER: "angle" | "swangle" | "egl" | "swiftshader" | null;
127
- validateOpenGlRenderer: (option: "angle" | "swangle" | "egl" | "swiftshader" | null) => "angle" | "swangle" | "egl" | "swiftshader" | null;
128
- getDefaultCrfForCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => number;
129
- validateSelectedCrfAndCodecCombination: (crf: unknown, codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => void;
125
+ DEFAULT_OPENGL_RENDERER: "swangle" | "angle" | "egl" | "swiftshader" | null;
126
+ validateOpenGlRenderer: (option: "swangle" | "angle" | "egl" | "swiftshader" | null) => "swangle" | "angle" | "egl" | "swiftshader" | null;
127
+ getDefaultCrfForCodec: (codec: "mp3" | "wav" | "h264" | "h265" | "vp8" | "vp9" | "aac" | "prores" | "h264-mkv" | "gif") => number;
128
+ validateSelectedCrfAndCodecCombination: (crf: unknown, codec: "mp3" | "wav" | "h264" | "h265" | "vp8" | "vp9" | "aac" | "prores" | "h264-mkv" | "gif") => void;
130
129
  validImageFormats: readonly ["png", "jpeg", "none"];
131
130
  validCodecs: readonly ["h264", "h265", "vp8", "vp9", "mp3", "aac", "wav", "prores", "h264-mkv", "gif"];
132
131
  DEFAULT_OVERWRITE: boolean;
@@ -134,14 +133,14 @@ export declare const RenderInternals: {
134
133
  validateQuality: (q: number | undefined) => void;
135
134
  validateFrame: (frame: number, durationInFrames: number) => void;
136
135
  DEFAULT_TIMEOUT: number;
137
- getValidCrfRanges: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => [number, number];
138
- validateSelectedPixelFormatAndCodecCombination: (pixelFormat: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le", codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => void;
139
- validateSelectedCodecAndProResCombination: (actualCodec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif", actualProResProfile: "proxy" | "4444-xq" | "4444" | "hq" | "standard" | "light" | undefined) => void;
140
- validateSelectedPixelFormatAndImageFormatCombination: (pixelFormat: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le", imageFormat: "jpeg" | "png" | "none") => "none" | "valid";
141
- DEFAULT_CODEC: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
142
- isAudioCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif" | undefined) => boolean;
136
+ getValidCrfRanges: (codec: "mp3" | "wav" | "h264" | "h265" | "vp8" | "vp9" | "aac" | "prores" | "h264-mkv" | "gif") => [number, number];
137
+ validateSelectedPixelFormatAndCodecCombination: (pixelFormat: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le", codec: "mp3" | "wav" | "h264" | "h265" | "vp8" | "vp9" | "aac" | "prores" | "h264-mkv" | "gif") => void;
138
+ validateSelectedCodecAndProResCombination: (actualCodec: "mp3" | "wav" | "h264" | "h265" | "vp8" | "vp9" | "aac" | "prores" | "h264-mkv" | "gif", actualProResProfile: "4444-xq" | "4444" | "hq" | "standard" | "light" | "proxy" | undefined) => void;
139
+ validateSelectedPixelFormatAndImageFormatCombination: (pixelFormat: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le", imageFormat: "png" | "jpeg" | "none") => "none" | "valid";
140
+ DEFAULT_CODEC: "mp3" | "wav" | "h264" | "h265" | "vp8" | "vp9" | "aac" | "prores" | "h264-mkv" | "gif";
141
+ isAudioCodec: (codec: "mp3" | "wav" | "h264" | "h265" | "vp8" | "vp9" | "aac" | "prores" | "h264-mkv" | "gif" | undefined) => boolean;
143
142
  logLevels: readonly ["verbose", "info", "warn", "error"];
144
- isEqualOrBelowLogLevel: (currentLevel: "error" | "verbose" | "info" | "warn", level: "error" | "verbose" | "info" | "warn") => boolean;
143
+ isEqualOrBelowLogLevel: (currentLevel: "verbose" | "info" | "warn" | "error", level: "verbose" | "info" | "warn" | "error") => boolean;
145
144
  isValidLogLevel: (level: string) => boolean;
146
145
  validateEveryNthFrame: (everyNthFrame: unknown) => void;
147
146
  perf: typeof perf;
@@ -1,2 +1,3 @@
1
+ export declare const getExt: (contentType: string) => string | null;
1
2
  export declare function mimeLookup(path: string): string | false;
2
3
  export declare function mimeContentType(str: string): false | string;
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mimeContentType = exports.mimeLookup = void 0;
3
+ exports.mimeContentType = exports.mimeLookup = exports.getExt = void 0;
4
4
  const path_1 = require("path");
5
5
  const mime_db_1 = require("./mime-db");
6
6
  const extensions = {};
7
7
  const types = {};
8
8
  // Populate the extensions/types maps
9
9
  populateMaps(extensions, {});
10
+ const getExt = (contentType) => {
11
+ var _a, _b, _c;
12
+ return (_c = (_b = (_a = mime_db_1.mimeDb[contentType.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : null;
13
+ };
14
+ exports.getExt = getExt;
10
15
  function mimeLookup(path) {
11
16
  if (!path || typeof path !== 'string') {
12
17
  return false;
@@ -91,13 +91,26 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, qual
91
91
  videoEnabled: imageFormat !== 'none',
92
92
  });
93
93
  await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
94
- pageFunction: (id) => {
94
+ // eslint-disable-next-line max-params
95
+ pageFunction: (id, defaultProps, durationInFrames, fps, height, width) => {
95
96
  window.setBundleMode({
96
97
  type: 'composition',
97
98
  compositionName: id,
99
+ compositionDefaultProps: defaultProps,
100
+ compositionDurationInFrames: durationInFrames,
101
+ compositionFps: fps,
102
+ compositionHeight: height,
103
+ compositionWidth: width,
98
104
  });
99
105
  },
100
- args: [composition.id],
106
+ args: [
107
+ composition.id,
108
+ composition.defaultProps,
109
+ composition.durationInFrames,
110
+ composition.fps,
111
+ composition.height,
112
+ composition.width,
113
+ ],
101
114
  frame: null,
102
115
  page,
103
116
  });
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { SmallTCompMetadata } from 'remotion';
3
2
  import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
4
3
  import type { DownloadMap } from './assets/download-map';
@@ -121,13 +121,26 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
121
121
  videoEnabled: true,
122
122
  });
123
123
  await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
124
- pageFunction: (id) => {
124
+ // eslint-disable-next-line max-params
125
+ pageFunction: (id, defaultProps, durationInFrames, fps, height, width) => {
125
126
  window.setBundleMode({
126
127
  type: 'composition',
127
128
  compositionName: id,
129
+ compositionDefaultProps: defaultProps,
130
+ compositionDurationInFrames: durationInFrames,
131
+ compositionFps: fps,
132
+ compositionHeight: height,
133
+ compositionWidth: width,
128
134
  });
129
135
  },
130
- args: [composition.id],
136
+ args: [
137
+ composition.id,
138
+ composition.defaultProps,
139
+ composition.durationInFrames,
140
+ composition.fps,
141
+ composition.height,
142
+ composition.width,
143
+ ],
131
144
  frame: null,
132
145
  page,
133
146
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/renderer",
3
- "version": "3.2.8",
3
+ "version": "3.2.11",
4
4
  "description": "Renderer for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "execa": "5.1.1",
24
24
  "extract-zip": "2.0.1",
25
- "remotion": "3.2.8",
25
+ "remotion": "3.2.11",
26
26
  "source-map": "^0.8.0-beta.0",
27
27
  "ws": "8.7.0"
28
28
  },
@@ -57,5 +57,5 @@
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  },
60
- "gitHead": "7ccde3ec3f4adecd5fb7188d9d2933435bba5743"
60
+ "gitHead": "43d44e718e41200aea544719e9963482f9a65120"
61
61
  }