@remotion/renderer 3.3.38 → 3.3.40
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/client.d.ts +8 -1
- package/dist/client.js +12 -0
- package/dist/compositor/compositor.d.ts +12 -0
- package/dist/compositor/compositor.js +96 -0
- package/dist/determine-vcodec-ffmepg-flags.d.ts +2 -0
- package/dist/determine-vcodec-ffmepg-flags.js +13 -0
- package/dist/get-compositions-from-bundle.d.ts +7 -0
- package/dist/get-compositions-from-bundle.js +55 -0
- package/dist/get-compositions-from-markup.d.ts +3 -0
- package/dist/get-compositions-from-markup.js +17 -0
- package/dist/get-compositions-on-server.d.ts +3 -0
- package/dist/get-compositions-on-server.js +18 -0
- package/dist/get-video-signals.d.ts +2 -0
- package/dist/get-video-signals.js +28 -0
- package/dist/lock-port-selection.d.ts +2 -0
- package/dist/lock-port-selection.js +11 -0
- package/dist/make-comp-manager-context.d.ts +2 -0
- package/dist/make-comp-manager-context.js +45 -0
- package/dist/make-timeline-context-value.d.ts +2 -0
- package/dist/make-timeline-context-value.js +20 -0
- package/dist/puppeteer-evaluate.js +19 -11
- package/dist/render-on-server.d.ts +3 -0
- package/dist/render-on-server.js +90 -0
- package/dist/render-svg.d.ts +8 -0
- package/dist/render-svg.js +13 -0
- package/dist/render-video-layer.d.ts +9 -0
- package/dist/render-video-layer.js +23 -0
- package/dist/render-web-frame.d.ts +74 -0
- package/dist/render-web-frame.js +260 -0
- package/dist/ws/ws-types.js +2 -1
- package/package.json +10 -10
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
export declare const BrowserSafeApis: {
|
|
2
|
-
getFileExtensionFromCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif"
|
|
2
|
+
getFileExtensionFromCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => "mp3" | "aac" | "wav" | "gif" | "mp4" | "mkv" | "mov" | "webm";
|
|
3
|
+
validCodecs: readonly ["h264", "h265", "vp8", "vp9", "mp3", "aac", "wav", "prores", "h264-mkv", "gif"];
|
|
4
|
+
getDefaultCrfForCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => number;
|
|
5
|
+
getValidCrfRanges: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => [number, number];
|
|
6
|
+
isAudioCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif" | undefined) => boolean;
|
|
7
|
+
proResProfileOptions: readonly ["4444-xq", "4444", "hq", "standard", "light", "proxy"];
|
|
8
|
+
validPixelFormats: readonly ["yuv420p", "yuva420p", "yuv422p", "yuv444p", "yuv420p10le", "yuv422p10le", "yuv444p10le", "yuva444p10le"];
|
|
9
|
+
DEFAULT_PIXEL_FORMAT: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le";
|
|
3
10
|
};
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BrowserSafeApis = void 0;
|
|
4
|
+
const codec_1 = require("./codec");
|
|
5
|
+
const crf_1 = require("./crf");
|
|
4
6
|
const get_extension_from_codec_1 = require("./get-extension-from-codec");
|
|
7
|
+
const is_audio_codec_1 = require("./is-audio-codec");
|
|
8
|
+
const pixel_format_1 = require("./pixel-format");
|
|
9
|
+
const prores_profile_1 = require("./prores-profile");
|
|
5
10
|
exports.BrowserSafeApis = {
|
|
6
11
|
getFileExtensionFromCodec: get_extension_from_codec_1.getFileExtensionFromCodec,
|
|
12
|
+
validCodecs: codec_1.validCodecs,
|
|
13
|
+
getDefaultCrfForCodec: crf_1.getDefaultCrfForCodec,
|
|
14
|
+
getValidCrfRanges: crf_1.getValidCrfRanges,
|
|
15
|
+
isAudioCodec: is_audio_codec_1.isAudioCodec,
|
|
16
|
+
proResProfileOptions: prores_profile_1.proResProfileOptions,
|
|
17
|
+
validPixelFormats: pixel_format_1.validPixelFormats,
|
|
18
|
+
DEFAULT_PIXEL_FORMAT: pixel_format_1.DEFAULT_PIXEL_FORMAT,
|
|
7
19
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CompositorCommand, CompositorInitiatePayload } from './payloads';
|
|
2
|
+
export declare type Compositor = {
|
|
3
|
+
finishCommands: () => void;
|
|
4
|
+
executeCommand: (payload: Omit<CompositorCommand, 'nonce'>) => Promise<void>;
|
|
5
|
+
waitForDone: () => Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const spawnCompositorOrReuse: ({ initiatePayload, renderId, }: {
|
|
8
|
+
initiatePayload: CompositorInitiatePayload;
|
|
9
|
+
renderId: string;
|
|
10
|
+
}) => Compositor;
|
|
11
|
+
export declare const releaseCompositorWithId: (renderId: string) => void;
|
|
12
|
+
export declare const waitForCompositorWithIdToQuit: (renderId: string) => Promise<void>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitForCompositorWithIdToQuit = exports.releaseCompositorWithId = exports.spawnCompositorOrReuse = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const get_executable_path_1 = require("./get-executable-path");
|
|
6
|
+
const compositorMap = {};
|
|
7
|
+
const spawnCompositorOrReuse = ({ initiatePayload, renderId, }) => {
|
|
8
|
+
if (!compositorMap[renderId]) {
|
|
9
|
+
compositorMap[renderId] = startCompositor(initiatePayload);
|
|
10
|
+
}
|
|
11
|
+
return compositorMap[renderId];
|
|
12
|
+
};
|
|
13
|
+
exports.spawnCompositorOrReuse = spawnCompositorOrReuse;
|
|
14
|
+
const releaseCompositorWithId = (renderId) => {
|
|
15
|
+
if (compositorMap[renderId]) {
|
|
16
|
+
compositorMap[renderId].finishCommands();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.releaseCompositorWithId = releaseCompositorWithId;
|
|
20
|
+
const waitForCompositorWithIdToQuit = (renderId) => {
|
|
21
|
+
if (!compositorMap[renderId]) {
|
|
22
|
+
throw new TypeError('No compositor with that id');
|
|
23
|
+
}
|
|
24
|
+
return compositorMap[renderId].waitForDone();
|
|
25
|
+
};
|
|
26
|
+
exports.waitForCompositorWithIdToQuit = waitForCompositorWithIdToQuit;
|
|
27
|
+
const startCompositor = (compositorInitiatePayload) => {
|
|
28
|
+
const bin = (0, get_executable_path_1.getExecutablePath)();
|
|
29
|
+
const child = (0, child_process_1.spawn)(`${bin}`, [JSON.stringify(compositorInitiatePayload)]);
|
|
30
|
+
const stderrChunks = [];
|
|
31
|
+
let stdoutListeners = [];
|
|
32
|
+
// TODO: Without this the render gets stuck!! :O
|
|
33
|
+
child.stderr.on('data', (d) => {
|
|
34
|
+
console.log('stderr', d.toString('utf-8'));
|
|
35
|
+
});
|
|
36
|
+
child.stdout.on('data', (d) => {
|
|
37
|
+
const str = d.toString('utf-8');
|
|
38
|
+
try {
|
|
39
|
+
const payloads = str
|
|
40
|
+
.split('--debug-end--')
|
|
41
|
+
.map((t) => t.trim())
|
|
42
|
+
.filter(Boolean);
|
|
43
|
+
for (const payload of payloads) {
|
|
44
|
+
const p = JSON.parse(payload.replace('--debug-start--', ''));
|
|
45
|
+
if (p.msg_type === 'debug') {
|
|
46
|
+
console.log('Rust debug', p.msg);
|
|
47
|
+
}
|
|
48
|
+
stdoutListeners.forEach((s) => s(p));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
console.log({ str });
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
let nonce = 0;
|
|
56
|
+
return {
|
|
57
|
+
waitForDone: () => {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
child.on('exit', (code) => {
|
|
60
|
+
if (code === 0) {
|
|
61
|
+
resolve();
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
reject(Buffer.concat(stderrChunks).toString('utf-8'));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
finishCommands: () => {
|
|
70
|
+
child.stdin.write('EOF\n');
|
|
71
|
+
},
|
|
72
|
+
executeCommand: (payload) => {
|
|
73
|
+
const actualPayload = {
|
|
74
|
+
...payload,
|
|
75
|
+
nonce,
|
|
76
|
+
};
|
|
77
|
+
nonce++;
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
child.stdin.write(JSON.stringify(actualPayload) + '\n');
|
|
80
|
+
const onStdout = (p) => {
|
|
81
|
+
if (p.msg_type === 'finish' && p.nonce === actualPayload.nonce) {
|
|
82
|
+
resolve();
|
|
83
|
+
stdoutListeners = stdoutListeners.filter((s) => s !== onStdout);
|
|
84
|
+
}
|
|
85
|
+
if (p.msg_type === 'error') {
|
|
86
|
+
const err = new Error(p.error);
|
|
87
|
+
err.stack = p.error + '\n' + p.backtrace;
|
|
88
|
+
reject(err);
|
|
89
|
+
stdoutListeners = stdoutListeners.filter((s) => s !== onStdout);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
stdoutListeners.push(onStdout);
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.determineVcodecFfmepgFlags = void 0;
|
|
4
|
+
const truthy_1 = require("./truthy");
|
|
5
|
+
const determineVcodecFfmepgFlags = (vcodecFlag) => {
|
|
6
|
+
return [
|
|
7
|
+
vcodecFlag === 'vp9' ? '-vcodec' : null,
|
|
8
|
+
vcodecFlag === 'vp9' ? 'libvpx-vp9' : null,
|
|
9
|
+
vcodecFlag === 'vp8' ? '-vcodec' : null,
|
|
10
|
+
vcodecFlag === 'vp8' ? 'libvpx' : null,
|
|
11
|
+
].filter(truthy_1.truthy);
|
|
12
|
+
};
|
|
13
|
+
exports.determineVcodecFfmepgFlags = determineVcodecFfmepgFlags;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { TCompMetadata } from 'remotion';
|
|
3
|
+
import type { GetCompositionsConfig } from './get-compositions';
|
|
4
|
+
export declare const getCompositionsFromBundle: (bundle: string, options: GetCompositionsConfig) => {
|
|
5
|
+
compositions: TCompMetadata[];
|
|
6
|
+
root: ComponentType;
|
|
7
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
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.getCompositionsFromBundle = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const remotion_1 = require("remotion");
|
|
10
|
+
const vm_1 = __importDefault(require("vm"));
|
|
11
|
+
const is_serve_url_1 = require("./is-serve-url");
|
|
12
|
+
const getCompositionsFromBundle = (bundle, options) => {
|
|
13
|
+
const bundleFile = path_1.default.join(bundle, 'bundle.js');
|
|
14
|
+
if ((0, is_serve_url_1.isServeUrl)(bundle)) {
|
|
15
|
+
throw new Error('Can only use getCompositionFromBundle from a local file');
|
|
16
|
+
}
|
|
17
|
+
const content = fs_1.default.readFileSync(bundleFile, 'utf-8');
|
|
18
|
+
// @ts-éxpect-error
|
|
19
|
+
process.env.REMOTION_SERVER_RENDERING = 'true';
|
|
20
|
+
const context = {
|
|
21
|
+
window: {
|
|
22
|
+
remotion_envVariables: options.envVariables,
|
|
23
|
+
},
|
|
24
|
+
clearTimeout: () => {
|
|
25
|
+
console.trace('clearTimeout() called inside a server-side bundle. This is not supported.');
|
|
26
|
+
},
|
|
27
|
+
setTimeout: () => {
|
|
28
|
+
console.trace('setTimeout() called inside a server-side bundle. This is not supported.');
|
|
29
|
+
},
|
|
30
|
+
process: {
|
|
31
|
+
env: {
|
|
32
|
+
REMOTION_SERVER_RENDERING: true,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
require,
|
|
36
|
+
Buffer,
|
|
37
|
+
console,
|
|
38
|
+
};
|
|
39
|
+
const vmContext = vm_1.default.createContext(context);
|
|
40
|
+
// TODO: Set props and env
|
|
41
|
+
const code = content;
|
|
42
|
+
vm_1.default.runInContext(code, vmContext, {
|
|
43
|
+
filename: bundleFile,
|
|
44
|
+
breakOnSigint: true,
|
|
45
|
+
});
|
|
46
|
+
const theRoot = remotion_1.Internals.getRoot();
|
|
47
|
+
if (!theRoot) {
|
|
48
|
+
throw new Error('Did not call getRoot() in the bundle. Delaying the calling of getRoot() is not supported in server-side-rendering.');
|
|
49
|
+
}
|
|
50
|
+
const Comp = theRoot;
|
|
51
|
+
const comps = (0, remotion_1.getCompositionsFromMarkup)(Comp);
|
|
52
|
+
remotion_1.Internals.clearRoot();
|
|
53
|
+
return { compositions: comps, root: Comp };
|
|
54
|
+
};
|
|
55
|
+
exports.getCompositionsFromBundle = getCompositionsFromBundle;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCompositionsFromMarkup = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const server_1 = require("react-dom/server");
|
|
6
|
+
const getCompositionsFromMarkup = (Comp) => {
|
|
7
|
+
process.env.REMOTION_SERVER_RENDERING = 'true';
|
|
8
|
+
const str = (0, server_1.renderToString)((0, jsx_runtime_1.jsx)(Comp, {}));
|
|
9
|
+
const matches = str.matchAll(/<div>(.*?)<\/div>/g);
|
|
10
|
+
const metadata = [];
|
|
11
|
+
for (const match of matches) {
|
|
12
|
+
const json = JSON.parse(match[1]);
|
|
13
|
+
metadata.push(json);
|
|
14
|
+
}
|
|
15
|
+
return metadata;
|
|
16
|
+
};
|
|
17
|
+
exports.getCompositionsFromMarkup = getCompositionsFromMarkup;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCompositionsFromMarkup = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const server_1 = require("react-dom/server");
|
|
6
|
+
const getCompositionsFromMarkup = (Comp) => {
|
|
7
|
+
process.env.REMOTION_SERVER_RENDERING = 'true';
|
|
8
|
+
const str = (0, server_1.renderToString)((0, jsx_runtime_1.jsx)(Comp, {}));
|
|
9
|
+
console.log({ str }, (0, jsx_runtime_1.jsx)(Comp, {}));
|
|
10
|
+
const matches = str.matchAll(/<div>(.*?)<\/div>/g);
|
|
11
|
+
const metadata = [];
|
|
12
|
+
for (const match of matches) {
|
|
13
|
+
const json = JSON.parse(match[1]);
|
|
14
|
+
metadata.push(json);
|
|
15
|
+
}
|
|
16
|
+
return metadata;
|
|
17
|
+
};
|
|
18
|
+
exports.getCompositionsFromMarkup = getCompositionsFromMarkup;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNativeVideoSignals = void 0;
|
|
4
|
+
const getNativeVideoSignals = (layers) => {
|
|
5
|
+
const videoSignals = layers
|
|
6
|
+
.filter((l) => {
|
|
7
|
+
return l.type === 'VideoFrame';
|
|
8
|
+
})
|
|
9
|
+
.map((l) => {
|
|
10
|
+
if (l.type !== 'VideoFrame') {
|
|
11
|
+
throw new Error('Expected VideoFrame');
|
|
12
|
+
}
|
|
13
|
+
return { frame: l.params.frame, src: l.params.src };
|
|
14
|
+
});
|
|
15
|
+
const map = {};
|
|
16
|
+
// Return a map for each video source and the number of times each frame is expected to be used
|
|
17
|
+
for (const { src, frame } of videoSignals) {
|
|
18
|
+
if (!map[src]) {
|
|
19
|
+
map[src] = {};
|
|
20
|
+
}
|
|
21
|
+
if (!map[src][frame]) {
|
|
22
|
+
map[src][frame] = 0;
|
|
23
|
+
}
|
|
24
|
+
map[src][frame]++;
|
|
25
|
+
}
|
|
26
|
+
return map;
|
|
27
|
+
};
|
|
28
|
+
exports.getNativeVideoSignals = getNativeVideoSignals;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unlockPortSelection = exports.lockPortSelection = void 0;
|
|
4
|
+
const locks = [];
|
|
5
|
+
const waitForPortSelection = () => { };
|
|
6
|
+
const lockPortSelection = () => {
|
|
7
|
+
locks.push();
|
|
8
|
+
};
|
|
9
|
+
exports.lockPortSelection = lockPortSelection;
|
|
10
|
+
const unlockPortSelection = () => { };
|
|
11
|
+
exports.unlockPortSelection = unlockPortSelection;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeCompManagerContext = void 0;
|
|
4
|
+
const makeCompManagerContext = (composition) => {
|
|
5
|
+
const memo = {
|
|
6
|
+
assets: [],
|
|
7
|
+
compositions: [composition],
|
|
8
|
+
currentComposition: composition.id,
|
|
9
|
+
currentCompositionMetadata: composition,
|
|
10
|
+
folders: [],
|
|
11
|
+
registerAsset: () => {
|
|
12
|
+
throw new Error('Not implemented');
|
|
13
|
+
},
|
|
14
|
+
registerComposition: () => {
|
|
15
|
+
throw new Error('Not implemented');
|
|
16
|
+
},
|
|
17
|
+
registerFolder: () => {
|
|
18
|
+
throw new Error('Not implemented');
|
|
19
|
+
},
|
|
20
|
+
setCurrentComposition: () => {
|
|
21
|
+
throw new Error('Not implemented');
|
|
22
|
+
},
|
|
23
|
+
registerSequence() {
|
|
24
|
+
throw new Error('Not implemented');
|
|
25
|
+
},
|
|
26
|
+
sequences: [],
|
|
27
|
+
setCurrentCompositionMetadata: () => {
|
|
28
|
+
throw new Error('Not implemented');
|
|
29
|
+
},
|
|
30
|
+
unregisterAsset: () => {
|
|
31
|
+
throw new Error('Not implemented');
|
|
32
|
+
},
|
|
33
|
+
unregisterComposition: () => {
|
|
34
|
+
throw new Error('Not implemented');
|
|
35
|
+
},
|
|
36
|
+
unregisterFolder: () => {
|
|
37
|
+
throw new Error('Not implemented');
|
|
38
|
+
},
|
|
39
|
+
unregisterSequence: () => {
|
|
40
|
+
throw new Error('Not implemented');
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return memo;
|
|
44
|
+
};
|
|
45
|
+
exports.makeCompManagerContext = makeCompManagerContext;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeTimelineContextValue = void 0;
|
|
4
|
+
const makeTimelineContextValue = (composition, frame) => {
|
|
5
|
+
const value = {
|
|
6
|
+
audioAndVideoTags: { current: [] },
|
|
7
|
+
rootId: composition.id,
|
|
8
|
+
playing: false,
|
|
9
|
+
playbackRate: 1,
|
|
10
|
+
imperativePlaying: {
|
|
11
|
+
current: false,
|
|
12
|
+
},
|
|
13
|
+
frame,
|
|
14
|
+
setPlaybackRate: () => {
|
|
15
|
+
throw new Error('Not implemented');
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
exports.makeTimelineContextValue = makeTimelineContextValue;
|
|
@@ -99,18 +99,26 @@ async function puppeteerEvaluateWithCatch({ page, pageFunction, frame, args, })
|
|
|
99
99
|
error.message += ' Are you passing a nested JSHandle?';
|
|
100
100
|
throw error;
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
try {
|
|
103
|
+
const { exceptionDetails, result: remoteObject } = await callFunctionOnPromise;
|
|
104
|
+
if (exceptionDetails) {
|
|
105
|
+
const err = new symbolicateable_error_1.SymbolicateableError({
|
|
106
|
+
stack: (_c = exceptionDetails.exception) === null || _c === void 0 ? void 0 : _c.description,
|
|
107
|
+
name: (_d = exceptionDetails.exception) === null || _d === void 0 ? void 0 : _d.className,
|
|
108
|
+
message: (_f = (_e = exceptionDetails.exception) === null || _e === void 0 ? void 0 : _e.description) === null || _f === void 0 ? void 0 : _f.split('\n')[0],
|
|
109
|
+
frame,
|
|
110
|
+
stackFrame: (0, parse_browser_error_stack_1.parseStack)(((_g = exceptionDetails.exception) === null || _g === void 0 ? void 0 : _g.description).split('\n')),
|
|
111
|
+
});
|
|
112
|
+
throw err;
|
|
113
|
+
}
|
|
114
|
+
return valueFromRemoteObject(remoteObject);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (error === null || error === void 0 ? void 0 : error.originalMessage.startsWith("Object couldn't be returned by value")) {
|
|
118
|
+
throw new Error('Could not serialize the return value of the function. Did you pass non-serializable values to defaultProps?');
|
|
119
|
+
}
|
|
120
|
+
throw error;
|
|
112
121
|
}
|
|
113
|
-
return valueFromRemoteObject(remoteObject);
|
|
114
122
|
}
|
|
115
123
|
exports.puppeteerEvaluateWithCatch = puppeteerEvaluateWithCatch;
|
|
116
124
|
/**
|
|
@@ -0,0 +1,90 @@
|
|
|
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.renderOnServer = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const execa_1 = __importDefault(require("execa"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const server_1 = require("react-dom/server");
|
|
11
|
+
const remotion_1 = require("remotion");
|
|
12
|
+
const download_map_1 = require("./assets/download-map");
|
|
13
|
+
const compose_1 = require("./compositor/compose");
|
|
14
|
+
const compositor_1 = require("./compositor/compositor");
|
|
15
|
+
const get_frame_padded_index_1 = require("./get-frame-padded-index");
|
|
16
|
+
const make_comp_manager_context_1 = require("./make-comp-manager-context");
|
|
17
|
+
const pool_1 = require("./pool");
|
|
18
|
+
const renderOnServer = async (Comp, composition) => {
|
|
19
|
+
console.time('total');
|
|
20
|
+
console.time('frames');
|
|
21
|
+
process.env.REMOTION_SERVER_RENDERING = 'true';
|
|
22
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
23
|
+
const memo = (0, make_comp_manager_context_1.makeCompManagerContext)(composition);
|
|
24
|
+
const pool = new pool_1.Pool(new Array(4).fill(true).map((_, i) => i));
|
|
25
|
+
const downloadMap = (0, download_map_1.makeDownloadMap)();
|
|
26
|
+
const renderId = 'abc';
|
|
27
|
+
await Promise.all(new Array(composition.durationInFrames).fill(true).map(async (_, i) => {
|
|
28
|
+
const frame = await pool.acquire();
|
|
29
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
30
|
+
const value = {
|
|
31
|
+
audioAndVideoTags: { current: [] },
|
|
32
|
+
rootId: composition.id,
|
|
33
|
+
playing: false,
|
|
34
|
+
playbackRate: 1,
|
|
35
|
+
imperativePlaying: {
|
|
36
|
+
current: false,
|
|
37
|
+
},
|
|
38
|
+
frame: i,
|
|
39
|
+
setPlaybackRate: () => {
|
|
40
|
+
throw new Error('Not implemented');
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
const svg = (0, server_1.renderToStaticMarkup)((0, jsx_runtime_1.jsx)(remotion_1.Internals.SelectCompositionMode, { layer: 0, id: composition.id, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.TimelineContext.Provider, { value: value, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: memo, children: (0, jsx_runtime_1.jsx)(Comp, {}) }) }) }));
|
|
44
|
+
const out = path_1.default.join(downloadMap.compositingDir, (0, get_frame_padded_index_1.getFrameOutputFileName)({
|
|
45
|
+
frame: i,
|
|
46
|
+
imageFormat: 'tiff',
|
|
47
|
+
index: i,
|
|
48
|
+
countType: 'from-zero',
|
|
49
|
+
lastFrame: composition.durationInFrames - 1,
|
|
50
|
+
totalFrames: composition.durationInFrames,
|
|
51
|
+
}));
|
|
52
|
+
await (0, compose_1.compose)({
|
|
53
|
+
height: composition.height,
|
|
54
|
+
width: composition.width,
|
|
55
|
+
downloadMap,
|
|
56
|
+
imageFormat: 'AddToH264',
|
|
57
|
+
layers: [
|
|
58
|
+
{
|
|
59
|
+
type: 'SvgImage',
|
|
60
|
+
params: {
|
|
61
|
+
height: composition.height,
|
|
62
|
+
width: composition.width,
|
|
63
|
+
markup: svg,
|
|
64
|
+
x: 0,
|
|
65
|
+
y: 0,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
output: out,
|
|
70
|
+
renderId,
|
|
71
|
+
compositorInitiatePayload: {
|
|
72
|
+
create_h264_queue: true,
|
|
73
|
+
duration_in_frames: 300,
|
|
74
|
+
fps: 30,
|
|
75
|
+
video_signals: {},
|
|
76
|
+
height: composition.height,
|
|
77
|
+
width: composition.width,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
pool.release(frame);
|
|
81
|
+
}));
|
|
82
|
+
(0, compositor_1.releaseCompositorWithId)(renderId);
|
|
83
|
+
console.timeEnd('frames');
|
|
84
|
+
await (0, compositor_1.waitForCompositorWithIdToQuit)(renderId);
|
|
85
|
+
console.time('convert');
|
|
86
|
+
await (0, execa_1.default)('ffmpeg', ['-i', 'fade.h264', '-c', 'copy', 'fade.mp4', '-y']);
|
|
87
|
+
console.timeEnd('convert');
|
|
88
|
+
console.timeEnd('total');
|
|
89
|
+
};
|
|
90
|
+
exports.renderOnServer = renderOnServer;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { TCompMetadata } from 'remotion';
|
|
3
|
+
export declare const renderSvg: ({ composition, Comp, frame, layer, }: {
|
|
4
|
+
composition: TCompMetadata;
|
|
5
|
+
Comp: ComponentType;
|
|
6
|
+
frame: number;
|
|
7
|
+
layer: number;
|
|
8
|
+
}) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderSvg = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const server_1 = require("react-dom/server");
|
|
6
|
+
const remotion_1 = require("remotion");
|
|
7
|
+
const make_comp_manager_context_1 = require("./make-comp-manager-context");
|
|
8
|
+
const make_timeline_context_value_1 = require("./make-timeline-context-value");
|
|
9
|
+
const renderSvg = ({ composition, Comp, frame, layer, }) => {
|
|
10
|
+
const svg = (0, server_1.renderToStaticMarkup)((0, jsx_runtime_1.jsx)(remotion_1.Internals.SelectCompositionMode, { layer: layer, id: composition.id, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.TimelineContext.Provider, { value: (0, make_timeline_context_value_1.makeTimelineContextValue)(composition, frame), children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: (0, make_comp_manager_context_1.makeCompManagerContext)(composition), children: (0, jsx_runtime_1.jsx)(Comp, {}) }) }) }));
|
|
11
|
+
return svg;
|
|
12
|
+
};
|
|
13
|
+
exports.renderSvg = renderSvg;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { TCompMetadata } from 'remotion';
|
|
3
|
+
import type { NativeVideoLayerInfo } from 'remotion/src/video/NativeVideoForRendering';
|
|
4
|
+
export declare const renderVideoLayer: ({ composition, Comp, frame, layer, }: {
|
|
5
|
+
composition: TCompMetadata;
|
|
6
|
+
Comp: ComponentType;
|
|
7
|
+
frame: number;
|
|
8
|
+
layer: number;
|
|
9
|
+
}) => NativeVideoLayerInfo | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderVideoLayer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const server_1 = require("react-dom/server");
|
|
6
|
+
const remotion_1 = require("remotion");
|
|
7
|
+
const make_comp_manager_context_1 = require("./make-comp-manager-context");
|
|
8
|
+
const make_timeline_context_value_1 = require("./make-timeline-context-value");
|
|
9
|
+
const renderVideoLayer = ({ composition, Comp, frame, layer, }) => {
|
|
10
|
+
process.env.REMOTION_SERVER_RENDERING = 'true';
|
|
11
|
+
const markup = (0, server_1.renderToStaticMarkup)((0, jsx_runtime_1.jsx)(remotion_1.Internals.SelectCompositionMode, { layer: layer, id: composition.id, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.TimelineContext.Provider, { value: (0, make_timeline_context_value_1.makeTimelineContextValue)(composition, frame), children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: (0, make_comp_manager_context_1.makeCompManagerContext)(composition), children: (0, jsx_runtime_1.jsx)(Comp, {}) }) }) }));
|
|
12
|
+
const matches = markup.matchAll(/<div>(.*?)<\/div>/g);
|
|
13
|
+
let parsed = null;
|
|
14
|
+
for (const match of matches) {
|
|
15
|
+
if (parsed) {
|
|
16
|
+
throw new Error('cannot have more than one video layer');
|
|
17
|
+
}
|
|
18
|
+
const json = JSON.parse(match[1]);
|
|
19
|
+
parsed = json;
|
|
20
|
+
}
|
|
21
|
+
return parsed;
|
|
22
|
+
};
|
|
23
|
+
exports.renderVideoLayer = renderVideoLayer;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { SmallTCompMetadata, TAsset } from 'remotion';
|
|
3
|
+
import type { DownloadMap } from './assets/download-map';
|
|
4
|
+
import type { BrowserExecutable } from './browser-executable';
|
|
5
|
+
import type { BrowserLog } from './browser-log';
|
|
6
|
+
import type { Page } from './browser/BrowserPage';
|
|
7
|
+
import type { CompositorLayer } from './compositor/payloads';
|
|
8
|
+
import type { CountType } from './get-frame-padded-index';
|
|
9
|
+
import type { ServeUrl } from './legacy-webpack-config';
|
|
10
|
+
import type { ChromiumOptions } from './open-browser';
|
|
11
|
+
import type { Pool } from './pool';
|
|
12
|
+
import type { BrowserReplacer } from './replace-browser';
|
|
13
|
+
export declare const renderWebFrameAndRetryTargetClose: ({ frame, index, retriesLeft, attempt, actualConcurrency, browserReplacer, poolPromise, composition, downloadMap, imageFormat, onFrameBuffer, outputDir, stopState, countType, scale, quality, framesToRender, lastFrame, framesRendered, browserExecutable, chromiumOptions, dumpBrowserLogs, pagesArray, onBrowserLog, inputProps, envVariables, muted, proxyPort, realFrameRange, serveUrl, timeoutInMilliseconds, }: {
|
|
14
|
+
frame: number;
|
|
15
|
+
index: number;
|
|
16
|
+
retriesLeft: number;
|
|
17
|
+
attempt: number;
|
|
18
|
+
actualConcurrency: number;
|
|
19
|
+
browserReplacer: BrowserReplacer | null;
|
|
20
|
+
poolPromise: Promise<Pool<Page>>;
|
|
21
|
+
composition: SmallTCompMetadata;
|
|
22
|
+
downloadMap: DownloadMap;
|
|
23
|
+
imageFormat: 'png' | 'jpeg' | 'none';
|
|
24
|
+
onFrameBuffer: ((buffer: Buffer, frame: number) => void) | undefined;
|
|
25
|
+
outputDir: string | null;
|
|
26
|
+
stopState: {
|
|
27
|
+
isStopped: boolean;
|
|
28
|
+
};
|
|
29
|
+
countType: CountType;
|
|
30
|
+
scale: number;
|
|
31
|
+
quality: number | undefined;
|
|
32
|
+
framesToRender: number[];
|
|
33
|
+
lastFrame: number;
|
|
34
|
+
framesRendered: {
|
|
35
|
+
frames: number;
|
|
36
|
+
};
|
|
37
|
+
browserExecutable?: BrowserExecutable | undefined;
|
|
38
|
+
chromiumOptions?: ChromiumOptions | undefined;
|
|
39
|
+
dumpBrowserLogs?: boolean | undefined;
|
|
40
|
+
pagesArray: Page[];
|
|
41
|
+
onBrowserLog?: ((log: BrowserLog) => void) | undefined;
|
|
42
|
+
inputProps: unknown;
|
|
43
|
+
envVariables?: Record<string, string> | undefined;
|
|
44
|
+
muted: boolean;
|
|
45
|
+
proxyPort: number;
|
|
46
|
+
realFrameRange: [number, number];
|
|
47
|
+
serveUrl: ServeUrl;
|
|
48
|
+
timeoutInMilliseconds: number;
|
|
49
|
+
}) => Promise<{
|
|
50
|
+
layer: CompositorLayer | null;
|
|
51
|
+
buffer: Buffer | null;
|
|
52
|
+
assets: TAsset[];
|
|
53
|
+
}>;
|
|
54
|
+
export declare const makePage: ({ browserReplacer, pagesArray, composition, scale, onBrowserLog, inputProps, envVariables, serveUrl, realFrameRange, timeoutInMilliseconds, proxyPort, imageFormat, muted, }: {
|
|
55
|
+
browserReplacer: BrowserReplacer;
|
|
56
|
+
pagesArray: Page[];
|
|
57
|
+
composition: SmallTCompMetadata;
|
|
58
|
+
scale?: number | undefined;
|
|
59
|
+
onBrowserLog?: ((log: BrowserLog) => void) | undefined;
|
|
60
|
+
inputProps: unknown;
|
|
61
|
+
envVariables?: Record<string, string> | undefined;
|
|
62
|
+
serveUrl: ServeUrl;
|
|
63
|
+
realFrameRange: [number, number];
|
|
64
|
+
timeoutInMilliseconds: number | undefined;
|
|
65
|
+
proxyPort: number;
|
|
66
|
+
imageFormat: 'png' | 'jpeg' | 'none';
|
|
67
|
+
muted: boolean;
|
|
68
|
+
}) => Promise<Page>;
|
|
69
|
+
export declare const makeBrowser: ({ dumpBrowserLogs, browserExecutable, chromiumOptions, scale, }: {
|
|
70
|
+
dumpBrowserLogs?: boolean | undefined;
|
|
71
|
+
browserExecutable?: BrowserExecutable | undefined;
|
|
72
|
+
chromiumOptions?: ChromiumOptions | undefined;
|
|
73
|
+
scale?: number | undefined;
|
|
74
|
+
}) => Promise<import("./browser/Browser").Browser>;
|
|
@@ -0,0 +1,260 @@
|
|
|
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.makeBrowser = exports.makePage = exports.renderWebFrameAndRetryTargetClose = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const browser_1 = require("./browser");
|
|
9
|
+
const handle_javascript_exception_1 = require("./error-handling/handle-javascript-exception");
|
|
10
|
+
const make_cancel_signal_1 = require("./make-cancel-signal");
|
|
11
|
+
const open_browser_1 = require("./open-browser");
|
|
12
|
+
const perf_1 = require("./perf");
|
|
13
|
+
const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
|
|
14
|
+
const seek_to_frame_1 = require("./seek-to-frame");
|
|
15
|
+
const set_props_and_env_1 = require("./set-props-and-env");
|
|
16
|
+
const take_frame_and_compose_1 = require("./take-frame-and-compose");
|
|
17
|
+
const renderFrameWithOptionToReject = async ({ frame, index, reject, width, height, poolPromise, stopState, imageFormat, downloadMap, scale, quality, }) => {
|
|
18
|
+
const pool = await poolPromise;
|
|
19
|
+
const freePage = await pool.acquire();
|
|
20
|
+
if (stopState.isStopped) {
|
|
21
|
+
reject(new Error('Render was stopped'));
|
|
22
|
+
throw new Error('stopped');
|
|
23
|
+
}
|
|
24
|
+
const errorCallbackOnFrame = (err) => {
|
|
25
|
+
reject(err);
|
|
26
|
+
};
|
|
27
|
+
const cleanupPageError = (0, handle_javascript_exception_1.handleJavascriptException)({
|
|
28
|
+
page: freePage,
|
|
29
|
+
onError: errorCallbackOnFrame,
|
|
30
|
+
frame,
|
|
31
|
+
});
|
|
32
|
+
freePage.on('error', errorCallbackOnFrame);
|
|
33
|
+
await (0, seek_to_frame_1.seekToFrame)({ frame, page: freePage });
|
|
34
|
+
const id = (0, perf_1.startPerfMeasure)('save');
|
|
35
|
+
const output = path_1.default.join(downloadMap.compositingDir, `preframe-${index}.${imageFormat}`);
|
|
36
|
+
const { buffer, collectedAssets, clipRegion } = await (0, take_frame_and_compose_1.takeFrame)({
|
|
37
|
+
frame,
|
|
38
|
+
freePage,
|
|
39
|
+
height,
|
|
40
|
+
imageFormat,
|
|
41
|
+
quality,
|
|
42
|
+
width,
|
|
43
|
+
});
|
|
44
|
+
const needsComposing = clipRegion === null
|
|
45
|
+
? null
|
|
46
|
+
: {
|
|
47
|
+
tmpFile: path_1.default.join(downloadMap.compositingDir, `${frame}.${imageFormat}`),
|
|
48
|
+
finalOutfie: output !== null && output !== void 0 ? output : path_1.default.join(downloadMap.compositingDir, `${frame}-final.${imageFormat}`),
|
|
49
|
+
clipRegion: clipRegion,
|
|
50
|
+
};
|
|
51
|
+
const compositionLayer = !needsComposing || needsComposing.clipRegion === 'hide'
|
|
52
|
+
? null
|
|
53
|
+
: {
|
|
54
|
+
type: imageFormat === 'jpeg'
|
|
55
|
+
? 'JpgImage'
|
|
56
|
+
: 'PngImage',
|
|
57
|
+
params: {
|
|
58
|
+
height: needsComposing.clipRegion.height * scale,
|
|
59
|
+
width: needsComposing.clipRegion.width * scale,
|
|
60
|
+
src: needsComposing.tmpFile,
|
|
61
|
+
x: needsComposing.clipRegion.x * scale,
|
|
62
|
+
y: needsComposing.clipRegion.y * scale,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
// TODO: Always return buffer
|
|
66
|
+
(0, perf_1.stopPerfMeasure)(id);
|
|
67
|
+
cleanupPageError();
|
|
68
|
+
freePage.off('error', errorCallbackOnFrame);
|
|
69
|
+
pool.release(freePage);
|
|
70
|
+
return { layer: compositionLayer, buffer, assets: collectedAssets };
|
|
71
|
+
};
|
|
72
|
+
const renderWebFrame = ({ frame, index, downloadMap, imageFormat, poolPromise, stopState, composition, scale, quality, }) => {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
renderFrameWithOptionToReject({
|
|
75
|
+
frame,
|
|
76
|
+
index,
|
|
77
|
+
reject,
|
|
78
|
+
width: composition.width,
|
|
79
|
+
height: composition.height,
|
|
80
|
+
downloadMap,
|
|
81
|
+
imageFormat,
|
|
82
|
+
poolPromise,
|
|
83
|
+
stopState,
|
|
84
|
+
scale,
|
|
85
|
+
quality,
|
|
86
|
+
})
|
|
87
|
+
.then((res) => {
|
|
88
|
+
resolve(res);
|
|
89
|
+
})
|
|
90
|
+
.catch((err) => {
|
|
91
|
+
reject(err);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
// TODO: Bring fixes for retrying here
|
|
96
|
+
const renderWebFrameAndRetryTargetClose = async ({ frame, index, retriesLeft, attempt, actualConcurrency, browserReplacer, poolPromise, composition, downloadMap, imageFormat, onFrameBuffer, outputDir, stopState, countType, scale, quality, framesToRender, lastFrame, framesRendered, browserExecutable, chromiumOptions, dumpBrowserLogs, pagesArray, onBrowserLog, inputProps, envVariables, muted, proxyPort, realFrameRange, serveUrl, timeoutInMilliseconds, }) => {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
try {
|
|
99
|
+
const returnval = await renderWebFrame({
|
|
100
|
+
frame,
|
|
101
|
+
index,
|
|
102
|
+
poolPromise,
|
|
103
|
+
composition,
|
|
104
|
+
downloadMap,
|
|
105
|
+
imageFormat,
|
|
106
|
+
stopState,
|
|
107
|
+
scale,
|
|
108
|
+
quality,
|
|
109
|
+
});
|
|
110
|
+
return returnval;
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
if (!((_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.includes('Target closed')) &&
|
|
114
|
+
!((_b = err === null || err === void 0 ? void 0 : err.message) === null || _b === void 0 ? void 0 : _b.includes('Session closed'))) {
|
|
115
|
+
throw err;
|
|
116
|
+
}
|
|
117
|
+
if ((0, make_cancel_signal_1.isUserCancelledRender)(err)) {
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
if (retriesLeft === 0) {
|
|
121
|
+
console.warn(err, `The browser crashed ${attempt} times while rendering frame ${frame}. Not retrying anymore. Learn more about this error under https://www.remotion.dev/docs/target-closed`);
|
|
122
|
+
throw err;
|
|
123
|
+
}
|
|
124
|
+
console.warn(`The browser crashed while rendering frame ${frame}, retrying ${retriesLeft} more times. Learn more about this error under https://www.remotion.dev/docs/target-closed`);
|
|
125
|
+
if (!browserReplacer) {
|
|
126
|
+
throw new Error('Did not have browser replacer for web frame');
|
|
127
|
+
}
|
|
128
|
+
await browserReplacer.replaceBrowser(() => (0, exports.makeBrowser)({
|
|
129
|
+
browserExecutable,
|
|
130
|
+
chromiumOptions,
|
|
131
|
+
dumpBrowserLogs,
|
|
132
|
+
scale,
|
|
133
|
+
}), async () => {
|
|
134
|
+
const pages = new Array(actualConcurrency).fill(true).map(() => (0, exports.makePage)({
|
|
135
|
+
browserReplacer,
|
|
136
|
+
composition,
|
|
137
|
+
pagesArray,
|
|
138
|
+
onBrowserLog,
|
|
139
|
+
scale,
|
|
140
|
+
inputProps,
|
|
141
|
+
envVariables,
|
|
142
|
+
imageFormat,
|
|
143
|
+
muted,
|
|
144
|
+
proxyPort,
|
|
145
|
+
realFrameRange,
|
|
146
|
+
serveUrl,
|
|
147
|
+
timeoutInMilliseconds,
|
|
148
|
+
}));
|
|
149
|
+
const puppeteerPages = await Promise.all(pages);
|
|
150
|
+
const pool = await poolPromise;
|
|
151
|
+
for (const newPage of puppeteerPages) {
|
|
152
|
+
pool.release(newPage);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
const fram = await (0, exports.renderWebFrameAndRetryTargetClose)({
|
|
156
|
+
frame,
|
|
157
|
+
index,
|
|
158
|
+
retriesLeft: retriesLeft - 1,
|
|
159
|
+
attempt: attempt + 1,
|
|
160
|
+
actualConcurrency,
|
|
161
|
+
browserReplacer,
|
|
162
|
+
composition,
|
|
163
|
+
downloadMap,
|
|
164
|
+
imageFormat,
|
|
165
|
+
onFrameBuffer,
|
|
166
|
+
outputDir,
|
|
167
|
+
poolPromise,
|
|
168
|
+
stopState,
|
|
169
|
+
countType,
|
|
170
|
+
scale,
|
|
171
|
+
quality,
|
|
172
|
+
framesToRender,
|
|
173
|
+
lastFrame,
|
|
174
|
+
framesRendered,
|
|
175
|
+
inputProps,
|
|
176
|
+
pagesArray,
|
|
177
|
+
browserExecutable,
|
|
178
|
+
chromiumOptions,
|
|
179
|
+
dumpBrowserLogs,
|
|
180
|
+
envVariables,
|
|
181
|
+
muted,
|
|
182
|
+
onBrowserLog,
|
|
183
|
+
proxyPort,
|
|
184
|
+
realFrameRange,
|
|
185
|
+
serveUrl,
|
|
186
|
+
timeoutInMilliseconds,
|
|
187
|
+
});
|
|
188
|
+
return fram;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
exports.renderWebFrameAndRetryTargetClose = renderWebFrameAndRetryTargetClose;
|
|
192
|
+
const makePage = async ({ browserReplacer, pagesArray, composition, scale, onBrowserLog, inputProps, envVariables, serveUrl, realFrameRange, timeoutInMilliseconds, proxyPort, imageFormat, muted, }) => {
|
|
193
|
+
if (!browserReplacer) {
|
|
194
|
+
throw new Error('canonot make page without browser replacer');
|
|
195
|
+
}
|
|
196
|
+
const page = await browserReplacer.getBrowser().newPage();
|
|
197
|
+
pagesArray.push(page);
|
|
198
|
+
await page.setViewport({
|
|
199
|
+
width: composition.width,
|
|
200
|
+
height: composition.height,
|
|
201
|
+
deviceScaleFactor: scale !== null && scale !== void 0 ? scale : 1,
|
|
202
|
+
});
|
|
203
|
+
const logCallback = (log) => {
|
|
204
|
+
onBrowserLog === null || onBrowserLog === void 0 ? void 0 : onBrowserLog({
|
|
205
|
+
stackTrace: log.stackTrace(),
|
|
206
|
+
text: log.text,
|
|
207
|
+
type: log.type,
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
if (onBrowserLog) {
|
|
211
|
+
page.on('console', logCallback);
|
|
212
|
+
}
|
|
213
|
+
const initialFrame = realFrameRange[0];
|
|
214
|
+
await (0, set_props_and_env_1.setPropsAndEnv)({
|
|
215
|
+
inputProps,
|
|
216
|
+
envVariables,
|
|
217
|
+
page,
|
|
218
|
+
serveUrl,
|
|
219
|
+
initialFrame,
|
|
220
|
+
timeoutInMilliseconds,
|
|
221
|
+
proxyPort,
|
|
222
|
+
retriesRemaining: 2,
|
|
223
|
+
audioEnabled: !muted,
|
|
224
|
+
videoEnabled: imageFormat !== 'none',
|
|
225
|
+
});
|
|
226
|
+
await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
227
|
+
// eslint-disable-next-line max-params
|
|
228
|
+
pageFunction: (id, defaultProps, durationInFrames, fps, height, width) => {
|
|
229
|
+
window.setBundleMode({
|
|
230
|
+
type: 'composition',
|
|
231
|
+
compositionName: id,
|
|
232
|
+
compositionDefaultProps: defaultProps,
|
|
233
|
+
compositionDurationInFrames: durationInFrames,
|
|
234
|
+
compositionFps: fps,
|
|
235
|
+
compositionHeight: height,
|
|
236
|
+
compositionWidth: width,
|
|
237
|
+
});
|
|
238
|
+
},
|
|
239
|
+
args: [
|
|
240
|
+
composition.id,
|
|
241
|
+
composition.defaultProps,
|
|
242
|
+
composition.durationInFrames,
|
|
243
|
+
composition.fps,
|
|
244
|
+
composition.height,
|
|
245
|
+
composition.width,
|
|
246
|
+
],
|
|
247
|
+
frame: null,
|
|
248
|
+
page,
|
|
249
|
+
});
|
|
250
|
+
page.off('console', logCallback);
|
|
251
|
+
return page;
|
|
252
|
+
};
|
|
253
|
+
exports.makePage = makePage;
|
|
254
|
+
const makeBrowser = ({ dumpBrowserLogs, browserExecutable, chromiumOptions, scale, }) => (0, open_browser_1.openBrowser)(browser_1.DEFAULT_BROWSER, {
|
|
255
|
+
shouldDumpIo: dumpBrowserLogs,
|
|
256
|
+
browserExecutable,
|
|
257
|
+
chromiumOptions,
|
|
258
|
+
forceDeviceScaleFactor: scale !== null && scale !== void 0 ? scale : 1,
|
|
259
|
+
});
|
|
260
|
+
exports.makeBrowser = makeBrowser;
|
package/dist/ws/ws-types.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ws = void 0;
|
|
7
7
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
8
|
-
// @ts-expect-error
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
9
|
+
// @ts-ignore
|
|
9
10
|
const ws_1 = __importDefault(require("ws"));
|
|
10
11
|
exports.ws = ws_1.default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/renderer",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.40",
|
|
4
4
|
"description": "Renderer for Remotion",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"execa": "5.1.1",
|
|
26
26
|
"extract-zip": "2.0.1",
|
|
27
|
-
"remotion": "3.3.
|
|
27
|
+
"remotion": "3.3.40",
|
|
28
28
|
"source-map": "^0.8.0-beta.0",
|
|
29
29
|
"ws": "8.7.0"
|
|
30
30
|
},
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"vitest": "0.24.3"
|
|
50
50
|
},
|
|
51
51
|
"optionalDependencies": {
|
|
52
|
-
"@remotion/compositor-darwin-arm64": "3.3.
|
|
53
|
-
"@remotion/compositor-darwin-x64": "3.3.
|
|
54
|
-
"@remotion/compositor-linux-arm64-gnu": "3.3.
|
|
55
|
-
"@remotion/compositor-linux-arm64-musl": "3.3.
|
|
56
|
-
"@remotion/compositor-linux-x64-gnu": "3.3.
|
|
57
|
-
"@remotion/compositor-linux-x64-musl": "3.3.
|
|
58
|
-
"@remotion/compositor-win32-x64-msvc": "3.3.
|
|
52
|
+
"@remotion/compositor-darwin-arm64": "3.3.40",
|
|
53
|
+
"@remotion/compositor-darwin-x64": "3.3.40",
|
|
54
|
+
"@remotion/compositor-linux-arm64-gnu": "3.3.40",
|
|
55
|
+
"@remotion/compositor-linux-arm64-musl": "3.3.40",
|
|
56
|
+
"@remotion/compositor-linux-x64-gnu": "3.3.40",
|
|
57
|
+
"@remotion/compositor-linux-x64-musl": "3.3.40",
|
|
58
|
+
"@remotion/compositor-win32-x64-msvc": "3.3.40"
|
|
59
59
|
},
|
|
60
60
|
"keywords": [
|
|
61
61
|
"remotion",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "be5f606a81761f7f8e1e191ebabd5f8d225d8c09"
|
|
71
71
|
}
|