@remotion/renderer 4.0.0-fastlambda.8 → 4.0.0-lambda.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/assets/cleanup-assets.d.ts +2 -0
- package/dist/assets/cleanup-assets.js +2 -0
- package/dist/assets/download-and-map-assets-to-file.d.ts +6 -0
- package/dist/assets/download-and-map-assets-to-file.js +46 -19
- package/dist/assets/ffmpeg-volume-expression.d.ts +2 -1
- package/dist/assets/ffmpeg-volume-expression.js +15 -12
- package/dist/assets/get-audio-channels.d.ts +5 -2
- package/dist/assets/get-audio-channels.js +15 -4
- package/dist/browser/Accessibility.d.ts +175 -0
- package/dist/browser/Accessibility.js +423 -0
- package/dist/browser/AriaQueryHandler.d.ts +20 -0
- package/dist/browser/AriaQueryHandler.js +108 -0
- package/dist/browser/Browser.d.ts +209 -0
- package/dist/browser/Browser.js +402 -0
- package/dist/browser/BrowserConnector.d.ts +26 -0
- package/dist/browser/BrowserConnector.js +49 -0
- package/dist/browser/BrowserFetcher.d.ts +89 -0
- package/dist/browser/BrowserFetcher.js +512 -0
- package/dist/browser/BrowserRunner.d.ts +39 -0
- package/dist/browser/BrowserRunner.js +308 -0
- package/dist/browser/Connection.d.ts +49 -0
- package/dist/browser/Connection.js +262 -0
- package/dist/browser/ConnectionTransport.d.ts +21 -0
- package/dist/browser/ConnectionTransport.js +17 -0
- package/dist/browser/ConsoleMessage.d.ts +55 -0
- package/dist/browser/ConsoleMessage.js +75 -0
- package/dist/browser/Coverage.d.ts +180 -0
- package/dist/browser/Coverage.js +371 -0
- package/dist/browser/DOMWorld.d.ts +50 -0
- package/dist/browser/DOMWorld.js +280 -0
- package/dist/browser/Debug.d.ts +19 -0
- package/dist/browser/Debug.js +42 -0
- package/dist/browser/DeviceDescriptors.d.ts +40 -0
- package/dist/browser/DeviceDescriptors.js +1407 -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 +70 -0
- package/dist/browser/EventEmitter.js +102 -0
- package/dist/browser/ExecutionContext.d.ts +35 -0
- package/dist/browser/ExecutionContext.js +190 -0
- package/dist/browser/FileChooser.d.ts +56 -0
- package/dist/browser/FileChooser.js +86 -0
- package/dist/browser/FrameManager.d.ts +96 -0
- package/dist/browser/FrameManager.js +512 -0
- package/dist/browser/HTTPRequest.d.ts +42 -0
- package/dist/browser/HTTPRequest.js +82 -0
- package/dist/browser/HTTPResponse.d.ts +100 -0
- package/dist/browser/HTTPResponse.js +196 -0
- package/dist/browser/Input.d.ts +355 -0
- package/dist/browser/Input.js +592 -0
- package/dist/browser/JSHandle.d.ts +36 -0
- package/dist/browser/JSHandle.js +93 -0
- package/dist/browser/LaunchOptions.d.ts +117 -0
- package/dist/browser/LaunchOptions.js +17 -0
- package/dist/browser/Launcher.d.ts +9 -0
- package/dist/browser/Launcher.js +602 -0
- package/dist/browser/LifecycleWatcher.d.ts +29 -0
- package/dist/browser/LifecycleWatcher.js +193 -0
- package/dist/browser/NetworkConditions.d.ts +26 -0
- package/dist/browser/NetworkConditions.js +33 -0
- package/dist/browser/NetworkEventManager.d.ts +35 -0
- package/dist/browser/NetworkEventManager.js +128 -0
- package/dist/browser/NetworkManager.d.ts +36 -0
- package/dist/browser/NetworkManager.js +284 -0
- package/dist/browser/NodeWebSocketTransport.d.ts +11 -0
- package/dist/browser/NodeWebSocketTransport.js +90 -0
- package/dist/browser/PDFOptions.d.ts +165 -0
- package/dist/browser/PDFOptions.js +34 -0
- package/dist/browser/PipeTransport.d.ts +10 -0
- package/dist/browser/PipeTransport.js +86 -0
- package/dist/browser/Product.d.ts +16 -0
- package/dist/browser/Product.js +17 -0
- package/dist/browser/Puppeteer.d.ts +35 -0
- package/dist/browser/Puppeteer.js +17 -0
- package/dist/browser/PuppeteerNode.d.ts +92 -0
- package/dist/browser/PuppeteerNode.js +143 -0
- package/dist/browser/PuppeteerViewport.d.ts +5 -0
- package/dist/browser/PuppeteerViewport.js +2 -0
- package/dist/browser/QueryHandler.d.ts +64 -0
- package/dist/browser/QueryHandler.js +183 -0
- package/dist/browser/ScreenshotOptions.d.ts +14 -0
- package/dist/browser/ScreenshotOptions.js +2 -0
- package/dist/browser/SecurityDetails.d.ts +55 -0
- package/dist/browser/SecurityDetails.js +95 -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/Tracing.d.ts +45 -0
- package/dist/browser/Tracing.js +136 -0
- package/dist/browser/USKeyboardLayout.d.ts +39 -0
- package/dist/browser/USKeyboardLayout.js +406 -0
- package/dist/browser/WebWorker.d.ts +96 -0
- package/dist/browser/WebWorker.js +122 -0
- package/dist/browser/assert.d.ts +21 -0
- package/dist/browser/assert.js +29 -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 +140 -0
- package/dist/browser/dialog.d.ts +70 -0
- package/dist/browser/dialog.js +114 -0
- package/dist/browser/environment.d.ts +16 -0
- package/dist/browser/environment.js +19 -0
- package/dist/browser/fetch.d.ts +16 -0
- package/dist/browser/fetch.js +46 -0
- package/dist/browser/find-up.d.ts +4 -0
- package/dist/browser/find-up.js +85 -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/page.d.ts +78 -0
- package/dist/browser/page.js +277 -0
- package/dist/browser/pkg-dir.d.ts +3 -0
- package/dist/browser/pkg-dir.js +13 -0
- package/dist/browser/revisions.d.ts +21 -0
- package/dist/browser/revisions.js +22 -0
- package/dist/browser/util.d.ts +46 -0
- package/dist/browser/util.js +161 -0
- package/dist/calculate-ffmpeg-filters.js +2 -2
- package/dist/combine-videos.d.ts +2 -1
- package/dist/combine-videos.js +8 -1
- package/dist/cycle-browser-tabs.d.ts +2 -1
- package/dist/cycle-browser-tabs.js +9 -2
- package/dist/ensure-presentation-timestamp.d.ts +1 -0
- package/dist/ensure-presentation-timestamp.js +57 -0
- package/dist/extract-frame-from-video.d.ts +11 -0
- package/dist/extract-frame-from-video.js +197 -0
- package/dist/frame-to-ffmpeg-timestamp.d.ts +1 -0
- package/dist/frame-to-ffmpeg-timestamp.js +8 -0
- package/dist/get-compositions.d.ts +5 -2
- package/dist/get-compositions.js +23 -5
- package/dist/get-duration-of-asset.d.ts +7 -0
- package/dist/get-duration-of-asset.js +36 -0
- package/dist/get-port.js +26 -24
- package/dist/index.d.ts +33 -9
- package/dist/index.js +14 -5
- package/dist/is-beyond-last-frame.d.ts +2 -0
- package/dist/is-beyond-last-frame.js +12 -0
- package/dist/last-frame-from-video-cache.d.ts +10 -0
- package/dist/last-frame-from-video-cache.js +50 -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.js +2 -2
- package/dist/offthread-video-server.d.ts +14 -0
- package/dist/offthread-video-server.js +67 -0
- package/dist/open-browser.d.ts +6 -6
- package/dist/open-browser.js +24 -20
- package/dist/prepare-server.d.ts +13 -2
- package/dist/prepare-server.js +35 -5
- package/dist/preprocess-audio-track.d.ts +1 -0
- package/dist/preprocess-audio-track.js +2 -2
- package/dist/prespawn-ffmpeg.d.ts +2 -0
- package/dist/prespawn-ffmpeg.js +10 -9
- package/dist/provide-screenshot.js +1 -1
- package/dist/puppeteer-screenshot.js +5 -1
- package/dist/render-frames.d.ts +6 -1
- package/dist/render-frames.js +96 -37
- package/dist/render-media.d.ts +12 -2
- package/dist/render-media.js +127 -54
- package/dist/render-still.d.ts +14 -4
- package/dist/render-still.js +58 -19
- 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 +205 -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 +3 -1
- package/dist/set-props-and-env.js +28 -6
- package/dist/stitch-frames-to-video.d.ts +4 -1
- package/dist/stitch-frames-to-video.js +36 -15
- package/dist/stringify-ffmpeg-filter.js +3 -0
- package/dist/tmp-dir.js +5 -1
- package/dist/validate-fps-for-gif.d.ts +2 -0
- package/dist/validate-fps-for-gif.js +9 -0
- package/package.json +6 -7
|
@@ -2,6 +2,7 @@ import { TAsset } from 'remotion';
|
|
|
2
2
|
export declare type RenderMediaOnDownload = (src: string) => ((progress: {
|
|
3
3
|
percent: number;
|
|
4
4
|
}) => void) | undefined | void;
|
|
5
|
+
export declare const waitForAssetToBeDownloaded: (src: string, to: string) => Promise<void>;
|
|
5
6
|
export declare const markAllAssetsAsDownloaded: () => void;
|
|
6
7
|
export declare const getSanitizedFilenameForAssetUrl: ({ src, downloadDir, }: {
|
|
7
8
|
src: string;
|
|
@@ -12,3 +13,8 @@ export declare const downloadAndMapAssetsToFileUrl: ({ asset, downloadDir, onDow
|
|
|
12
13
|
downloadDir: string;
|
|
13
14
|
onDownload: RenderMediaOnDownload;
|
|
14
15
|
}) => Promise<TAsset>;
|
|
16
|
+
export declare const startDownloadForSrc: ({ src, downloadDir, onDownload, }: {
|
|
17
|
+
src: string;
|
|
18
|
+
downloadDir: string;
|
|
19
|
+
onDownload: RenderMediaOnDownload;
|
|
20
|
+
}) => Promise<string>;
|
|
@@ -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.startDownloadForSrc = exports.downloadAndMapAssetsToFileUrl = exports.getSanitizedFilenameForAssetUrl = exports.markAllAssetsAsDownloaded = 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,38 @@ 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, to) => {
|
|
17
|
+
var _a;
|
|
18
|
+
if ((_a = hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[to]) {
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
}
|
|
17
21
|
if (!listeners[src]) {
|
|
18
|
-
listeners[src] =
|
|
22
|
+
listeners[src] = {};
|
|
23
|
+
}
|
|
24
|
+
if (!listeners[src][to]) {
|
|
25
|
+
listeners[src][to] = [];
|
|
19
26
|
}
|
|
20
27
|
return new Promise((resolve) => {
|
|
21
|
-
listeners[src].push(() => resolve());
|
|
28
|
+
listeners[src][to].push(() => resolve());
|
|
22
29
|
});
|
|
23
30
|
};
|
|
24
|
-
|
|
31
|
+
exports.waitForAssetToBeDownloaded = waitForAssetToBeDownloaded;
|
|
32
|
+
const notifyAssetIsDownloaded = (src, to) => {
|
|
25
33
|
if (!listeners[src]) {
|
|
26
|
-
listeners[src] =
|
|
34
|
+
listeners[src] = {};
|
|
35
|
+
}
|
|
36
|
+
if (!listeners[src][to]) {
|
|
37
|
+
listeners[src][to] = [];
|
|
27
38
|
}
|
|
28
|
-
listeners[src].forEach((fn) => fn());
|
|
29
|
-
isDownloadingMap[src]
|
|
30
|
-
|
|
39
|
+
listeners[src][to].forEach((fn) => fn());
|
|
40
|
+
if (!isDownloadingMap[src]) {
|
|
41
|
+
isDownloadingMap[src] = {};
|
|
42
|
+
}
|
|
43
|
+
isDownloadingMap[src][to] = false;
|
|
44
|
+
if (!hasBeenDownloadedMap[src]) {
|
|
45
|
+
hasBeenDownloadedMap[src] = {};
|
|
46
|
+
}
|
|
47
|
+
hasBeenDownloadedMap[src][to] = true;
|
|
31
48
|
};
|
|
32
49
|
const validateMimeType = (mimeType, src) => {
|
|
33
50
|
if (!mimeType.includes('/')) {
|
|
@@ -69,13 +86,17 @@ function validateBufferEncoding(potentialEncoding, dataUrl) {
|
|
|
69
86
|
}
|
|
70
87
|
}
|
|
71
88
|
const downloadAsset = async (src, to, onDownload) => {
|
|
72
|
-
|
|
89
|
+
var _a, _b;
|
|
90
|
+
if ((_a = hasBeenDownloadedMap[src]) === null || _a === void 0 ? void 0 : _a[to]) {
|
|
73
91
|
return;
|
|
74
92
|
}
|
|
75
|
-
if (isDownloadingMap[src]) {
|
|
76
|
-
return waitForAssetToBeDownloaded(src);
|
|
93
|
+
if ((_b = isDownloadingMap[src]) === null || _b === void 0 ? void 0 : _b[to]) {
|
|
94
|
+
return (0, exports.waitForAssetToBeDownloaded)(src, to);
|
|
95
|
+
}
|
|
96
|
+
if (!isDownloadingMap[src]) {
|
|
97
|
+
isDownloadingMap[src] = {};
|
|
77
98
|
}
|
|
78
|
-
isDownloadingMap[src] = true;
|
|
99
|
+
isDownloadingMap[src][to] = true;
|
|
79
100
|
const onProgress = onDownload(src);
|
|
80
101
|
(0, ensure_output_directory_1.ensureOutputDirectory)(to);
|
|
81
102
|
if (src.startsWith('data:')) {
|
|
@@ -94,7 +115,7 @@ const downloadAsset = async (src, to, onDownload) => {
|
|
|
94
115
|
validateBufferEncoding(encoding, src);
|
|
95
116
|
const buff = Buffer.from(assetData, encoding);
|
|
96
117
|
await fs_1.default.promises.writeFile(to, buff);
|
|
97
|
-
notifyAssetIsDownloaded(src);
|
|
118
|
+
notifyAssetIsDownloaded(src, to);
|
|
98
119
|
return;
|
|
99
120
|
}
|
|
100
121
|
await (0, download_file_1.downloadFile)(src, to, ({ progress }) => {
|
|
@@ -102,7 +123,7 @@ const downloadAsset = async (src, to, onDownload) => {
|
|
|
102
123
|
percent: progress,
|
|
103
124
|
});
|
|
104
125
|
});
|
|
105
|
-
notifyAssetIsDownloaded(src);
|
|
126
|
+
notifyAssetIsDownloaded(src, to);
|
|
106
127
|
};
|
|
107
128
|
const markAllAssetsAsDownloaded = () => {
|
|
108
129
|
Object.keys(hasBeenDownloadedMap).forEach((key) => {
|
|
@@ -127,16 +148,22 @@ const getSanitizedFilenameForAssetUrl = ({ src, downloadDir, }) => {
|
|
|
127
148
|
};
|
|
128
149
|
exports.getSanitizedFilenameForAssetUrl = getSanitizedFilenameForAssetUrl;
|
|
129
150
|
const downloadAndMapAssetsToFileUrl = async ({ asset, downloadDir, onDownload, }) => {
|
|
130
|
-
const newSrc = (0, exports.
|
|
151
|
+
const newSrc = await (0, exports.startDownloadForSrc)({
|
|
131
152
|
src: asset.src,
|
|
132
153
|
downloadDir,
|
|
154
|
+
onDownload,
|
|
133
155
|
});
|
|
134
|
-
if (!remotion_1.Internals.AssetCompression.isAssetCompressed(newSrc)) {
|
|
135
|
-
await downloadAsset(asset.src, newSrc, onDownload);
|
|
136
|
-
}
|
|
137
156
|
return {
|
|
138
157
|
...asset,
|
|
139
158
|
src: newSrc,
|
|
140
159
|
};
|
|
141
160
|
};
|
|
142
161
|
exports.downloadAndMapAssetsToFileUrl = downloadAndMapAssetsToFileUrl;
|
|
162
|
+
const startDownloadForSrc = async ({ src, downloadDir, onDownload, }) => {
|
|
163
|
+
const newSrc = (0, exports.getSanitizedFilenameForAssetUrl)({ downloadDir, src });
|
|
164
|
+
if (!remotion_1.Internals.AssetCompression.isAssetCompressed(newSrc)) {
|
|
165
|
+
await downloadAsset(src, newSrc, onDownload);
|
|
166
|
+
}
|
|
167
|
+
return newSrc;
|
|
168
|
+
};
|
|
169
|
+
exports.startDownloadForSrc = startDownloadForSrc;
|
|
@@ -4,9 +4,10 @@ declare type FfmpegVolumeExpression = {
|
|
|
4
4
|
eval: FfmpegEval;
|
|
5
5
|
value: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const ffmpegVolumeExpression: ({ volume, startInVideo, fps, }: {
|
|
7
|
+
export declare const ffmpegVolumeExpression: ({ volume, startInVideo, fps, trimLeft, }: {
|
|
8
8
|
volume: AssetVolume;
|
|
9
9
|
startInVideo: number;
|
|
10
|
+
trimLeft: number;
|
|
10
11
|
fps: number;
|
|
11
12
|
}) => FfmpegVolumeExpression;
|
|
12
13
|
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, startInVideo, fps, }) => {
|
|
46
|
+
const ffmpegVolumeExpression = ({ volume, startInVideo, 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') {
|
|
@@ -60,14 +57,20 @@ const ffmpegVolumeExpression = ({ volume, startInVideo, fps, }) => {
|
|
|
60
57
|
volume: volume[0],
|
|
61
58
|
startInVideo,
|
|
62
59
|
fps,
|
|
60
|
+
trimLeft,
|
|
63
61
|
});
|
|
64
62
|
}
|
|
63
|
+
// A 1 sec video with frames 0-29 would mean that
|
|
64
|
+
// frame 29 corresponds to timestamp 0.966666...
|
|
65
|
+
// but the audio is actually 1 sec long. For that reason we pad the last
|
|
66
|
+
// timestamp.
|
|
67
|
+
const paddedVolume = [...volume, volume[volume.length - 1]];
|
|
65
68
|
// Otherwise, we construct an FFMPEG expression. First step:
|
|
66
69
|
// Make a map of all possible volumes
|
|
67
70
|
// {possibleVolume1} => [frame1, frame2]
|
|
68
71
|
// {possibleVolume2} => [frame3, frame4]
|
|
69
72
|
const volumeMap = {};
|
|
70
|
-
|
|
73
|
+
paddedVolume.forEach((baseVolume, frame) => {
|
|
71
74
|
// Adjust volume based on how many other tracks have not yet finished
|
|
72
75
|
const actualVolume = (0, round_volume_to_avoid_stack_overflow_1.roundVolumeToAvoidStackOverflow)(Math.min(1, baseVolume));
|
|
73
76
|
if (!volumeMap[actualVolume]) {
|
|
@@ -81,7 +84,7 @@ const ffmpegVolumeExpression = ({ volume, startInVideo, fps, }) => {
|
|
|
81
84
|
.map((key) => [Number(key), volumeMap[key]])
|
|
82
85
|
.sort((a, b) => a[1].length - b[1].length);
|
|
83
86
|
// Construct and tell FFMPEG it has to evaluate expression on each frame
|
|
84
|
-
const expression = ffmpegBuildVolumeExpression(volumeArray, fps);
|
|
87
|
+
const expression = ffmpegBuildVolumeExpression(volumeArray, trimLeft, fps);
|
|
85
88
|
return {
|
|
86
89
|
eval: 'frame',
|
|
87
90
|
value: `'${expression}'`,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { 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;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2018 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 { CDPSession } from './Connection';
|
|
17
|
+
import { ElementHandle } from './JSHandle';
|
|
18
|
+
/**
|
|
19
|
+
* Represents a Node and the properties of it that are relevant to Accessibility.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export interface SerializedAXNode {
|
|
23
|
+
/**
|
|
24
|
+
* The {@link https://www.w3.org/TR/wai-aria/#usage_intro | role} of the node.
|
|
25
|
+
*/
|
|
26
|
+
role: string;
|
|
27
|
+
/**
|
|
28
|
+
* A human readable name for the node.
|
|
29
|
+
*/
|
|
30
|
+
name?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The current value of the node.
|
|
33
|
+
*/
|
|
34
|
+
value?: string | number;
|
|
35
|
+
/**
|
|
36
|
+
* An additional human readable description of the node.
|
|
37
|
+
*/
|
|
38
|
+
description?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Any keyboard shortcuts associated with this node.
|
|
41
|
+
*/
|
|
42
|
+
keyshortcuts?: string;
|
|
43
|
+
/**
|
|
44
|
+
* A human readable alternative to the role.
|
|
45
|
+
*/
|
|
46
|
+
roledescription?: string;
|
|
47
|
+
/**
|
|
48
|
+
* A description of the current value.
|
|
49
|
+
*/
|
|
50
|
+
valuetext?: string;
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
expanded?: boolean;
|
|
53
|
+
focused?: boolean;
|
|
54
|
+
modal?: boolean;
|
|
55
|
+
multiline?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Whether more than one child can be selected.
|
|
58
|
+
*/
|
|
59
|
+
multiselectable?: boolean;
|
|
60
|
+
readonly?: boolean;
|
|
61
|
+
required?: boolean;
|
|
62
|
+
selected?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the checkbox is checked, or in a
|
|
65
|
+
* {@link https://www.w3.org/TR/wai-aria-practices/examples/checkbox/checkbox-2/checkbox-2.html | mixed state}.
|
|
66
|
+
*/
|
|
67
|
+
checked?: boolean | 'mixed';
|
|
68
|
+
/**
|
|
69
|
+
* Whether the node is checked or in a mixed state.
|
|
70
|
+
*/
|
|
71
|
+
pressed?: boolean | 'mixed';
|
|
72
|
+
/**
|
|
73
|
+
* The level of a heading.
|
|
74
|
+
*/
|
|
75
|
+
level?: number;
|
|
76
|
+
valuemin?: number;
|
|
77
|
+
valuemax?: number;
|
|
78
|
+
autocomplete?: string;
|
|
79
|
+
haspopup?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Whether and in what way this node's value is invalid.
|
|
82
|
+
*/
|
|
83
|
+
invalid?: string;
|
|
84
|
+
orientation?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Children of this node, if there are any.
|
|
87
|
+
*/
|
|
88
|
+
children?: SerializedAXNode[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
export interface SnapshotOptions {
|
|
94
|
+
/**
|
|
95
|
+
* Prune uninteresting nodes from the tree.
|
|
96
|
+
* @defaultValue true
|
|
97
|
+
*/
|
|
98
|
+
interestingOnly?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Root node to get the accessibility tree for
|
|
101
|
+
* @defaultValue The root node of the entire page.
|
|
102
|
+
*/
|
|
103
|
+
root?: ElementHandle;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The Accessibility class provides methods for inspecting Chromium's
|
|
107
|
+
* accessibility tree. The accessibility tree is used by assistive technology
|
|
108
|
+
* such as {@link https://en.wikipedia.org/wiki/Screen_reader | screen readers} or
|
|
109
|
+
* {@link https://en.wikipedia.org/wiki/Switch_access | switches}.
|
|
110
|
+
*
|
|
111
|
+
* @remarks
|
|
112
|
+
*
|
|
113
|
+
* Accessibility is a very platform-specific thing. On different platforms,
|
|
114
|
+
* there are different screen readers that might have wildly different output.
|
|
115
|
+
*
|
|
116
|
+
* Blink - Chrome's rendering engine - has a concept of "accessibility tree",
|
|
117
|
+
* which is then translated into different platform-specific APIs. Accessibility
|
|
118
|
+
* namespace gives users access to the Blink Accessibility Tree.
|
|
119
|
+
*
|
|
120
|
+
* Most of the accessibility tree gets filtered out when converting from Blink
|
|
121
|
+
* AX Tree to Platform-specific AX-Tree or by assistive technologies themselves.
|
|
122
|
+
* By default, Puppeteer tries to approximate this filtering, exposing only
|
|
123
|
+
* the "interesting" nodes of the tree.
|
|
124
|
+
*
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
export declare class Accessibility {
|
|
128
|
+
#private;
|
|
129
|
+
/**
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
constructor(client: CDPSession);
|
|
133
|
+
/**
|
|
134
|
+
* Captures the current state of the accessibility tree.
|
|
135
|
+
* The returned object represents the root accessible node of the page.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
*
|
|
139
|
+
* **NOTE** The Chromium accessibility tree contains nodes that go unused on
|
|
140
|
+
* most platforms and by most screen readers. Puppeteer will discard them as
|
|
141
|
+
* well for an easier to process tree, unless `interestingOnly` is set to
|
|
142
|
+
* `false`.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* An example of dumping the entire accessibility tree:
|
|
146
|
+
* ```js
|
|
147
|
+
* const snapshot = await page.accessibility.snapshot();
|
|
148
|
+
* console.log(snapshot);
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* An example of logging the focused node's name:
|
|
153
|
+
* ```js
|
|
154
|
+
* const snapshot = await page.accessibility.snapshot();
|
|
155
|
+
* const node = findFocusedNode(snapshot);
|
|
156
|
+
* console.log(node && node.name);
|
|
157
|
+
*
|
|
158
|
+
* function findFocusedNode(node) {
|
|
159
|
+
* if (node.focused)
|
|
160
|
+
* return node;
|
|
161
|
+
* for (const child of node.children || []) {
|
|
162
|
+
* const foundNode = findFocusedNode(child);
|
|
163
|
+
* return foundNode;
|
|
164
|
+
* }
|
|
165
|
+
* return null;
|
|
166
|
+
* }
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @returns An AXNode object representing the snapshot.
|
|
170
|
+
*
|
|
171
|
+
*/
|
|
172
|
+
snapshot(options?: SnapshotOptions): Promise<SerializedAXNode | null>;
|
|
173
|
+
private serializeTree;
|
|
174
|
+
private collectInterestingNodes;
|
|
175
|
+
}
|