@remotion/renderer 4.0.0-preload.13 → 4.0.0-publish.3
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.
- package/dist/abort.d.ts +7 -0
- package/dist/abort.js +20 -0
- package/dist/assets/calculate-asset-positions.d.ts +2 -2
- package/dist/assets/cleanup-assets.d.ts +2 -0
- package/dist/assets/cleanup-assets.js +2 -0
- package/dist/assets/convert-assets-to-file-urls.d.ts +2 -2
- package/dist/assets/download-and-map-assets-to-file.d.ts +22 -3
- package/dist/assets/download-and-map-assets-to-file.js +84 -31
- package/dist/assets/download-file.d.ts +10 -5
- package/dist/assets/download-file.js +18 -5
- package/dist/assets/ffmpeg-volume-expression.d.ts +3 -3
- package/dist/assets/ffmpeg-volume-expression.js +16 -14
- package/dist/assets/flatten-volume-array.d.ts +1 -1
- package/dist/assets/get-audio-channels.d.ts +5 -2
- package/dist/assets/get-audio-channels.js +15 -4
- package/dist/assets/read-file.js +4 -1
- package/dist/assets/types.d.ts +1 -1
- package/dist/browser/Browser.d.ts +60 -0
- package/dist/browser/Browser.js +218 -0
- package/dist/browser/BrowserConnector.d.ts +19 -0
- package/dist/browser/BrowserConnector.js +17 -0
- package/dist/browser/BrowserFetcher.d.ts +89 -0
- package/dist/browser/BrowserFetcher.js +510 -0
- package/dist/browser/BrowserRunner.d.ts +39 -0
- package/dist/browser/BrowserRunner.js +308 -0
- package/dist/browser/Connection.d.ts +42 -0
- package/dist/browser/Connection.js +242 -0
- package/dist/browser/ConnectionTransport.d.ts +21 -0
- package/dist/browser/ConnectionTransport.js +17 -0
- package/dist/browser/ConsoleMessage.d.ts +31 -0
- package/dist/browser/ConsoleMessage.js +48 -0
- package/dist/browser/DOMWorld.d.ts +52 -0
- package/dist/browser/DOMWorld.js +272 -0
- package/dist/browser/EmulationManager.d.ts +7 -0
- package/dist/browser/EmulationManager.js +40 -0
- package/dist/browser/Errors.d.ts +25 -0
- package/dist/browser/Errors.js +35 -0
- package/dist/browser/EvalTypes.d.ts +27 -0
- package/dist/browser/EvalTypes.js +17 -0
- package/dist/browser/EventEmitter.d.ts +23 -0
- package/dist/browser/EventEmitter.js +53 -0
- package/dist/browser/ExecutionContext.d.ts +34 -0
- package/dist/browser/ExecutionContext.js +174 -0
- package/dist/browser/FrameManager.d.ts +93 -0
- package/dist/browser/FrameManager.js +496 -0
- package/dist/browser/HTTPRequest.d.ts +28 -0
- package/dist/browser/HTTPRequest.js +37 -0
- package/dist/browser/HTTPResponse.d.ts +21 -0
- package/dist/browser/HTTPResponse.js +41 -0
- package/dist/browser/JSHandle.d.ts +35 -0
- package/dist/browser/JSHandle.js +90 -0
- package/dist/browser/LaunchOptions.d.ts +38 -0
- package/dist/browser/LaunchOptions.js +17 -0
- package/dist/browser/Launcher.d.ts +9 -0
- package/dist/browser/Launcher.js +504 -0
- package/dist/browser/LifecycleWatcher.d.ts +29 -0
- package/dist/browser/LifecycleWatcher.js +180 -0
- package/dist/browser/NetworkEventManager.d.ts +33 -0
- package/dist/browser/NetworkEventManager.js +81 -0
- package/dist/browser/NetworkManager.d.ts +34 -0
- package/dist/browser/NetworkManager.js +235 -0
- package/dist/browser/NodeWebSocketTransport.d.ts +17 -0
- package/dist/browser/NodeWebSocketTransport.js +90 -0
- package/dist/browser/Page.d.ts +74 -0
- package/dist/browser/Page.js +283 -0
- package/dist/browser/Product.d.ts +16 -0
- package/dist/browser/Product.js +17 -0
- package/dist/browser/PuppeteerNode.d.ts +40 -0
- package/dist/browser/PuppeteerNode.js +81 -0
- package/dist/browser/PuppeteerViewport.d.ts +5 -0
- package/dist/browser/PuppeteerViewport.js +2 -0
- package/dist/browser/ScreenshotOptions.d.ts +14 -0
- package/dist/browser/ScreenshotOptions.js +2 -0
- package/dist/browser/Target.d.ts +61 -0
- package/dist/browser/Target.js +146 -0
- package/dist/browser/TaskQueue.d.ts +20 -0
- package/dist/browser/TaskQueue.js +47 -0
- package/dist/browser/TimeoutSettings.d.ts +23 -0
- package/dist/browser/TimeoutSettings.js +62 -0
- package/dist/browser/assert.d.ts +1 -0
- package/dist/browser/assert.js +9 -0
- package/dist/browser/compat.d.ts +2 -0
- package/dist/browser/compat.js +17 -0
- package/dist/browser/create-browser-fetcher.d.ts +17 -0
- package/dist/browser/create-browser-fetcher.js +119 -0
- package/dist/browser/devtools-commands.d.ts +270 -0
- package/dist/browser/devtools-commands.js +2 -0
- package/dist/browser/devtools-types.d.ts +1142 -0
- package/dist/browser/devtools-types.js +2 -0
- package/dist/browser/environment.d.ts +16 -0
- package/dist/browser/environment.js +19 -0
- package/dist/browser/get-download-destination.d.ts +1 -0
- package/dist/browser/get-download-destination.js +38 -0
- package/dist/browser/mitt/index.d.ts +22 -0
- package/dist/browser/mitt/index.js +49 -0
- package/dist/browser/node.d.ts +2 -0
- package/dist/browser/node.js +9 -0
- package/dist/browser/revisions.d.ts +21 -0
- package/dist/browser/revisions.js +22 -0
- package/dist/browser/util.d.ts +47 -0
- package/dist/browser/util.js +169 -0
- package/dist/browser/ws.d.ts +287 -0
- package/dist/browser/ws.js +21 -0
- package/dist/browser-log.d.ts +1 -1
- package/dist/calculate-ffmpeg-filters.d.ts +1 -1
- package/dist/calculate-ffmpeg-filters.js +2 -2
- package/dist/calculate-sar-dar-pixels.d.ts +9 -0
- package/dist/calculate-sar-dar-pixels.js +19 -0
- package/dist/can-use-parallel-encoding.d.ts +1 -1
- package/dist/cancel.d.ts +7 -0
- package/dist/cancel.js +25 -0
- package/dist/combine-videos.d.ts +3 -2
- package/dist/combine-videos.js +8 -1
- package/dist/convert-to-pcm.d.ts +1 -1
- package/dist/create-ffmpeg-complex-filter.d.ts +4 -1
- package/dist/create-silent-audio.d.ts +1 -1
- package/dist/cycle-browser-tabs.d.ts +3 -2
- package/dist/cycle-browser-tabs.js +9 -2
- package/dist/delay-render-embedded-stack.d.ts +1 -1
- package/dist/ensure-faststart.d.ts +1 -0
- package/dist/ensure-faststart.js +14 -0
- package/dist/ensure-presentation-timestamp.d.ts +1 -0
- package/dist/ensure-presentation-timestamp.js +57 -0
- package/dist/error-handling/handle-javascript-exception.d.ts +2 -2
- package/dist/error-handling/handle-javascript-exception.js +3 -4
- package/dist/error-handling/symbolicate-error.d.ts +1 -1
- package/dist/error-handling/symbolicateable-error.d.ts +1 -1
- package/dist/extract-frame-from-video.d.ts +16 -0
- package/dist/extract-frame-from-video.js +248 -0
- package/dist/faststart/atom.d.ts +35 -0
- package/dist/faststart/atom.js +138 -0
- package/dist/faststart/index.d.ts +0 -0
- package/dist/faststart/index.js +1 -0
- package/dist/faststart/options.d.ts +6 -0
- package/dist/faststart/options.js +2 -0
- package/dist/faststart/qt-faststart.d.ts +18 -0
- package/dist/faststart/qt-faststart.js +66 -0
- package/dist/faststart/update-chunk-offsets.d.ts +10 -0
- package/dist/faststart/update-chunk-offsets.js +114 -0
- package/dist/faststart/util.d.ts +9 -0
- package/dist/faststart/util.js +34 -0
- package/dist/frame-to-ffmpeg-timestamp.d.ts +1 -0
- package/dist/frame-to-ffmpeg-timestamp.js +8 -0
- package/dist/get-audio-codec-name.d.ts +1 -1
- package/dist/get-browser-instance.d.ts +4 -3
- package/dist/get-codec-name.d.ts +1 -1
- package/dist/get-compositions.d.ts +8 -5
- package/dist/get-compositions.js +26 -8
- package/dist/get-duration-from-frame-range.d.ts +1 -1
- package/dist/get-duration-of-asset.d.ts +7 -0
- package/dist/get-duration-of-asset.js +36 -0
- package/dist/get-extension-from-codec.d.ts +1 -1
- package/dist/get-frame-to-render.d.ts +1 -1
- package/dist/get-local-browser-executable.d.ts +1 -1
- package/dist/get-local-browser-executable.js +7 -5
- package/dist/get-port.js +30 -37
- package/dist/get-prores-profile-name.d.ts +1 -1
- package/dist/get-video-info.d.ts +8 -0
- package/dist/get-video-info.js +50 -0
- package/dist/image-format.d.ts +1 -1
- package/dist/index.d.ts +45 -14
- package/dist/index.js +17 -5
- package/dist/is-beyond-last-frame.d.ts +2 -0
- package/dist/is-beyond-last-frame.js +12 -0
- package/dist/is-vp9-video.d.ts +3 -0
- package/dist/is-vp9-video.js +24 -0
- package/dist/last-frame-from-video-cache.d.ts +14 -0
- package/dist/last-frame-from-video-cache.js +55 -0
- package/dist/make-assets-download-dir.js +6 -1
- package/dist/make-cancel-signal.d.ts +7 -0
- package/dist/make-cancel-signal.js +25 -0
- package/dist/merge-audio-track.d.ts +1 -1
- package/dist/merge-audio-track.js +2 -2
- package/dist/offthread-video-server.d.ts +15 -0
- package/dist/offthread-video-server.js +74 -0
- package/dist/open-browser.d.ts +9 -7
- package/dist/open-browser.js +11 -11
- package/dist/prepare-server.d.ts +13 -2
- package/dist/prepare-server.js +38 -5
- package/dist/preprocess-audio-track.d.ts +3 -2
- package/dist/preprocess-audio-track.js +2 -2
- package/dist/prespawn-ffmpeg.d.ts +3 -1
- package/dist/prespawn-ffmpeg.js +10 -9
- package/dist/provide-screenshot.d.ts +4 -5
- package/dist/provide-screenshot.js +1 -2
- package/dist/puppeteer-evaluate.d.ts +1 -1
- package/dist/puppeteer-evaluate.js +3 -4
- package/dist/puppeteer-screenshot.d.ts +3 -3
- package/dist/puppeteer-screenshot.js +7 -5
- package/dist/render-frames.d.ts +13 -8
- package/dist/render-frames.js +105 -43
- package/dist/render-gif.d.ts +2 -0
- package/dist/render-gif.js +242 -0
- package/dist/render-media.d.ts +19 -9
- package/dist/render-media.js +134 -56
- package/dist/render-still.d.ts +17 -7
- package/dist/render-still.js +58 -19
- package/dist/screenshot-dom-element.d.ts +6 -8
- package/dist/screenshot-dom-element.js +3 -6
- package/dist/screenshot-task.d.ts +3 -3
- package/dist/screenshot-task.js +3 -5
- package/dist/seek-to-frame.d.ts +2 -2
- package/dist/seek-to-frame.js +2 -2
- package/dist/serve-handler/glob-slash.d.ts +1 -0
- package/dist/serve-handler/glob-slash.js +12 -0
- package/dist/serve-handler/index.d.ts +4 -0
- package/dist/serve-handler/index.js +204 -0
- package/dist/serve-handler/is-path-inside.d.ts +1 -0
- package/dist/serve-handler/is-path-inside.js +27 -0
- package/dist/serve-handler/range-parser.d.ts +13 -0
- package/dist/serve-handler/range-parser.js +57 -0
- package/dist/serve-static.d.ts +10 -3
- package/dist/serve-static.js +22 -4
- package/dist/set-props-and-env.d.ts +4 -2
- package/dist/set-props-and-env.js +28 -3
- package/dist/should-use-vp9-decoder.d.ts +0 -0
- package/dist/should-use-vp9-decoder.js +1 -0
- package/dist/stitch-frames-to-gif.d.ts +8 -0
- package/dist/stitch-frames-to-gif.js +128 -0
- package/dist/stitch-frames-to-video.d.ts +9 -5
- package/dist/stitch-frames-to-video.js +57 -18
- package/dist/stringify-ffmpeg-filter.d.ts +2 -2
- package/dist/stringify-ffmpeg-filter.js +10 -5
- package/dist/symbolicate-stacktrace.d.ts +1 -1
- package/dist/tmp-dir.js +5 -1
- package/dist/types.d.ts +1 -1
- package/dist/validate-even-dimensions-with-codec.d.ts +1 -1
- package/dist/validate-fps-for-gif.d.ts +2 -0
- package/dist/validate-fps-for-gif.js +9 -0
- package/dist/validate-offthreadvideo-image-format.d.ts +1 -0
- package/dist/validate-offthreadvideo-image-format.js +15 -0
- package/dist/validate-output-filename.d.ts +1 -1
- package/dist/wait-for-symbolication-error-to-be-done.d.ts +3 -0
- package/dist/wait-for-symbolication-error-to-be-done.js +34 -0
- package/package.json +10 -10
- package/tsconfig.json +6 -2
- package/types/mime-types/index.d.ts +16 -0
- package/types/ws/index.d.ts +509 -0
package/dist/abort.d.ts
ADDED
package/dist/abort.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCancelSignal = void 0;
|
|
4
|
+
const getCancelSignal = () => {
|
|
5
|
+
const callbacks = [];
|
|
6
|
+
let cancelled = false;
|
|
7
|
+
return {
|
|
8
|
+
cancelSignal: (callback) => callbacks.push(callback),
|
|
9
|
+
cancel: () => {
|
|
10
|
+
if (cancelled) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
callbacks.forEach((cb) => {
|
|
14
|
+
cb();
|
|
15
|
+
});
|
|
16
|
+
cancelled = true;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.getCancelSignal = getCancelSignal;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TAsset } from 'remotion';
|
|
2
|
-
import { Assets } from './types';
|
|
1
|
+
import type { TAsset } from 'remotion';
|
|
2
|
+
import type { Assets } from './types';
|
|
3
3
|
export declare const calculateAssetPositions: (frames: TAsset[][]) => Assets;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TAsset } from 'remotion';
|
|
2
|
-
import { RenderMediaOnDownload } from './download-and-map-assets-to-file';
|
|
1
|
+
import type { TAsset } from 'remotion';
|
|
2
|
+
import type { RenderMediaOnDownload } from './download-and-map-assets-to-file';
|
|
3
3
|
export declare const convertAssetsToFileUrls: ({ assets, downloadDir, onDownload, }: {
|
|
4
4
|
assets: TAsset[][];
|
|
5
5
|
downloadDir: string;
|
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
import { TAsset } from 'remotion';
|
|
1
|
+
import type { TAsset } from 'remotion';
|
|
2
2
|
export declare type RenderMediaOnDownload = (src: string) => ((progress: {
|
|
3
|
-
percent: number;
|
|
3
|
+
percent: number | null;
|
|
4
|
+
downloaded: number;
|
|
5
|
+
totalSize: number | null;
|
|
4
6
|
}) => void) | undefined | void;
|
|
7
|
+
export declare const waitForAssetToBeDownloaded: ({ src, downloadDir, }: {
|
|
8
|
+
src: string;
|
|
9
|
+
downloadDir: string;
|
|
10
|
+
}) => Promise<string>;
|
|
11
|
+
export declare const downloadAsset: ({ src, onDownload, downloadDir, }: {
|
|
12
|
+
src: string;
|
|
13
|
+
onDownload: RenderMediaOnDownload;
|
|
14
|
+
downloadDir: string;
|
|
15
|
+
}) => Promise<string>;
|
|
5
16
|
export declare const markAllAssetsAsDownloaded: () => void;
|
|
6
|
-
export declare const
|
|
17
|
+
export declare const getFilename: ({ contentDisposition, src, }: {
|
|
18
|
+
src: string;
|
|
19
|
+
contentDisposition: string | null;
|
|
20
|
+
}) => {
|
|
21
|
+
pathname: string;
|
|
22
|
+
search: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const getSanitizedFilenameForAssetUrl: ({ src, downloadDir, contentDisposition, }: {
|
|
7
25
|
src: string;
|
|
8
26
|
downloadDir: string;
|
|
27
|
+
contentDisposition: string | null;
|
|
9
28
|
}) => string;
|
|
10
29
|
export declare const downloadAndMapAssetsToFileUrl: ({ asset, downloadDir, onDownload, }: {
|
|
11
30
|
asset: TAsset;
|
|
@@ -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.downloadAndMapAssetsToFileUrl = exports.getSanitizedFilenameForAssetUrl = exports.markAllAssetsAsDownloaded = void 0;
|
|
6
|
+
exports.downloadAndMapAssetsToFileUrl = exports.getSanitizedFilenameForAssetUrl = exports.getFilename = exports.markAllAssetsAsDownloaded = exports.downloadAsset = exports.waitForAssetToBeDownloaded = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const remotion_1 = require("remotion");
|
|
@@ -13,21 +13,41 @@ const sanitize_filepath_1 = require("./sanitize-filepath");
|
|
|
13
13
|
const isDownloadingMap = {};
|
|
14
14
|
const hasBeenDownloadedMap = {};
|
|
15
15
|
const listeners = {};
|
|
16
|
-
const waitForAssetToBeDownloaded = (src) => {
|
|
16
|
+
const waitForAssetToBeDownloaded = ({ src, downloadDir, }) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
if ((_a = hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[downloadDir]) {
|
|
19
|
+
return Promise.resolve((_b = hasBeenDownloadedMap[src]) === null || _b === void 0 ? void 0 : _b[downloadDir]);
|
|
20
|
+
}
|
|
17
21
|
if (!listeners[src]) {
|
|
18
|
-
listeners[src] =
|
|
22
|
+
listeners[src] = {};
|
|
23
|
+
}
|
|
24
|
+
if (!listeners[src][downloadDir]) {
|
|
25
|
+
listeners[src][downloadDir] = [];
|
|
19
26
|
}
|
|
20
27
|
return new Promise((resolve) => {
|
|
21
|
-
listeners[src].push(() =>
|
|
28
|
+
listeners[src][downloadDir].push(() => {
|
|
29
|
+
var _a;
|
|
30
|
+
resolve((_a = hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[downloadDir]);
|
|
31
|
+
});
|
|
22
32
|
});
|
|
23
33
|
};
|
|
24
|
-
|
|
34
|
+
exports.waitForAssetToBeDownloaded = waitForAssetToBeDownloaded;
|
|
35
|
+
const notifyAssetIsDownloaded = ({ src, downloadDir, to, }) => {
|
|
25
36
|
if (!listeners[src]) {
|
|
26
|
-
listeners[src] =
|
|
37
|
+
listeners[src] = {};
|
|
38
|
+
}
|
|
39
|
+
if (!listeners[src][downloadDir]) {
|
|
40
|
+
listeners[src][downloadDir] = [];
|
|
41
|
+
}
|
|
42
|
+
listeners[src][downloadDir].forEach((fn) => fn());
|
|
43
|
+
if (!isDownloadingMap[src]) {
|
|
44
|
+
isDownloadingMap[src] = {};
|
|
27
45
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
46
|
+
isDownloadingMap[src][downloadDir] = true;
|
|
47
|
+
if (!hasBeenDownloadedMap[src]) {
|
|
48
|
+
hasBeenDownloadedMap[src] = {};
|
|
49
|
+
}
|
|
50
|
+
hasBeenDownloadedMap[src][downloadDir] = to;
|
|
31
51
|
};
|
|
32
52
|
const validateMimeType = (mimeType, src) => {
|
|
33
53
|
if (!mimeType.includes('/')) {
|
|
@@ -68,17 +88,29 @@ function validateBufferEncoding(potentialEncoding, dataUrl) {
|
|
|
68
88
|
throw new TypeError(errMessage);
|
|
69
89
|
}
|
|
70
90
|
}
|
|
71
|
-
const downloadAsset = async (src,
|
|
72
|
-
|
|
73
|
-
|
|
91
|
+
const downloadAsset = async ({ src, onDownload, downloadDir, }) => {
|
|
92
|
+
var _a, _b, _c;
|
|
93
|
+
if (remotion_1.Internals.AssetCompression.isAssetCompressed(src)) {
|
|
94
|
+
return src;
|
|
95
|
+
}
|
|
96
|
+
if ((_a = hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[downloadDir]) {
|
|
97
|
+
return (_b = hasBeenDownloadedMap[src]) === null || _b === void 0 ? void 0 : _b[downloadDir];
|
|
74
98
|
}
|
|
75
|
-
if (isDownloadingMap[src]) {
|
|
76
|
-
return waitForAssetToBeDownloaded(src);
|
|
99
|
+
if ((_c = isDownloadingMap[src]) === null || _c === void 0 ? void 0 : _c[downloadDir]) {
|
|
100
|
+
return (0, exports.waitForAssetToBeDownloaded)({ src, downloadDir });
|
|
77
101
|
}
|
|
78
|
-
isDownloadingMap[src]
|
|
102
|
+
if (!isDownloadingMap[src]) {
|
|
103
|
+
isDownloadingMap[src] = {};
|
|
104
|
+
}
|
|
105
|
+
isDownloadingMap[src][downloadDir] = true;
|
|
79
106
|
const onProgress = onDownload(src);
|
|
80
|
-
(0, ensure_output_directory_1.ensureOutputDirectory)(to);
|
|
81
107
|
if (src.startsWith('data:')) {
|
|
108
|
+
const output = (0, exports.getSanitizedFilenameForAssetUrl)({
|
|
109
|
+
contentDisposition: null,
|
|
110
|
+
downloadDir,
|
|
111
|
+
src,
|
|
112
|
+
});
|
|
113
|
+
(0, ensure_output_directory_1.ensureOutputDirectory)(output);
|
|
82
114
|
const [assetDetails, assetData] = src.substring('data:'.length).split(',');
|
|
83
115
|
if (!assetDetails.includes(';')) {
|
|
84
116
|
const errMessage = [
|
|
@@ -93,17 +125,21 @@ const downloadAsset = async (src, to, onDownload) => {
|
|
|
93
125
|
validateMimeType(mimeType, src);
|
|
94
126
|
validateBufferEncoding(encoding, src);
|
|
95
127
|
const buff = Buffer.from(assetData, encoding);
|
|
96
|
-
await fs_1.default.promises.writeFile(
|
|
97
|
-
notifyAssetIsDownloaded(src);
|
|
98
|
-
return;
|
|
128
|
+
await fs_1.default.promises.writeFile(output, buff);
|
|
129
|
+
notifyAssetIsDownloaded({ src, downloadDir, to: output });
|
|
130
|
+
return output;
|
|
99
131
|
}
|
|
100
|
-
await (0, download_file_1.downloadFile)(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
132
|
+
const { to } = await (0, download_file_1.downloadFile)({
|
|
133
|
+
url: src,
|
|
134
|
+
onProgress: (progress) => {
|
|
135
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress(progress);
|
|
136
|
+
},
|
|
137
|
+
to: (contentDisposition) => (0, exports.getSanitizedFilenameForAssetUrl)({ contentDisposition, downloadDir, src }),
|
|
104
138
|
});
|
|
105
|
-
notifyAssetIsDownloaded(src);
|
|
139
|
+
notifyAssetIsDownloaded({ src, downloadDir, to });
|
|
140
|
+
return to;
|
|
106
141
|
};
|
|
142
|
+
exports.downloadAsset = downloadAsset;
|
|
107
143
|
const markAllAssetsAsDownloaded = () => {
|
|
108
144
|
Object.keys(hasBeenDownloadedMap).forEach((key) => {
|
|
109
145
|
delete hasBeenDownloadedMap[key];
|
|
@@ -113,27 +149,44 @@ const markAllAssetsAsDownloaded = () => {
|
|
|
113
149
|
});
|
|
114
150
|
};
|
|
115
151
|
exports.markAllAssetsAsDownloaded = markAllAssetsAsDownloaded;
|
|
116
|
-
const
|
|
152
|
+
const getFilename = ({ contentDisposition, src, }) => {
|
|
153
|
+
const filenameProbe = 'filename=';
|
|
154
|
+
if (contentDisposition === null || contentDisposition === void 0 ? void 0 : contentDisposition.includes(filenameProbe)) {
|
|
155
|
+
const start = contentDisposition.indexOf(filenameProbe);
|
|
156
|
+
const onlyFromFileName = contentDisposition.substring(start + filenameProbe.length);
|
|
157
|
+
const hasSemi = onlyFromFileName.indexOf(';');
|
|
158
|
+
if (hasSemi === -1) {
|
|
159
|
+
return { pathname: onlyFromFileName.trim(), search: '' };
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
search: '',
|
|
163
|
+
pathname: onlyFromFileName.substring(0, hasSemi).trim(),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const { pathname, search } = new URL(src);
|
|
167
|
+
return { pathname, search };
|
|
168
|
+
};
|
|
169
|
+
exports.getFilename = getFilename;
|
|
170
|
+
const getSanitizedFilenameForAssetUrl = ({ src, downloadDir, contentDisposition, }) => {
|
|
117
171
|
if (remotion_1.Internals.AssetCompression.isAssetCompressed(src)) {
|
|
118
172
|
return src;
|
|
119
173
|
}
|
|
120
|
-
const { pathname, search } =
|
|
174
|
+
const { pathname, search } = (0, exports.getFilename)({ contentDisposition, src });
|
|
121
175
|
const split = pathname.split('.');
|
|
122
176
|
const fileExtension = split.length > 1 && split[split.length - 1]
|
|
123
177
|
? `.${split[split.length - 1]}`
|
|
124
178
|
: '';
|
|
125
179
|
const hashedFileName = String((0, remotion_1.random)(`${pathname}${search}`)).replace('0.', '');
|
|
126
|
-
|
|
180
|
+
const filename = hashedFileName + fileExtension;
|
|
181
|
+
return path_1.default.join(downloadDir, (0, sanitize_filepath_1.sanitizeFilePath)(filename));
|
|
127
182
|
};
|
|
128
183
|
exports.getSanitizedFilenameForAssetUrl = getSanitizedFilenameForAssetUrl;
|
|
129
184
|
const downloadAndMapAssetsToFileUrl = async ({ asset, downloadDir, onDownload, }) => {
|
|
130
|
-
const newSrc = (0, exports.
|
|
185
|
+
const newSrc = await (0, exports.downloadAsset)({
|
|
131
186
|
src: asset.src,
|
|
132
187
|
downloadDir,
|
|
188
|
+
onDownload,
|
|
133
189
|
});
|
|
134
|
-
if (!remotion_1.Internals.AssetCompression.isAssetCompressed(newSrc)) {
|
|
135
|
-
await downloadAsset(asset.src, newSrc, onDownload);
|
|
136
|
-
}
|
|
137
190
|
return {
|
|
138
191
|
...asset,
|
|
139
192
|
src: newSrc,
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
export declare const downloadFile: (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export declare const downloadFile: ({ onProgress, url, to: toFn, }: {
|
|
2
|
+
url: string;
|
|
3
|
+
to: (contentDisposition: string | null) => string;
|
|
4
|
+
onProgress: ((progress: {
|
|
5
|
+
percent: number | null;
|
|
6
|
+
downloaded: number;
|
|
7
|
+
totalSize: number | null;
|
|
8
|
+
}) => void) | undefined;
|
|
9
|
+
}) => Promise<{
|
|
6
10
|
sizeInBytes: number;
|
|
11
|
+
to: string;
|
|
7
12
|
}>;
|
|
@@ -2,25 +2,38 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.downloadFile = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
|
+
const ensure_output_directory_1 = require("../ensure-output-directory");
|
|
5
6
|
const read_file_1 = require("./read-file");
|
|
6
|
-
const downloadFile = (url, to,
|
|
7
|
+
const downloadFile = ({ onProgress, url, to: toFn, }) => {
|
|
7
8
|
return new Promise((resolve, reject) => {
|
|
8
9
|
(0, read_file_1.readFile)(url)
|
|
9
10
|
.then((res) => {
|
|
10
|
-
|
|
11
|
+
var _a;
|
|
12
|
+
const contentDisposition = (_a = res.headers['content-disposition']) !== null && _a !== void 0 ? _a : null;
|
|
13
|
+
const to = toFn(contentDisposition);
|
|
14
|
+
(0, ensure_output_directory_1.ensureOutputDirectory)(to);
|
|
15
|
+
const sizeHeader = res.headers['content-length'];
|
|
16
|
+
const totalSize = typeof sizeHeader === 'undefined' ? null : Number(sizeHeader);
|
|
11
17
|
const writeStream = (0, fs_1.createWriteStream)(to);
|
|
18
|
+
let downloaded = 0;
|
|
12
19
|
// Listen to 'close' event instead of more
|
|
13
20
|
// concise method to avoid this problem
|
|
14
21
|
// https://github.com/remotion-dev/remotion/issues/384#issuecomment-844398183
|
|
15
|
-
writeStream.on('close', () =>
|
|
22
|
+
writeStream.on('close', () => {
|
|
23
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
24
|
+
downloaded,
|
|
25
|
+
percent: 1,
|
|
26
|
+
totalSize: downloaded,
|
|
27
|
+
});
|
|
28
|
+
return resolve({ sizeInBytes: downloaded, to });
|
|
29
|
+
});
|
|
16
30
|
writeStream.on('error', (err) => reject(err));
|
|
17
|
-
let downloaded = 0;
|
|
18
31
|
res.pipe(writeStream).on('error', (err) => reject(err));
|
|
19
32
|
res.on('data', (d) => {
|
|
20
33
|
downloaded += d.length;
|
|
21
34
|
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
22
35
|
downloaded,
|
|
23
|
-
|
|
36
|
+
percent: totalSize === null ? null : downloaded / totalSize,
|
|
24
37
|
totalSize,
|
|
25
38
|
});
|
|
26
39
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { AssetVolume } from './types';
|
|
1
|
+
import type { AssetVolume } from './types';
|
|
2
2
|
declare type FfmpegEval = 'once' | 'frame';
|
|
3
3
|
declare type FfmpegVolumeExpression = {
|
|
4
4
|
eval: FfmpegEval;
|
|
5
5
|
value: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const ffmpegVolumeExpression: ({ volume,
|
|
7
|
+
export declare const ffmpegVolumeExpression: ({ volume, fps, trimLeft, }: {
|
|
8
8
|
volume: AssetVolume;
|
|
9
|
-
|
|
9
|
+
trimLeft: number;
|
|
10
10
|
fps: number;
|
|
11
11
|
}) => FfmpegVolumeExpression;
|
|
12
12
|
export {};
|
|
@@ -12,12 +12,12 @@ const FFMPEG_TIME_VARIABLE = 't';
|
|
|
12
12
|
const ffmpegIfOrElse = (condition, then, elseDo) => {
|
|
13
13
|
return `if(${condition},${then},${elseDo})`;
|
|
14
14
|
};
|
|
15
|
-
const ffmpegIsOneOfFrames = (frames, fps) => {
|
|
15
|
+
const ffmpegIsOneOfFrames = ({ frames, trimLeft, fps, }) => {
|
|
16
16
|
const consecutiveArrays = [];
|
|
17
17
|
for (let i = 0; i < frames.length; i++) {
|
|
18
18
|
const previousFrame = frames[i - 1];
|
|
19
19
|
const frame = frames[i];
|
|
20
|
-
if (
|
|
20
|
+
if (previousFrame === undefined || frame !== previousFrame + 1) {
|
|
21
21
|
consecutiveArrays.push([]);
|
|
22
22
|
}
|
|
23
23
|
consecutiveArrays[consecutiveArrays.length - 1].push(frame);
|
|
@@ -28,25 +28,22 @@ const ffmpegIsOneOfFrames = (frames, fps) => {
|
|
|
28
28
|
const lastFrame = f[f.length - 1];
|
|
29
29
|
const before = (firstFrame - 0.5) / fps;
|
|
30
30
|
const after = (lastFrame + 0.5) / fps;
|
|
31
|
-
return `between(${FFMPEG_TIME_VARIABLE},${before.toFixed(4)},${after.toFixed(4)})`;
|
|
31
|
+
return `between(${FFMPEG_TIME_VARIABLE},${(before + trimLeft).toFixed(4)},${(after + trimLeft).toFixed(4)})`;
|
|
32
32
|
})
|
|
33
33
|
.join('+');
|
|
34
34
|
};
|
|
35
|
-
const ffmpegBuildVolumeExpression = (arr, fps) => {
|
|
35
|
+
const ffmpegBuildVolumeExpression = (arr, delay, fps) => {
|
|
36
36
|
if (arr.length === 0) {
|
|
37
37
|
throw new Error('Volume array expression should never have length 0');
|
|
38
38
|
}
|
|
39
39
|
if (arr.length === 1) {
|
|
40
|
-
|
|
41
|
-
// where the audio actually plays.
|
|
42
|
-
// If this is the case, we just return volume 0 to clip it.
|
|
43
|
-
return ffmpegIfOrElse(ffmpegIsOneOfFrames(arr[0][1], fps), String(arr[0][0]), String(0));
|
|
40
|
+
return String(arr[0][0]);
|
|
44
41
|
}
|
|
45
42
|
const [first, ...rest] = arr;
|
|
46
43
|
const [volume, frames] = first;
|
|
47
|
-
return ffmpegIfOrElse(ffmpegIsOneOfFrames(frames, fps), String(volume), ffmpegBuildVolumeExpression(rest, fps));
|
|
44
|
+
return ffmpegIfOrElse(ffmpegIsOneOfFrames({ frames, trimLeft: delay, fps }), String(volume), ffmpegBuildVolumeExpression(rest, delay, fps));
|
|
48
45
|
};
|
|
49
|
-
const ffmpegVolumeExpression = ({ volume,
|
|
46
|
+
const ffmpegVolumeExpression = ({ volume, fps, trimLeft, }) => {
|
|
50
47
|
// If it's a static volume, we return it and tell
|
|
51
48
|
// FFMPEG it only has to evaluate it once
|
|
52
49
|
if (typeof volume === 'number') {
|
|
@@ -58,22 +55,27 @@ const ffmpegVolumeExpression = ({ volume, startInVideo, fps, }) => {
|
|
|
58
55
|
if ([...new Set(volume)].length === 1) {
|
|
59
56
|
return (0, exports.ffmpegVolumeExpression)({
|
|
60
57
|
volume: volume[0],
|
|
61
|
-
startInVideo,
|
|
62
58
|
fps,
|
|
59
|
+
trimLeft,
|
|
63
60
|
});
|
|
64
61
|
}
|
|
62
|
+
// A 1 sec video with frames 0-29 would mean that
|
|
63
|
+
// frame 29 corresponds to timestamp 0.966666...
|
|
64
|
+
// but the audio is actually 1 sec long. For that reason we pad the last
|
|
65
|
+
// timestamp.
|
|
66
|
+
const paddedVolume = [...volume, volume[volume.length - 1]];
|
|
65
67
|
// Otherwise, we construct an FFMPEG expression. First step:
|
|
66
68
|
// Make a map of all possible volumes
|
|
67
69
|
// {possibleVolume1} => [frame1, frame2]
|
|
68
70
|
// {possibleVolume2} => [frame3, frame4]
|
|
69
71
|
const volumeMap = {};
|
|
70
|
-
|
|
72
|
+
paddedVolume.forEach((baseVolume, frame) => {
|
|
71
73
|
// Adjust volume based on how many other tracks have not yet finished
|
|
72
74
|
const actualVolume = (0, round_volume_to_avoid_stack_overflow_1.roundVolumeToAvoidStackOverflow)(Math.min(1, baseVolume));
|
|
73
75
|
if (!volumeMap[actualVolume]) {
|
|
74
76
|
volumeMap[actualVolume] = [];
|
|
75
77
|
}
|
|
76
|
-
volumeMap[actualVolume].push(frame
|
|
78
|
+
volumeMap[actualVolume].push(frame);
|
|
77
79
|
});
|
|
78
80
|
// Sort the map so that the most common volume is last
|
|
79
81
|
// this is going to be the else statement so the expression is short
|
|
@@ -81,7 +83,7 @@ const ffmpegVolumeExpression = ({ volume, startInVideo, fps, }) => {
|
|
|
81
83
|
.map((key) => [Number(key), volumeMap[key]])
|
|
82
84
|
.sort((a, b) => a[1].length - b[1].length);
|
|
83
85
|
// Construct and tell FFMPEG it has to evaluate expression on each frame
|
|
84
|
-
const expression = ffmpegBuildVolumeExpression(volumeArray, fps);
|
|
86
|
+
const expression = ffmpegBuildVolumeExpression(volumeArray, trimLeft, fps);
|
|
85
87
|
return {
|
|
86
88
|
eval: 'frame',
|
|
87
89
|
value: `'${expression}'`,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AssetVolume, MediaAsset } from './types';
|
|
1
|
+
import type { AssetVolume, MediaAsset } from './types';
|
|
2
2
|
export declare const flattenVolumeArray: (volume: AssetVolume) => AssetVolume;
|
|
3
3
|
export declare const convertAssetToFlattenedVolume: (asset: MediaAsset) => MediaAsset;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { FfmpegExecutable } from 'remotion';
|
|
2
|
+
declare type Result = {
|
|
2
3
|
channels: number;
|
|
3
4
|
duration: number | null;
|
|
4
|
-
}
|
|
5
|
+
};
|
|
6
|
+
export declare const getAudioChannelsAndDuration: (src: string, ffprobeExecutable: FfmpegExecutable) => Promise<Result>;
|
|
7
|
+
export {};
|
|
@@ -5,21 +5,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getAudioChannelsAndDuration = void 0;
|
|
7
7
|
const execa_1 = __importDefault(require("execa"));
|
|
8
|
-
|
|
8
|
+
const p_limit_1 = require("../p-limit");
|
|
9
|
+
const durationOfAssetCache = {};
|
|
10
|
+
const limit = (0, p_limit_1.pLimit)(1);
|
|
11
|
+
async function getAudioChannelsAndDurationUnlimited(src, ffprobeExecutable) {
|
|
12
|
+
if (durationOfAssetCache[src]) {
|
|
13
|
+
return durationOfAssetCache[src];
|
|
14
|
+
}
|
|
9
15
|
const args = [
|
|
10
16
|
['-v', 'error'],
|
|
11
17
|
['-show_entries', 'stream=channels:format=duration'],
|
|
12
18
|
['-of', 'default=nw=1'],
|
|
13
|
-
[
|
|
19
|
+
[src],
|
|
14
20
|
]
|
|
15
21
|
.reduce((acc, val) => acc.concat(val), [])
|
|
16
22
|
.filter(Boolean);
|
|
17
|
-
const task = await (0, execa_1.default)('ffprobe', args);
|
|
23
|
+
const task = await (0, execa_1.default)(ffprobeExecutable !== null && ffprobeExecutable !== void 0 ? ffprobeExecutable : 'ffprobe', args);
|
|
18
24
|
const channels = task.stdout.match(/channels=([0-9]+)/);
|
|
19
25
|
const duration = task.stdout.match(/duration=([0-9.]+)/);
|
|
20
|
-
|
|
26
|
+
const result = {
|
|
21
27
|
channels: channels ? parseInt(channels[1], 10) : 0,
|
|
22
28
|
duration: duration ? parseFloat(duration[1]) : null,
|
|
23
29
|
};
|
|
30
|
+
durationOfAssetCache[src] = result;
|
|
31
|
+
return result;
|
|
24
32
|
}
|
|
33
|
+
const getAudioChannelsAndDuration = (src, ffprobeExecutable) => {
|
|
34
|
+
return limit(() => getAudioChannelsAndDurationUnlimited(src, ffprobeExecutable));
|
|
35
|
+
};
|
|
25
36
|
exports.getAudioChannelsAndDuration = getAudioChannelsAndDuration;
|
package/dist/assets/read-file.js
CHANGED
|
@@ -29,7 +29,10 @@ const readFile = async (url, redirectsSoFar = 0) => {
|
|
|
29
29
|
throw new Error(`Too many redirects while downloading ${url}`);
|
|
30
30
|
}
|
|
31
31
|
const file = await readFileWithoutRedirect(url);
|
|
32
|
-
if (file.statusCode === 302 ||
|
|
32
|
+
if (file.statusCode === 302 ||
|
|
33
|
+
file.statusCode === 301 ||
|
|
34
|
+
file.statusCode === 307 ||
|
|
35
|
+
file.statusCode === 308) {
|
|
33
36
|
if (!file.headers.location) {
|
|
34
37
|
throw new Error(`Received a status code ${file.statusCode} but no "Location" header while calling ${file.headers.location}`);
|
|
35
38
|
}
|
package/dist/assets/types.d.ts
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2017 Google Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { Connection } from './Connection';
|
|
17
|
+
import { EventEmitter } from './EventEmitter';
|
|
18
|
+
import type { Page } from './Page';
|
|
19
|
+
import type { Viewport } from './PuppeteerViewport';
|
|
20
|
+
import { Target } from './Target';
|
|
21
|
+
declare type BrowserCloseCallback = () => Promise<void> | void;
|
|
22
|
+
interface WaitForTargetOptions {
|
|
23
|
+
timeout?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare const enum BrowserEmittedEvents {
|
|
26
|
+
TargetChanged = "targetchanged",
|
|
27
|
+
TargetCreated = "targetcreated",
|
|
28
|
+
Closed = "closed"
|
|
29
|
+
}
|
|
30
|
+
export declare class Browser extends EventEmitter {
|
|
31
|
+
#private;
|
|
32
|
+
static _create({ connection, contextIds, defaultViewport, closeCallback, }: {
|
|
33
|
+
connection: Connection;
|
|
34
|
+
contextIds: string[];
|
|
35
|
+
defaultViewport: Viewport;
|
|
36
|
+
closeCallback?: BrowserCloseCallback;
|
|
37
|
+
}): Promise<Browser>;
|
|
38
|
+
get _targets(): Map<string, Target>;
|
|
39
|
+
constructor(connection: Connection, contextIds: string[], defaultViewport: Viewport, closeCallback?: BrowserCloseCallback);
|
|
40
|
+
browserContexts(): BrowserContext[];
|
|
41
|
+
newPage(): Promise<Page>;
|
|
42
|
+
_createPageInContext(contextId?: string): Promise<Page>;
|
|
43
|
+
targets(): Target[];
|
|
44
|
+
waitForTarget(predicate: (x: Target) => boolean | Promise<boolean>, options?: WaitForTargetOptions): Promise<Target>;
|
|
45
|
+
pages(): Promise<Page[]>;
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
disconnect(): void;
|
|
48
|
+
}
|
|
49
|
+
export declare class BrowserContext extends EventEmitter {
|
|
50
|
+
#private;
|
|
51
|
+
constructor(browser: Browser, contextId?: string);
|
|
52
|
+
targets(): Target[];
|
|
53
|
+
waitForTarget(predicate: (x: Target) => boolean | Promise<boolean>, options?: {
|
|
54
|
+
timeout?: number;
|
|
55
|
+
}): Promise<Target>;
|
|
56
|
+
pages(): Promise<Page[]>;
|
|
57
|
+
newPage(): Promise<Page>;
|
|
58
|
+
browser(): Browser;
|
|
59
|
+
}
|
|
60
|
+
export {};
|