@remotion/renderer 4.1.0-alpha2 → 4.1.0-alpha4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/get-video-stream-duration.d.ts +9 -0
- package/dist/assets/get-video-stream-duration.js +71 -0
- package/dist/browser/Browser.d.ts +7 -6
- package/dist/browser/Browser.js +12 -12
- package/dist/browser/BrowserPage.d.ts +13 -2
- package/dist/browser/BrowserPage.js +15 -8
- package/dist/browser/BrowserRunner.js +2 -2
- package/dist/browser/LaunchOptions.d.ts +2 -0
- package/dist/browser/Launcher.js +2 -1
- package/dist/browser/Target.d.ts +2 -1
- package/dist/browser/Target.js +3 -1
- package/dist/browser/should-log-message.js +8 -0
- package/dist/calculate-sar-dar-pixels.d.ts +9 -0
- package/dist/calculate-sar-dar-pixels.js +19 -0
- package/dist/compositor/compositor.d.ts +3 -2
- package/dist/compositor/compositor.js +6 -5
- package/dist/cycle-browser-tabs.d.ts +2 -1
- package/dist/cycle-browser-tabs.js +2 -2
- package/dist/determine-resize-params.d.ts +4 -0
- package/dist/determine-resize-params.js +10 -0
- package/dist/determine-vcodec-ffmpeg-flags.d.ts +2 -0
- package/dist/determine-vcodec-ffmpeg-flags.js +13 -0
- package/dist/ensure-ffmpeg.d.ts +18 -0
- package/dist/ensure-ffmpeg.js +58 -0
- package/dist/ensure-presentation-timestamp.d.ts +15 -0
- package/dist/ensure-presentation-timestamp.js +88 -0
- package/dist/extract-frame-from-video.d.ts +16 -0
- package/dist/extract-frame-from-video.js +191 -0
- package/dist/ffmpeg-executable.d.ts +1 -0
- package/dist/ffmpeg-executable.js +2 -0
- package/dist/ffmpeg-flags.d.ts +31 -0
- package/dist/ffmpeg-flags.js +245 -0
- package/dist/format-logs.d.ts +3 -0
- package/dist/format-logs.js +201 -0
- package/dist/frame-to-ffmpeg-timestamp.d.ts +1 -0
- package/dist/frame-to-ffmpeg-timestamp.js +8 -0
- package/dist/get-browser-instance.d.ts +3 -2
- package/dist/get-browser-instance.js +5 -5
- package/dist/get-can-extract-frames-fast.d.ts +14 -0
- package/dist/get-can-extract-frames-fast.js +71 -0
- package/dist/get-compositions.d.ts +4 -3
- package/dist/get-compositions.js +6 -5
- package/dist/get-frame-of-video-slow.d.ts +17 -0
- package/dist/get-frame-of-video-slow.js +72 -0
- package/dist/get-video-info.d.ts +8 -0
- package/dist/get-video-info.js +59 -0
- package/dist/index.d.ts +23 -25
- package/dist/is-beyond-last-frame.d.ts +3 -0
- package/dist/is-beyond-last-frame.js +12 -0
- package/dist/last-frame-from-video-cache.d.ts +17 -0
- package/dist/last-frame-from-video-cache.js +55 -0
- package/dist/legacy-webpack-config.d.ts +9 -0
- package/dist/legacy-webpack-config.js +13 -0
- package/dist/logger.d.ts +1 -2
- package/dist/logger.js +5 -10
- package/dist/offthread-video-server.d.ts +3 -2
- package/dist/offthread-video-server.js +4 -3
- package/dist/open-browser.d.ts +3 -2
- package/dist/open-browser.js +7 -5
- package/dist/perf.js +4 -2
- package/dist/prepare-server.d.ts +3 -2
- package/dist/prepare-server.js +4 -4
- package/dist/prespawn-ffmpeg.d.ts +2 -1
- package/dist/prespawn-ffmpeg.js +2 -30
- package/dist/quality.d.ts +1 -0
- package/dist/quality.js +21 -0
- package/dist/render-frames.d.ts +11 -4
- package/dist/render-frames.js +15 -11
- package/dist/render-media.d.ts +11 -4
- package/dist/render-media.js +12 -14
- package/dist/render-still.d.ts +8 -2
- package/dist/render-still.js +8 -8
- package/dist/replace-browser.d.ts +2 -1
- package/dist/replace-browser.js +2 -2
- package/dist/select-composition.d.ts +2 -1
- package/dist/select-composition.js +8 -8
- package/dist/serve-static.d.ts +2 -1
- package/dist/serve-static.js +1 -1
- package/dist/stitch-frames-to-video.d.ts +2 -1
- package/dist/stitch-frames-to-video.js +12 -22
- package/dist/try-to-extract-frame-of-video-fast.d.ts +12 -0
- package/dist/try-to-extract-frame-of-video-fast.js +55 -0
- package/dist/validate-ffmpeg.d.ts +7 -0
- package/dist/validate-ffmpeg.js +77 -0
- package/dist/warn-about-ffmpeg-version.d.ts +5 -0
- package/dist/warn-about-ffmpeg-version.js +37 -0
- package/package.json +9 -9
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatObjectPreview = exports.formatRemoteObject = void 0;
|
|
4
|
+
const chalk_1 = require("./chalk");
|
|
5
|
+
const formatRemoteObject = (remoteObject) => {
|
|
6
|
+
if (remoteObject.preview) {
|
|
7
|
+
return (0, exports.formatObjectPreview)(remoteObject.preview);
|
|
8
|
+
}
|
|
9
|
+
if (remoteObject.type === 'string') {
|
|
10
|
+
return chalk_1.chalk.reset(`${remoteObject.value}`);
|
|
11
|
+
}
|
|
12
|
+
if (remoteObject.type === 'number') {
|
|
13
|
+
return chalk_1.chalk.yellow(`${remoteObject.value}`);
|
|
14
|
+
}
|
|
15
|
+
if (remoteObject.type === 'bigint') {
|
|
16
|
+
return chalk_1.chalk.yellow(`${remoteObject.description}`);
|
|
17
|
+
}
|
|
18
|
+
if (remoteObject.type === 'boolean') {
|
|
19
|
+
return chalk_1.chalk.yellow(`${remoteObject.value}`);
|
|
20
|
+
}
|
|
21
|
+
if (remoteObject.type === 'function') {
|
|
22
|
+
return chalk_1.chalk.cyan(String(remoteObject.description));
|
|
23
|
+
}
|
|
24
|
+
if (remoteObject.type === 'object') {
|
|
25
|
+
if (remoteObject.subtype === 'null') {
|
|
26
|
+
return chalk_1.chalk.white(`null`);
|
|
27
|
+
}
|
|
28
|
+
return chalk_1.chalk.reset(`Object`);
|
|
29
|
+
}
|
|
30
|
+
if (remoteObject.type === 'symbol') {
|
|
31
|
+
return chalk_1.chalk.green(`${remoteObject.description}`);
|
|
32
|
+
}
|
|
33
|
+
if (remoteObject.type === 'undefined') {
|
|
34
|
+
return chalk_1.chalk.gray(`undefined`);
|
|
35
|
+
}
|
|
36
|
+
throw new Error('unhandled remote object');
|
|
37
|
+
};
|
|
38
|
+
exports.formatRemoteObject = formatRemoteObject;
|
|
39
|
+
const formatObjectPreview = (preview) => {
|
|
40
|
+
if (typeof preview === 'undefined') {
|
|
41
|
+
return '';
|
|
42
|
+
}
|
|
43
|
+
if (preview.type === 'object') {
|
|
44
|
+
if (preview.subtype === 'date') {
|
|
45
|
+
return chalk_1.chalk.reset(`Date { ${chalk_1.chalk.magenta(String(preview.description))} }`);
|
|
46
|
+
}
|
|
47
|
+
const properties = preview.properties.map((property) => {
|
|
48
|
+
return `${property.name}: ${formatProperty(property)}`;
|
|
49
|
+
});
|
|
50
|
+
if (preview.subtype === 'array') {
|
|
51
|
+
return chalk_1.chalk.reset(`[ ${preview.properties.map((p) => formatProperty(p)).join(', ')} ]`);
|
|
52
|
+
}
|
|
53
|
+
if (preview.subtype === 'arraybuffer') {
|
|
54
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
55
|
+
}
|
|
56
|
+
if (preview.subtype === 'dataview') {
|
|
57
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
58
|
+
}
|
|
59
|
+
if (preview.subtype === 'generator') {
|
|
60
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
61
|
+
}
|
|
62
|
+
if (preview.subtype === 'iterator') {
|
|
63
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
64
|
+
}
|
|
65
|
+
if (preview.subtype === 'map') {
|
|
66
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
67
|
+
}
|
|
68
|
+
if (preview.subtype === 'node') {
|
|
69
|
+
return chalk_1.chalk.magenta(`<${preview.description}>`);
|
|
70
|
+
}
|
|
71
|
+
if (preview.subtype === 'null') {
|
|
72
|
+
return chalk_1.chalk.white(String(preview.description));
|
|
73
|
+
}
|
|
74
|
+
if (preview.subtype === 'promise') {
|
|
75
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
76
|
+
}
|
|
77
|
+
if (preview.subtype === 'proxy') {
|
|
78
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
79
|
+
}
|
|
80
|
+
if (preview.subtype === 'regexp') {
|
|
81
|
+
return chalk_1.chalk.red(String(preview.description));
|
|
82
|
+
}
|
|
83
|
+
if (preview.subtype === 'set') {
|
|
84
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
85
|
+
}
|
|
86
|
+
if (preview.subtype === 'typedarray') {
|
|
87
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
88
|
+
}
|
|
89
|
+
if (preview.subtype === 'error') {
|
|
90
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
91
|
+
}
|
|
92
|
+
if (preview.subtype === 'wasmvalue') {
|
|
93
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
94
|
+
}
|
|
95
|
+
if (preview.subtype === 'weakmap') {
|
|
96
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
97
|
+
}
|
|
98
|
+
if (preview.subtype === 'weakset') {
|
|
99
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
100
|
+
}
|
|
101
|
+
if (preview.subtype === 'webassemblymemory') {
|
|
102
|
+
return chalk_1.chalk.reset(String(preview.description));
|
|
103
|
+
}
|
|
104
|
+
if (properties.length === 0) {
|
|
105
|
+
return chalk_1.chalk.reset('{}');
|
|
106
|
+
}
|
|
107
|
+
return chalk_1.chalk.reset(`{ ${properties.join(', ')} }`);
|
|
108
|
+
}
|
|
109
|
+
return '';
|
|
110
|
+
};
|
|
111
|
+
exports.formatObjectPreview = formatObjectPreview;
|
|
112
|
+
const formatProperty = (property) => {
|
|
113
|
+
if (property.type === 'string') {
|
|
114
|
+
return chalk_1.chalk.green(`"${property.value}"`);
|
|
115
|
+
}
|
|
116
|
+
if (property.type === 'object') {
|
|
117
|
+
if (!property.subtype && property.value === 'Object') {
|
|
118
|
+
return chalk_1.chalk.reset(`{…}`);
|
|
119
|
+
}
|
|
120
|
+
if (property.subtype === 'date') {
|
|
121
|
+
return chalk_1.chalk.reset(`Date { ${chalk_1.chalk.magenta(String(property.value))} }`);
|
|
122
|
+
}
|
|
123
|
+
if (property.subtype === 'arraybuffer') {
|
|
124
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
125
|
+
}
|
|
126
|
+
if (property.subtype === 'array') {
|
|
127
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
128
|
+
}
|
|
129
|
+
if (property.subtype === 'dataview') {
|
|
130
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
131
|
+
}
|
|
132
|
+
if (property.subtype === 'error') {
|
|
133
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
134
|
+
}
|
|
135
|
+
if (property.subtype === 'generator') {
|
|
136
|
+
return chalk_1.chalk.reset(`[generator ${property.value}]`);
|
|
137
|
+
}
|
|
138
|
+
if (property.subtype === 'iterator') {
|
|
139
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
140
|
+
}
|
|
141
|
+
if (property.subtype === 'map') {
|
|
142
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
143
|
+
}
|
|
144
|
+
if (property.subtype === 'node') {
|
|
145
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
146
|
+
}
|
|
147
|
+
if (property.subtype === 'null') {
|
|
148
|
+
return chalk_1.chalk.white(`${property.value}`);
|
|
149
|
+
}
|
|
150
|
+
if (property.subtype === 'promise') {
|
|
151
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
152
|
+
}
|
|
153
|
+
if (property.subtype === 'proxy') {
|
|
154
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
155
|
+
}
|
|
156
|
+
if (property.subtype === 'regexp') {
|
|
157
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
158
|
+
}
|
|
159
|
+
if (property.subtype === 'set') {
|
|
160
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
161
|
+
}
|
|
162
|
+
if (property.subtype === 'typedarray') {
|
|
163
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
164
|
+
}
|
|
165
|
+
if (property.subtype === 'wasmvalue') {
|
|
166
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
167
|
+
}
|
|
168
|
+
if (property.subtype === 'webassemblymemory') {
|
|
169
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
170
|
+
}
|
|
171
|
+
if (property.subtype === 'weakmap') {
|
|
172
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
173
|
+
}
|
|
174
|
+
if (property.subtype === 'weakset') {
|
|
175
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
176
|
+
}
|
|
177
|
+
return chalk_1.chalk.reset(`${property.value}`);
|
|
178
|
+
}
|
|
179
|
+
if (property.type === 'accessor') {
|
|
180
|
+
return chalk_1.chalk.gray(`get()`);
|
|
181
|
+
}
|
|
182
|
+
if (property.type === 'bigint') {
|
|
183
|
+
return chalk_1.chalk.yellow(`${property.value}`);
|
|
184
|
+
}
|
|
185
|
+
if (property.type === 'boolean') {
|
|
186
|
+
return chalk_1.chalk.yellow(`${property.value}`);
|
|
187
|
+
}
|
|
188
|
+
if (property.type === 'function') {
|
|
189
|
+
return chalk_1.chalk.cyan(`Function`);
|
|
190
|
+
}
|
|
191
|
+
if (property.type === 'number') {
|
|
192
|
+
return chalk_1.chalk.yellow(`${property.value}`);
|
|
193
|
+
}
|
|
194
|
+
if (property.type === 'symbol') {
|
|
195
|
+
return chalk_1.chalk.green(`${property.value}`);
|
|
196
|
+
}
|
|
197
|
+
if (property.type === 'undefined') {
|
|
198
|
+
return chalk_1.chalk.gray(`undefined`);
|
|
199
|
+
}
|
|
200
|
+
throw new Error('unexpected property type ' + JSON.stringify(property));
|
|
201
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const frameToFfmpegTimestamp: (time: number) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.frameToFfmpegTimestamp = void 0;
|
|
4
|
+
const frameToFfmpegTimestamp = (time) => {
|
|
5
|
+
// We ceil because FFMPEG seeks to the closest frame BEFORE the position
|
|
6
|
+
return (Math.ceil(time * 1000000) / 1000).toFixed(3) + 'ms';
|
|
7
|
+
};
|
|
8
|
+
exports.frameToFfmpegTimestamp = frameToFfmpegTimestamp;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { BrowserExecutable } from './browser-executable';
|
|
2
2
|
import type { HeadlessBrowser } from './browser/Browser';
|
|
3
3
|
import type { Page } from './browser/BrowserPage';
|
|
4
|
+
import type { LogLevel } from './log-level';
|
|
4
5
|
import type { ChromiumOptions } from './open-browser';
|
|
5
6
|
import type { AnySourceMapConsumer } from './symbolicate-stacktrace';
|
|
6
|
-
export declare const getPageAndCleanupFn: ({ passedInInstance, browserExecutable, chromiumOptions, context, forceDeviceScaleFactor, indent,
|
|
7
|
+
export declare const getPageAndCleanupFn: ({ passedInInstance, browserExecutable, chromiumOptions, context, forceDeviceScaleFactor, indent, logLevel, }: {
|
|
7
8
|
passedInInstance: HeadlessBrowser | undefined;
|
|
8
9
|
browserExecutable: BrowserExecutable | null;
|
|
9
10
|
chromiumOptions: ChromiumOptions;
|
|
10
11
|
context: AnySourceMapConsumer | null;
|
|
11
12
|
indent: boolean;
|
|
12
13
|
forceDeviceScaleFactor: number | undefined;
|
|
13
|
-
|
|
14
|
+
logLevel: LogLevel;
|
|
14
15
|
}) => Promise<{
|
|
15
16
|
cleanup: () => void;
|
|
16
17
|
page: Page;
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getPageAndCleanupFn = void 0;
|
|
4
4
|
const browser_1 = require("./browser");
|
|
5
5
|
const open_browser_1 = require("./open-browser");
|
|
6
|
-
const getPageAndCleanupFn = async ({ passedInInstance, browserExecutable, chromiumOptions, context, forceDeviceScaleFactor, indent,
|
|
6
|
+
const getPageAndCleanupFn = async ({ passedInInstance, browserExecutable, chromiumOptions, context, forceDeviceScaleFactor, indent, logLevel, }) => {
|
|
7
7
|
if (passedInInstance) {
|
|
8
|
-
const page = await passedInInstance.newPage(context);
|
|
8
|
+
const page = await passedInInstance.newPage(context, logLevel, indent);
|
|
9
9
|
return {
|
|
10
10
|
page,
|
|
11
11
|
cleanup: () => {
|
|
@@ -23,15 +23,15 @@ const getPageAndCleanupFn = async ({ passedInInstance, browserExecutable, chromi
|
|
|
23
23
|
chromiumOptions,
|
|
24
24
|
forceDeviceScaleFactor,
|
|
25
25
|
indent,
|
|
26
|
-
shouldDumpIo,
|
|
27
26
|
viewport: null,
|
|
27
|
+
logLevel,
|
|
28
28
|
});
|
|
29
|
-
const browserPage = await browserInstance.newPage(context);
|
|
29
|
+
const browserPage = await browserInstance.newPage(context, logLevel, indent);
|
|
30
30
|
return {
|
|
31
31
|
page: browserPage,
|
|
32
32
|
cleanup: () => {
|
|
33
33
|
// Close whole browser that was just created and don't wait for it to finish.
|
|
34
|
-
browserInstance.close(true).catch((err) => {
|
|
34
|
+
browserInstance.close(true, logLevel, indent).catch((err) => {
|
|
35
35
|
console.error('Was not able to close puppeteer page', err);
|
|
36
36
|
});
|
|
37
37
|
},
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FfmpegExecutable } from './ffmpeg-executable';
|
|
2
|
+
export declare const ACCEPTABLE_OFFSET_THRESHOLD = 50;
|
|
3
|
+
/**
|
|
4
|
+
* @description Probes whether frames of a video can be efficiently extracted when using <OffthreadVideo>.
|
|
5
|
+
* @see [Documentation](https://www.remotion.dev/docs/renderer/get-can-extract-frames-fast)
|
|
6
|
+
*/
|
|
7
|
+
export declare const getCanExtractFramesFast: ({ src, ffmpegExecutable, ffprobeExecutable, }: {
|
|
8
|
+
src: string;
|
|
9
|
+
ffmpegExecutable?: FfmpegExecutable | undefined;
|
|
10
|
+
ffprobeExecutable?: FfmpegExecutable | undefined;
|
|
11
|
+
}) => Promise<{
|
|
12
|
+
canExtractFramesFast: boolean;
|
|
13
|
+
shouldReencode: boolean;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,71 @@
|
|
|
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.getCanExtractFramesFast = exports.ACCEPTABLE_OFFSET_THRESHOLD = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const get_video_stream_duration_1 = require("./assets/get-video-stream-duration");
|
|
9
|
+
const ensure_presentation_timestamp_1 = require("./ensure-presentation-timestamp");
|
|
10
|
+
const find_closest_package_json_1 = require("./find-closest-package-json");
|
|
11
|
+
const get_video_info_1 = require("./get-video-info");
|
|
12
|
+
const try_to_extract_frame_of_video_fast_1 = require("./try-to-extract-frame-of-video-fast");
|
|
13
|
+
exports.ACCEPTABLE_OFFSET_THRESHOLD = 50;
|
|
14
|
+
/**
|
|
15
|
+
* @description Probes whether frames of a video can be efficiently extracted when using <OffthreadVideo>.
|
|
16
|
+
* @see [Documentation](https://www.remotion.dev/docs/renderer/get-can-extract-frames-fast)
|
|
17
|
+
*/
|
|
18
|
+
const getCanExtractFramesFast = async ({ src, ffmpegExecutable, ffprobeExecutable, }) => {
|
|
19
|
+
const remotionRoot = (0, find_closest_package_json_1.findRemotionRoot)();
|
|
20
|
+
const out = await (0, ensure_presentation_timestamp_1.ensurePresentationTimestampWithoutCache)({
|
|
21
|
+
ffmpegExecutable: ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : null,
|
|
22
|
+
ffprobeExecutable: ffprobeExecutable !== null && ffprobeExecutable !== void 0 ? ffprobeExecutable : null,
|
|
23
|
+
remotionRoot,
|
|
24
|
+
src,
|
|
25
|
+
});
|
|
26
|
+
const { specialVcodecForTransparency: specialVcodec } = await (0, get_video_info_1.getVideoInfoUncached)({
|
|
27
|
+
src: out,
|
|
28
|
+
ffprobeExecutable: ffprobeExecutable !== null && ffprobeExecutable !== void 0 ? ffprobeExecutable : null,
|
|
29
|
+
remotionRoot,
|
|
30
|
+
});
|
|
31
|
+
if (specialVcodec === 'vp8') {
|
|
32
|
+
fs_1.default.unlinkSync(out);
|
|
33
|
+
return {
|
|
34
|
+
canExtractFramesFast: false,
|
|
35
|
+
shouldReencode: false,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const { duration } = await (0, get_video_stream_duration_1.getVideoStreamDurationwithoutCache)({
|
|
39
|
+
ffprobeExecutable: ffprobeExecutable !== null && ffprobeExecutable !== void 0 ? ffprobeExecutable : null,
|
|
40
|
+
remotionRoot,
|
|
41
|
+
src: out,
|
|
42
|
+
});
|
|
43
|
+
if (duration === null) {
|
|
44
|
+
fs_1.default.unlinkSync(out);
|
|
45
|
+
throw new Error(`Could not determine the duration of ${src} using FFMPEG. The file is not supported.`);
|
|
46
|
+
}
|
|
47
|
+
const actualOffset = `${duration * 1000 - exports.ACCEPTABLE_OFFSET_THRESHOLD}ms`;
|
|
48
|
+
const [stdErr] = await (0, try_to_extract_frame_of_video_fast_1.tryToExtractFrameOfVideoFast)({
|
|
49
|
+
actualOffset,
|
|
50
|
+
ffmpegExecutable: ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : null,
|
|
51
|
+
imageFormat: 'jpeg',
|
|
52
|
+
// Intentionally leaving needsResize as null, because we don't need to resize
|
|
53
|
+
needsResize: null,
|
|
54
|
+
remotionRoot,
|
|
55
|
+
specialVCodecForTransparency: specialVcodec,
|
|
56
|
+
src: out,
|
|
57
|
+
});
|
|
58
|
+
fs_1.default.unlinkSync(out);
|
|
59
|
+
const isEmpty = stdErr.includes('Output file is empty');
|
|
60
|
+
if (isEmpty) {
|
|
61
|
+
return {
|
|
62
|
+
canExtractFramesFast: false,
|
|
63
|
+
shouldReencode: true,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
canExtractFramesFast: true,
|
|
68
|
+
shouldReencode: false,
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
exports.getCanExtractFramesFast = getCanExtractFramesFast;
|
|
@@ -4,6 +4,7 @@ import type { BrowserLog } from './browser-log';
|
|
|
4
4
|
import type { HeadlessBrowser } from './browser/Browser';
|
|
5
5
|
import type { ChromiumOptions } from './open-browser';
|
|
6
6
|
import type { RemotionServer } from './prepare-server';
|
|
7
|
+
import { type LogLevel } from './log-level';
|
|
7
8
|
type InternalGetCompositionsOptions = {
|
|
8
9
|
inputProps: Record<string, unknown>;
|
|
9
10
|
envVariables: Record<string, string>;
|
|
@@ -15,7 +16,7 @@ type InternalGetCompositionsOptions = {
|
|
|
15
16
|
port: number | null;
|
|
16
17
|
server: RemotionServer | undefined;
|
|
17
18
|
indent: boolean;
|
|
18
|
-
|
|
19
|
+
logLevel: LogLevel;
|
|
19
20
|
serveUrlOrWebpackUrl: string;
|
|
20
21
|
};
|
|
21
22
|
export type GetCompositionsOptions = {
|
|
@@ -27,9 +28,9 @@ export type GetCompositionsOptions = {
|
|
|
27
28
|
timeoutInMilliseconds?: number;
|
|
28
29
|
chromiumOptions?: ChromiumOptions;
|
|
29
30
|
port?: number | null;
|
|
30
|
-
|
|
31
|
+
logLevel?: LogLevel;
|
|
31
32
|
};
|
|
32
|
-
export declare const internalGetCompositions: ({ browserExecutable, chromiumOptions, envVariables, indent, inputProps, onBrowserLog, port, puppeteerInstance, serveUrlOrWebpackUrl, server, timeoutInMilliseconds,
|
|
33
|
+
export declare const internalGetCompositions: ({ browserExecutable, chromiumOptions, envVariables, indent, inputProps, onBrowserLog, port, puppeteerInstance, serveUrlOrWebpackUrl, server, timeoutInMilliseconds, logLevel, }: InternalGetCompositionsOptions) => Promise<AnyCompMetadata[]>;
|
|
33
34
|
/**
|
|
34
35
|
* @description Gets the compositions defined in a Remotion project based on a Webpack bundle.
|
|
35
36
|
* @see [Documentation](https://www.remotion.dev/docs/renderer/get-compositions)
|
package/dist/get-compositions.js
CHANGED
|
@@ -10,6 +10,7 @@ const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
|
|
|
10
10
|
const seek_to_frame_1 = require("./seek-to-frame");
|
|
11
11
|
const set_props_and_env_1 = require("./set-props-and-env");
|
|
12
12
|
const validate_puppeteer_timeout_1 = require("./validate-puppeteer-timeout");
|
|
13
|
+
const logger_1 = require("./logger");
|
|
13
14
|
const innerGetCompositions = async ({ envVariables, inputProps, onBrowserLog, page, proxyPort, serveUrl, timeoutInMilliseconds, }) => {
|
|
14
15
|
if (onBrowserLog) {
|
|
15
16
|
page.on('console', (log) => {
|
|
@@ -54,7 +55,7 @@ const innerGetCompositions = async ({ envVariables, inputProps, onBrowserLog, pa
|
|
|
54
55
|
});
|
|
55
56
|
return result;
|
|
56
57
|
};
|
|
57
|
-
const internalGetCompositions = async ({ browserExecutable, chromiumOptions, envVariables, indent, inputProps, onBrowserLog, port, puppeteerInstance, serveUrlOrWebpackUrl, server, timeoutInMilliseconds,
|
|
58
|
+
const internalGetCompositions = async ({ browserExecutable, chromiumOptions, envVariables, indent, inputProps, onBrowserLog, port, puppeteerInstance, serveUrlOrWebpackUrl, server, timeoutInMilliseconds, logLevel, }) => {
|
|
58
59
|
const { page, cleanup: cleanupPage } = await (0, get_browser_instance_1.getPageAndCleanupFn)({
|
|
59
60
|
passedInInstance: puppeteerInstance,
|
|
60
61
|
browserExecutable,
|
|
@@ -62,7 +63,7 @@ const internalGetCompositions = async ({ browserExecutable, chromiumOptions, env
|
|
|
62
63
|
context: null,
|
|
63
64
|
forceDeviceScaleFactor: undefined,
|
|
64
65
|
indent,
|
|
65
|
-
|
|
66
|
+
logLevel,
|
|
66
67
|
});
|
|
67
68
|
const cleanup = [cleanupPage];
|
|
68
69
|
return new Promise((resolve, reject) => {
|
|
@@ -77,7 +78,7 @@ const internalGetCompositions = async ({ browserExecutable, chromiumOptions, env
|
|
|
77
78
|
port,
|
|
78
79
|
remotionRoot: (0, find_closest_package_json_1.findRemotionRoot)(),
|
|
79
80
|
concurrency: 1,
|
|
80
|
-
|
|
81
|
+
logLevel,
|
|
81
82
|
indent,
|
|
82
83
|
}, {
|
|
83
84
|
onDownload: () => undefined,
|
|
@@ -115,7 +116,7 @@ exports.internalGetCompositions = internalGetCompositions;
|
|
|
115
116
|
* @see [Documentation](https://www.remotion.dev/docs/renderer/get-compositions)
|
|
116
117
|
*/
|
|
117
118
|
const getCompositions = (serveUrlOrWebpackUrl, config) => {
|
|
118
|
-
const { browserExecutable, chromiumOptions, envVariables, inputProps, onBrowserLog, port, puppeteerInstance, timeoutInMilliseconds,
|
|
119
|
+
const { browserExecutable, chromiumOptions, envVariables, inputProps, onBrowserLog, port, puppeteerInstance, timeoutInMilliseconds, logLevel, } = config !== null && config !== void 0 ? config : {};
|
|
119
120
|
return (0, exports.internalGetCompositions)({
|
|
120
121
|
browserExecutable: browserExecutable !== null && browserExecutable !== void 0 ? browserExecutable : null,
|
|
121
122
|
chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
|
|
@@ -128,7 +129,7 @@ const getCompositions = (serveUrlOrWebpackUrl, config) => {
|
|
|
128
129
|
serveUrlOrWebpackUrl,
|
|
129
130
|
server: undefined,
|
|
130
131
|
timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : TimeoutSettings_1.DEFAULT_TIMEOUT,
|
|
131
|
-
|
|
132
|
+
logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : (0, logger_1.getLogLevel)(),
|
|
132
133
|
});
|
|
133
134
|
};
|
|
134
135
|
exports.getCompositions = getCompositions;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OffthreadVideoImageFormat } from 'remotion';
|
|
2
|
+
import type { SpecialVCodecForTransparency } from './assets/download-map';
|
|
3
|
+
import type { FfmpegExecutable } from './ffmpeg-executable';
|
|
4
|
+
export declare const getFrameOfVideoSlow: ({ src, duration, ffmpegExecutable, imageFormat, specialVCodecForTransparency, needsResize, offset, fps, remotionRoot, }: {
|
|
5
|
+
ffmpegExecutable: FfmpegExecutable;
|
|
6
|
+
src: string;
|
|
7
|
+
duration: number;
|
|
8
|
+
imageFormat: OffthreadVideoImageFormat;
|
|
9
|
+
specialVCodecForTransparency: SpecialVCodecForTransparency;
|
|
10
|
+
needsResize: [
|
|
11
|
+
number,
|
|
12
|
+
number
|
|
13
|
+
] | null;
|
|
14
|
+
offset: number;
|
|
15
|
+
fps: number | null;
|
|
16
|
+
remotionRoot: string;
|
|
17
|
+
}) => Promise<Buffer>;
|
|
@@ -0,0 +1,72 @@
|
|
|
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.getFrameOfVideoSlow = void 0;
|
|
7
|
+
// Uses no seeking, therefore the whole video has to be decoded. This is a last resort and should only happen
|
|
8
|
+
// if the video is corrupted
|
|
9
|
+
const execa_1 = __importDefault(require("execa"));
|
|
10
|
+
const determine_resize_params_1 = require("./determine-resize-params");
|
|
11
|
+
const determine_vcodec_ffmpeg_flags_1 = require("./determine-vcodec-ffmpeg-flags");
|
|
12
|
+
const ffmpeg_flags_1 = require("./ffmpeg-flags");
|
|
13
|
+
const truthy_1 = require("./truthy");
|
|
14
|
+
const getFrameOfVideoSlow = async ({ src, duration, ffmpegExecutable, imageFormat, specialVCodecForTransparency, needsResize, offset, fps, remotionRoot, }) => {
|
|
15
|
+
console.warn(`\nUsing a slow method to extract the frame at ${duration}ms of ${src}. See https://remotion.dev/docs/slow-method-to-extract-frame for advice`);
|
|
16
|
+
const actualOffset = `-${duration * 1000 - offset}ms`;
|
|
17
|
+
const command = [
|
|
18
|
+
'-itsoffset',
|
|
19
|
+
actualOffset,
|
|
20
|
+
...(0, determine_vcodec_ffmpeg_flags_1.determineVcodecFfmpegFlags)(specialVCodecForTransparency),
|
|
21
|
+
'-i',
|
|
22
|
+
src,
|
|
23
|
+
'-frames:v',
|
|
24
|
+
'1',
|
|
25
|
+
'-c:v',
|
|
26
|
+
imageFormat === 'jpeg' ? 'mjpeg' : 'png',
|
|
27
|
+
'-f',
|
|
28
|
+
'image2pipe',
|
|
29
|
+
...(0, determine_resize_params_1.determineResizeParams)(needsResize),
|
|
30
|
+
'-',
|
|
31
|
+
].filter(truthy_1.truthy);
|
|
32
|
+
const { stdout, stderr } = (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)(ffmpegExecutable, remotionRoot, 'ffmpeg'), command);
|
|
33
|
+
if (!stderr) {
|
|
34
|
+
throw new Error('unexpectedly did not get stderr');
|
|
35
|
+
}
|
|
36
|
+
if (!stdout) {
|
|
37
|
+
throw new Error('unexpectedly did not get stdout');
|
|
38
|
+
}
|
|
39
|
+
const stderrChunks = [];
|
|
40
|
+
const stdoutChunks = [];
|
|
41
|
+
const stdErrString = new Promise((resolve, reject) => {
|
|
42
|
+
stderr.on('data', (d) => stderrChunks.push(d));
|
|
43
|
+
stderr.on('error', (err) => reject(err));
|
|
44
|
+
stderr.on('end', () => resolve(Buffer.concat(stderrChunks).toString('utf-8')));
|
|
45
|
+
});
|
|
46
|
+
const stdoutChunk = new Promise((resolve, reject) => {
|
|
47
|
+
stdout.on('data', (d) => stdoutChunks.push(d));
|
|
48
|
+
stdout.on('error', (err) => reject(err));
|
|
49
|
+
stdout.on('end', () => resolve(Buffer.concat(stdoutChunks)));
|
|
50
|
+
});
|
|
51
|
+
const [stdErr, stdoutBuffer] = await Promise.all([stdErrString, stdoutChunk]);
|
|
52
|
+
const isEmpty = stdErr.includes('Output file is empty');
|
|
53
|
+
if (isEmpty) {
|
|
54
|
+
if (offset > 70) {
|
|
55
|
+
throw new Error(`Could not get last frame of ${src}. Tried to seek to the end using the command "ffmpeg ${command.join(' ')}" but got no frame. Most likely this video is corrupted.`);
|
|
56
|
+
}
|
|
57
|
+
return (0, exports.getFrameOfVideoSlow)({
|
|
58
|
+
ffmpegExecutable,
|
|
59
|
+
duration,
|
|
60
|
+
// Decrement in 10ms increments, or 1 frame (e.g. fps = 25 --> 40ms)
|
|
61
|
+
offset: offset + (fps === null ? 10 : 1000 / fps),
|
|
62
|
+
src,
|
|
63
|
+
imageFormat,
|
|
64
|
+
specialVCodecForTransparency,
|
|
65
|
+
needsResize,
|
|
66
|
+
fps,
|
|
67
|
+
remotionRoot,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return stdoutBuffer;
|
|
71
|
+
};
|
|
72
|
+
exports.getFrameOfVideoSlow = getFrameOfVideoSlow;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DownloadMap, Vp9Result } from './assets/download-map';
|
|
2
|
+
import type { FfmpegExecutable } from './ffmpeg-executable';
|
|
3
|
+
export declare function getVideoInfoUncached({ src, ffprobeExecutable, remotionRoot, }: {
|
|
4
|
+
src: string;
|
|
5
|
+
ffprobeExecutable: FfmpegExecutable;
|
|
6
|
+
remotionRoot: string;
|
|
7
|
+
}): Promise<Vp9Result>;
|
|
8
|
+
export declare const getVideoInfo: (downloadMap: DownloadMap, src: string, ffprobeExecutable: FfmpegExecutable, remotionRoot: string) => Promise<Vp9Result>;
|
|
@@ -0,0 +1,59 @@
|
|
|
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.getVideoInfo = exports.getVideoInfoUncached = void 0;
|
|
7
|
+
const execa_1 = __importDefault(require("execa"));
|
|
8
|
+
const calculate_sar_dar_pixels_1 = require("./calculate-sar-dar-pixels");
|
|
9
|
+
const ffmpeg_flags_1 = require("./ffmpeg-flags");
|
|
10
|
+
const p_limit_1 = require("./p-limit");
|
|
11
|
+
const limit = (0, p_limit_1.pLimit)(1);
|
|
12
|
+
async function getVideoInfoUncached({ src, ffprobeExecutable, remotionRoot, }) {
|
|
13
|
+
var _a;
|
|
14
|
+
const task = await (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)(ffprobeExecutable, remotionRoot, 'ffprobe'), [src]);
|
|
15
|
+
const isVp9 = task.stderr.includes('Video: vp9');
|
|
16
|
+
const isVp8 = task.stderr.includes('Video: vp8');
|
|
17
|
+
const dimensions = (_a = task.stderr
|
|
18
|
+
.split('\n')
|
|
19
|
+
.find((n) => n.trim().startsWith('Stream #'))) === null || _a === void 0 ? void 0 : _a.match(/([0-9]{2,6})x([0-9]{2,6})/);
|
|
20
|
+
const dar = task.stderr.match(/DAR\s([0-9]+):([0-9]+)/);
|
|
21
|
+
let needsResize = null;
|
|
22
|
+
if (dimensions && dar) {
|
|
23
|
+
const width = parseInt(dimensions[1], 10);
|
|
24
|
+
const height = parseInt(dimensions[2], 10);
|
|
25
|
+
const darWidth = parseInt(dar[1], 10);
|
|
26
|
+
const darHeight = parseInt(dar[2], 10);
|
|
27
|
+
const { width: actualWidth, height: actualHeight } = (0, calculate_sar_dar_pixels_1.calculateDisplayVideoSize)({
|
|
28
|
+
darX: darWidth,
|
|
29
|
+
darY: darHeight,
|
|
30
|
+
x: width,
|
|
31
|
+
y: height,
|
|
32
|
+
});
|
|
33
|
+
if (actualWidth !== width || actualHeight !== height) {
|
|
34
|
+
needsResize = [actualWidth, actualHeight];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const result = {
|
|
38
|
+
specialVcodecForTransparency: isVp9 ? 'vp9' : isVp8 ? 'vp8' : 'none',
|
|
39
|
+
needsResize,
|
|
40
|
+
};
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
exports.getVideoInfoUncached = getVideoInfoUncached;
|
|
44
|
+
async function getVideoInfoUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot) {
|
|
45
|
+
if (typeof downloadMap.isVp9VideoCache[src] !== 'undefined') {
|
|
46
|
+
return downloadMap.isVp9VideoCache[src];
|
|
47
|
+
}
|
|
48
|
+
const result = await getVideoInfoUncached({
|
|
49
|
+
ffprobeExecutable,
|
|
50
|
+
remotionRoot,
|
|
51
|
+
src,
|
|
52
|
+
});
|
|
53
|
+
downloadMap.isVp9VideoCache[src] = result;
|
|
54
|
+
return downloadMap.isVp9VideoCache[src];
|
|
55
|
+
}
|
|
56
|
+
const getVideoInfo = (downloadMap, src, ffprobeExecutable, remotionRoot) => {
|
|
57
|
+
return limit(() => getVideoInfoUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot));
|
|
58
|
+
};
|
|
59
|
+
exports.getVideoInfo = getVideoInfo;
|