@remotion/serverless 4.0.244 → 4.0.245
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/.turbo/turbo-formatting.log +7 -0
- package/.turbo/turbo-lint.log +11 -0
- package/.turbo/turbo-make.log +1 -1
- package/LICENSE.md +1 -1
- package/dist/best-frames-per-function-param.d.ts +1 -0
- package/dist/best-frames-per-function-param.js +17 -0
- package/dist/calculate-chunk-times.d.ts +5 -0
- package/dist/calculate-chunk-times.js +29 -0
- package/dist/can-concat-seamlessly.d.ts +3 -0
- package/dist/can-concat-seamlessly.js +17 -0
- package/dist/cleanup-props.d.ts +9 -0
- package/dist/cleanup-props.js +23 -0
- package/dist/cleanup-serialized-input-props.d.ts +15 -0
- package/dist/cleanup-serialized-input-props.js +34 -0
- package/dist/concat-videos.d.ts +26 -0
- package/dist/concat-videos.js +53 -0
- package/dist/create-post-render-data.d.ts +20 -0
- package/dist/create-post-render-data.js +68 -0
- package/dist/docs-url.d.ts +1 -0
- package/dist/docs-url.js +4 -0
- package/dist/estimate-price-from-bucket.d.ts +15 -0
- package/dist/estimate-price-from-bucket.js +31 -0
- package/dist/find-output-file-in-bucket.d.ts +16 -0
- package/dist/find-output-file-in-bucket.js +41 -0
- package/dist/format-costs-info.d.ts +2 -0
- package/dist/format-costs-info.js +23 -0
- package/dist/get-overall-progress-from-storage.d.ts +11 -0
- package/dist/get-overall-progress-from-storage.js +25 -0
- package/dist/get-overall-progress.d.ts +9 -0
- package/dist/get-overall-progress.js +23 -0
- package/dist/handlers/compositions.d.ts +11 -0
- package/dist/handlers/compositions.js +81 -0
- package/dist/handlers/launch.d.ts +17 -0
- package/dist/handlers/launch.js +601 -0
- package/dist/handlers/progress.d.ts +12 -0
- package/dist/handlers/progress.js +51 -0
- package/dist/handlers/renderer.d.ts +23 -0
- package/dist/handlers/renderer.js +342 -0
- package/dist/handlers/start.d.ts +14 -0
- package/dist/handlers/start.js +105 -0
- package/dist/handlers/still.d.ts +20 -0
- package/dist/handlers/still.js +334 -0
- package/dist/inspect-error.d.ts +4 -0
- package/dist/inspect-error.js +39 -0
- package/dist/invoke-webhook.d.ts +39 -0
- package/dist/invoke-webhook.js +116 -0
- package/dist/leak-detection.d.ts +4 -0
- package/dist/leak-detection.js +40 -0
- package/dist/make-timeout-error.d.ts +13 -0
- package/dist/make-timeout-error.js +32 -0
- package/dist/make-timeout-message.d.ts +12 -0
- package/dist/make-timeout-message.js +75 -0
- package/dist/merge-chunks.d.ts +37 -0
- package/dist/merge-chunks.js +92 -0
- package/dist/min-max.d.ts +2 -0
- package/dist/min-max.js +33 -0
- package/dist/most-expensive-chunks.d.ts +13 -0
- package/dist/most-expensive-chunks.js +28 -0
- package/dist/on-downloads-helpers.d.ts +2 -0
- package/dist/on-downloads-helpers.js +29 -0
- package/dist/overall-render-progress.d.ts +59 -0
- package/dist/overall-render-progress.js +180 -0
- package/dist/plan-frame-ranges.d.ts +7 -0
- package/dist/plan-frame-ranges.js +17 -0
- package/dist/progress.d.ts +16 -0
- package/dist/progress.js +254 -0
- package/dist/render-has-audio-video.d.ts +6 -0
- package/dist/render-has-audio-video.js +21 -0
- package/dist/render-progress.d.ts +51 -0
- package/dist/render-progress.js +2 -0
- package/dist/return-values.d.ts +38 -0
- package/dist/return-values.js +2 -0
- package/dist/stackback.d.ts +6 -0
- package/dist/stackback.js +59 -0
- package/dist/stream-renderer.d.ts +17 -0
- package/dist/stream-renderer.js +148 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.js +2 -0
- package/dist/validate-download-behavior.d.ts +1 -0
- package/dist/validate-download-behavior.js +21 -0
- package/dist/validate-frames-per-function.d.ts +4 -0
- package/dist/validate-frames-per-function.js +29 -0
- package/dist/validate-frames-per-lambda.d.ts +4 -0
- package/dist/validate-frames-per-lambda.js +29 -0
- package/dist/validate-privacy.d.ts +2 -0
- package/dist/validate-privacy.js +14 -0
- package/dist/validate.d.ts +4 -0
- package/dist/validate.js +8 -0
- package/dist/why-is-node-running.d.ts +15 -0
- package/dist/why-is-node-running.js +89 -0
- package/package.json +5 -5
- package/tsconfig.tsbuildinfo +1 -1
package/dist/progress.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProgress = void 0;
|
|
4
|
+
const pure_1 = require("@remotion/renderer/pure");
|
|
5
|
+
const no_react_1 = require("remotion/no-react");
|
|
6
|
+
const calculate_chunk_times_1 = require("./calculate-chunk-times");
|
|
7
|
+
const estimate_price_from_bucket_1 = require("./estimate-price-from-bucket");
|
|
8
|
+
const expected_out_name_1 = require("./expected-out-name");
|
|
9
|
+
const format_costs_info_1 = require("./format-costs-info");
|
|
10
|
+
const get_overall_progress_1 = require("./get-overall-progress");
|
|
11
|
+
const get_overall_progress_from_storage_1 = require("./get-overall-progress-from-storage");
|
|
12
|
+
const inspect_error_1 = require("./inspect-error");
|
|
13
|
+
const make_timeout_error_1 = require("./make-timeout-error");
|
|
14
|
+
const render_has_audio_video_1 = require("./render-has-audio-video");
|
|
15
|
+
const truthy_1 = require("./truthy");
|
|
16
|
+
const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region, memorySizeInMb, timeoutInMilliseconds, customCredentials, providerSpecifics, forcePathStyle, functionName, }) => {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
18
|
+
const overallProgress = await (0, get_overall_progress_from_storage_1.getOverallProgressFromStorage)({
|
|
19
|
+
renderId,
|
|
20
|
+
bucketName,
|
|
21
|
+
expectedBucketOwner,
|
|
22
|
+
region,
|
|
23
|
+
providerSpecifics,
|
|
24
|
+
forcePathStyle,
|
|
25
|
+
});
|
|
26
|
+
if (overallProgress.postRenderData) {
|
|
27
|
+
if (!overallProgress.renderMetadata) {
|
|
28
|
+
throw new Error('No render metadata found even though render is finished');
|
|
29
|
+
}
|
|
30
|
+
if (overallProgress.renderMetadata.type === 'still') {
|
|
31
|
+
throw new Error("You don't need to call getRenderProgress() on a still render. Once you have obtained the `renderId`, the render is already done! 😉");
|
|
32
|
+
}
|
|
33
|
+
const outData = (0, expected_out_name_1.getExpectedOutName)(overallProgress.renderMetadata, bucketName, customCredentials);
|
|
34
|
+
const totalFrameCount = pure_1.NoReactAPIs.getFramesToRender(overallProgress.renderMetadata.frameRange, overallProgress.renderMetadata.everyNthFrame).length;
|
|
35
|
+
return {
|
|
36
|
+
framesRendered: totalFrameCount,
|
|
37
|
+
bucket: bucketName,
|
|
38
|
+
renderSize: overallProgress.postRenderData.renderSize,
|
|
39
|
+
chunks: overallProgress.renderMetadata.totalChunks,
|
|
40
|
+
cleanup: {
|
|
41
|
+
doneIn: overallProgress.postRenderData.timeToCleanUp,
|
|
42
|
+
filesDeleted: overallProgress.postRenderData.filesCleanedUp,
|
|
43
|
+
minFilesToDelete: overallProgress.postRenderData.filesCleanedUp,
|
|
44
|
+
},
|
|
45
|
+
costs: {
|
|
46
|
+
accruedSoFar: overallProgress.postRenderData.cost.estimatedCost,
|
|
47
|
+
displayCost: overallProgress.postRenderData.cost.estimatedDisplayCost,
|
|
48
|
+
currency: overallProgress.postRenderData.cost.currency,
|
|
49
|
+
disclaimer: overallProgress.postRenderData.cost.disclaimer,
|
|
50
|
+
},
|
|
51
|
+
currentTime: Date.now(),
|
|
52
|
+
done: true,
|
|
53
|
+
encodingStatus: {
|
|
54
|
+
framesEncoded: totalFrameCount,
|
|
55
|
+
combinedFrames: totalFrameCount,
|
|
56
|
+
timeToCombine: overallProgress.postRenderData.timeToCombine,
|
|
57
|
+
},
|
|
58
|
+
errors: overallProgress.postRenderData.errors,
|
|
59
|
+
fatalErrorEncountered: false,
|
|
60
|
+
lambdasInvoked: overallProgress.renderMetadata.totalChunks,
|
|
61
|
+
outputFile: overallProgress.postRenderData.outputFile,
|
|
62
|
+
renderId,
|
|
63
|
+
timeToFinish: overallProgress.postRenderData.timeToFinish,
|
|
64
|
+
timeToFinishChunks: overallProgress.postRenderData.timeToRenderChunks,
|
|
65
|
+
timeToRenderFrames: overallProgress.postRenderData.timeToRenderFrames,
|
|
66
|
+
overallProgress: 1,
|
|
67
|
+
retriesInfo: overallProgress.postRenderData.retriesInfo,
|
|
68
|
+
outKey: outData.key,
|
|
69
|
+
outBucket: outData.renderBucketName,
|
|
70
|
+
mostExpensiveFrameRanges: (_a = overallProgress.postRenderData.mostExpensiveFrameRanges) !== null && _a !== void 0 ? _a : null,
|
|
71
|
+
timeToEncode: overallProgress.postRenderData.timeToEncode,
|
|
72
|
+
outputSizeInBytes: overallProgress.postRenderData.outputSize,
|
|
73
|
+
type: 'success',
|
|
74
|
+
estimatedBillingDurationInMilliseconds: overallProgress.postRenderData.estimatedBillingDurationInMilliseconds,
|
|
75
|
+
timeToCombine: overallProgress.postRenderData.timeToCombine,
|
|
76
|
+
combinedFrames: totalFrameCount,
|
|
77
|
+
renderMetadata: overallProgress.renderMetadata,
|
|
78
|
+
timeoutTimestamp: overallProgress.timeoutTimestamp,
|
|
79
|
+
compositionValidated: overallProgress.compositionValidated,
|
|
80
|
+
functionLaunched: overallProgress.functionLaunched,
|
|
81
|
+
serveUrlOpened: overallProgress.serveUrlOpened,
|
|
82
|
+
artifacts: overallProgress.receivedArtifact,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const { renderMetadata } = overallProgress;
|
|
86
|
+
const errorExplanations = (0, inspect_error_1.inspectErrors)({
|
|
87
|
+
errors: overallProgress.errors,
|
|
88
|
+
});
|
|
89
|
+
const { hasAudio, hasVideo } = renderMetadata
|
|
90
|
+
? (0, render_has_audio_video_1.lambdaRenderHasAudioVideo)(renderMetadata)
|
|
91
|
+
: { hasAudio: false, hasVideo: false };
|
|
92
|
+
const chunkCount = (_b = overallProgress.chunks.length) !== null && _b !== void 0 ? _b : 0;
|
|
93
|
+
const cleanup = {
|
|
94
|
+
doneIn: null,
|
|
95
|
+
minFilesToDelete: 0,
|
|
96
|
+
filesDeleted: 0,
|
|
97
|
+
};
|
|
98
|
+
if (renderMetadata === null) {
|
|
99
|
+
return {
|
|
100
|
+
framesRendered: (_c = overallProgress.framesRendered) !== null && _c !== void 0 ? _c : 0,
|
|
101
|
+
chunks: chunkCount,
|
|
102
|
+
done: false,
|
|
103
|
+
encodingStatus: {
|
|
104
|
+
framesEncoded: overallProgress.framesEncoded,
|
|
105
|
+
combinedFrames: overallProgress.combinedFrames,
|
|
106
|
+
timeToCombine: overallProgress.timeToCombine,
|
|
107
|
+
},
|
|
108
|
+
timeToRenderFrames: overallProgress.timeToRenderFrames,
|
|
109
|
+
costs: (0, format_costs_info_1.formatCostsInfo)(0),
|
|
110
|
+
renderId,
|
|
111
|
+
renderMetadata,
|
|
112
|
+
bucket: bucketName,
|
|
113
|
+
outputFile: null,
|
|
114
|
+
timeToFinish: null,
|
|
115
|
+
errors: errorExplanations,
|
|
116
|
+
fatalErrorEncountered: errorExplanations.some((f) => f.isFatal && !f.willRetry),
|
|
117
|
+
currentTime: Date.now(),
|
|
118
|
+
renderSize: 0,
|
|
119
|
+
lambdasInvoked: (_d = overallProgress.lambdasInvoked) !== null && _d !== void 0 ? _d : 0,
|
|
120
|
+
cleanup,
|
|
121
|
+
timeToFinishChunks: null,
|
|
122
|
+
overallProgress: (0, get_overall_progress_1.getOverallProgress)({
|
|
123
|
+
encoding: 0,
|
|
124
|
+
invoking: 0,
|
|
125
|
+
frames: 0,
|
|
126
|
+
gotComposition: overallProgress.compositionValidated,
|
|
127
|
+
visitedServeUrl: overallProgress.serveUrlOpened,
|
|
128
|
+
invokedLambda: overallProgress.lambdasInvoked,
|
|
129
|
+
combining: 0,
|
|
130
|
+
}),
|
|
131
|
+
retriesInfo: (_e = overallProgress.retries) !== null && _e !== void 0 ? _e : [],
|
|
132
|
+
outKey: null,
|
|
133
|
+
outBucket: null,
|
|
134
|
+
mostExpensiveFrameRanges: null,
|
|
135
|
+
timeToEncode: overallProgress.timeToEncode,
|
|
136
|
+
outputSizeInBytes: null,
|
|
137
|
+
estimatedBillingDurationInMilliseconds: null,
|
|
138
|
+
combinedFrames: (_f = overallProgress.combinedFrames) !== null && _f !== void 0 ? _f : 0,
|
|
139
|
+
timeToCombine: (_g = overallProgress.timeToCombine) !== null && _g !== void 0 ? _g : null,
|
|
140
|
+
timeoutTimestamp: overallProgress.timeoutTimestamp,
|
|
141
|
+
type: 'success',
|
|
142
|
+
compositionValidated: overallProgress.compositionValidated,
|
|
143
|
+
functionLaunched: overallProgress.functionLaunched,
|
|
144
|
+
serveUrlOpened: overallProgress.serveUrlOpened,
|
|
145
|
+
artifacts: overallProgress.receivedArtifact,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const priceFromBucket = (0, estimate_price_from_bucket_1.estimatePriceFromBucket)({
|
|
149
|
+
renderMetadata,
|
|
150
|
+
memorySizeInMb,
|
|
151
|
+
lambdasInvoked: (_h = renderMetadata.estimatedRenderLambdaInvokations) !== null && _h !== void 0 ? _h : 0,
|
|
152
|
+
diskSizeInMb: providerSpecifics.getEphemeralStorageForPriceCalculation(),
|
|
153
|
+
timings: (_j = overallProgress.timings) !== null && _j !== void 0 ? _j : [],
|
|
154
|
+
region,
|
|
155
|
+
providerSpecifics,
|
|
156
|
+
});
|
|
157
|
+
const chunkMultiplier = [hasAudio, hasVideo].filter(truthy_1.truthy).length;
|
|
158
|
+
if (renderMetadata.type === 'still') {
|
|
159
|
+
throw new Error("You don't need to call getRenderProgress() on a still render. Once you have obtained the `renderId`, the render is already done! 😉");
|
|
160
|
+
}
|
|
161
|
+
const allChunks = ((_k = overallProgress.chunks) !== null && _k !== void 0 ? _k : []).length / chunkMultiplier ===
|
|
162
|
+
((_l = renderMetadata.totalChunks) !== null && _l !== void 0 ? _l : Infinity);
|
|
163
|
+
const frameCount = pure_1.NoReactAPIs.getFramesToRender(renderMetadata.frameRange, renderMetadata.everyNthFrame).length;
|
|
164
|
+
const missingChunks = new Array(renderMetadata.totalChunks)
|
|
165
|
+
.fill(true)
|
|
166
|
+
.map((_, i) => i)
|
|
167
|
+
.filter((index) => {
|
|
168
|
+
var _a;
|
|
169
|
+
return (typeof ((_a = overallProgress.chunks) !== null && _a !== void 0 ? _a : []).find((c) => c === index) ===
|
|
170
|
+
'undefined');
|
|
171
|
+
});
|
|
172
|
+
// We add a 20 second buffer for it, since AWS timeshifts can be quite a lot. Once it's 20sec over the limit, we consider it timed out
|
|
173
|
+
// 1. If we have missing chunks, we consider it timed out
|
|
174
|
+
const isBeyondTimeoutAndMissingChunks = Date.now() > renderMetadata.startedDate + timeoutInMilliseconds + 20000 &&
|
|
175
|
+
missingChunks &&
|
|
176
|
+
missingChunks.length > 0;
|
|
177
|
+
// 2. If we have no missing chunks, but the encoding is not done, even after the additional `merge` function has been spawned, we consider it timed out
|
|
178
|
+
const isBeyondTimeoutAndHasStitchTimeout = Date.now() > renderMetadata.startedDate + timeoutInMilliseconds * 2 + 20000;
|
|
179
|
+
const allErrors = [
|
|
180
|
+
isBeyondTimeoutAndMissingChunks || isBeyondTimeoutAndHasStitchTimeout
|
|
181
|
+
? (0, make_timeout_error_1.makeTimeoutError)({
|
|
182
|
+
timeoutInMilliseconds,
|
|
183
|
+
renderMetadata,
|
|
184
|
+
renderId,
|
|
185
|
+
missingChunks: missingChunks !== null && missingChunks !== void 0 ? missingChunks : [],
|
|
186
|
+
region,
|
|
187
|
+
functionName,
|
|
188
|
+
providerSpecifics,
|
|
189
|
+
})
|
|
190
|
+
: null,
|
|
191
|
+
...errorExplanations,
|
|
192
|
+
].filter(no_react_1.NoReactInternals.truthy);
|
|
193
|
+
return {
|
|
194
|
+
framesRendered: (_m = overallProgress.framesRendered) !== null && _m !== void 0 ? _m : 0,
|
|
195
|
+
chunks: chunkCount,
|
|
196
|
+
done: false,
|
|
197
|
+
encodingStatus: {
|
|
198
|
+
framesEncoded: overallProgress.framesEncoded,
|
|
199
|
+
combinedFrames: overallProgress.combinedFrames,
|
|
200
|
+
timeToCombine: overallProgress.timeToCombine,
|
|
201
|
+
},
|
|
202
|
+
timeToRenderFrames: overallProgress.timeToRenderFrames,
|
|
203
|
+
costs: priceFromBucket
|
|
204
|
+
? (0, format_costs_info_1.formatCostsInfo)(priceFromBucket.accruedSoFar)
|
|
205
|
+
: (0, format_costs_info_1.formatCostsInfo)(0),
|
|
206
|
+
renderId,
|
|
207
|
+
renderMetadata,
|
|
208
|
+
bucket: bucketName,
|
|
209
|
+
outputFile: null,
|
|
210
|
+
timeToFinish: null,
|
|
211
|
+
errors: allErrors,
|
|
212
|
+
fatalErrorEncountered: allErrors.some((f) => f.isFatal && !f.willRetry),
|
|
213
|
+
currentTime: Date.now(),
|
|
214
|
+
renderSize: 0,
|
|
215
|
+
lambdasInvoked: (_o = overallProgress.lambdasInvoked) !== null && _o !== void 0 ? _o : 0,
|
|
216
|
+
cleanup,
|
|
217
|
+
timeToFinishChunks: allChunks && overallProgress
|
|
218
|
+
? (0, calculate_chunk_times_1.calculateChunkTimes)({
|
|
219
|
+
type: 'absolute-time',
|
|
220
|
+
timings: overallProgress.timings,
|
|
221
|
+
})
|
|
222
|
+
: null,
|
|
223
|
+
overallProgress: (0, get_overall_progress_1.getOverallProgress)({
|
|
224
|
+
encoding: frameCount
|
|
225
|
+
? ((_p = overallProgress.framesEncoded) !== null && _p !== void 0 ? _p : 0) / frameCount
|
|
226
|
+
: 0,
|
|
227
|
+
invoking: ((_q = overallProgress.lambdasInvoked) !== null && _q !== void 0 ? _q : 0) /
|
|
228
|
+
renderMetadata.estimatedRenderLambdaInvokations,
|
|
229
|
+
frames: ((_r = overallProgress.framesRendered) !== null && _r !== void 0 ? _r : 0) / (frameCount !== null && frameCount !== void 0 ? frameCount : 1),
|
|
230
|
+
gotComposition: overallProgress.compositionValidated,
|
|
231
|
+
visitedServeUrl: overallProgress.serveUrlOpened,
|
|
232
|
+
invokedLambda: overallProgress.lambdasInvoked,
|
|
233
|
+
combining: overallProgress.combinedFrames / (frameCount !== null && frameCount !== void 0 ? frameCount : 1),
|
|
234
|
+
}),
|
|
235
|
+
retriesInfo: (_s = overallProgress.retries) !== null && _s !== void 0 ? _s : [],
|
|
236
|
+
outKey: null,
|
|
237
|
+
outBucket: null,
|
|
238
|
+
mostExpensiveFrameRanges: null,
|
|
239
|
+
timeToEncode: overallProgress.timeToEncode,
|
|
240
|
+
outputSizeInBytes: null,
|
|
241
|
+
estimatedBillingDurationInMilliseconds: priceFromBucket
|
|
242
|
+
? priceFromBucket.estimatedBillingDurationInMilliseconds
|
|
243
|
+
: null,
|
|
244
|
+
combinedFrames: (_t = overallProgress.combinedFrames) !== null && _t !== void 0 ? _t : 0,
|
|
245
|
+
timeToCombine: (_u = overallProgress.timeToCombine) !== null && _u !== void 0 ? _u : null,
|
|
246
|
+
timeoutTimestamp: overallProgress.timeoutTimestamp,
|
|
247
|
+
type: 'success',
|
|
248
|
+
compositionValidated: overallProgress.compositionValidated,
|
|
249
|
+
functionLaunched: overallProgress.functionLaunched,
|
|
250
|
+
serveUrlOpened: overallProgress.serveUrlOpened,
|
|
251
|
+
artifacts: overallProgress.receivedArtifact,
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
exports.getProgress = getProgress;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RenderMetadata } from './render-metadata';
|
|
2
|
+
import type { CloudProvider } from './types';
|
|
3
|
+
export declare const lambdaRenderHasAudioVideo: <Provider extends CloudProvider>(renderMetadata: RenderMetadata<Provider>) => {
|
|
4
|
+
hasAudio: boolean;
|
|
5
|
+
hasVideo: boolean;
|
|
6
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lambdaRenderHasAudioVideo = void 0;
|
|
4
|
+
const pure_1 = require("@remotion/renderer/pure");
|
|
5
|
+
const lambdaRenderHasAudioVideo = (renderMetadata) => {
|
|
6
|
+
if (renderMetadata.type === 'still') {
|
|
7
|
+
throw new Error('Cannot merge stills');
|
|
8
|
+
}
|
|
9
|
+
const support = pure_1.NoReactAPIs.codecSupportsMedia(renderMetadata.codec);
|
|
10
|
+
const hasVideo = renderMetadata
|
|
11
|
+
? !pure_1.NoReactAPIs.isAudioCodec(renderMetadata.codec)
|
|
12
|
+
: false;
|
|
13
|
+
const hasAudio = renderMetadata
|
|
14
|
+
? !renderMetadata.muted && support.audio
|
|
15
|
+
: false;
|
|
16
|
+
return {
|
|
17
|
+
hasAudio,
|
|
18
|
+
hasVideo,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.lambdaRenderHasAudioVideo = lambdaRenderHasAudioVideo;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ExpensiveChunk } from './most-expensive-chunks';
|
|
2
|
+
import type { RenderMetadata } from './render-metadata';
|
|
3
|
+
import type { ChunkRetry, CloudProvider, CostsInfo, ReceivedArtifact } from './types';
|
|
4
|
+
import type { EnhancedErrorInfo } from './write-lambda-error';
|
|
5
|
+
export type CleanupInfo = {
|
|
6
|
+
doneIn: number | null;
|
|
7
|
+
minFilesToDelete: number;
|
|
8
|
+
filesDeleted: number;
|
|
9
|
+
};
|
|
10
|
+
type EncodingProgress = {
|
|
11
|
+
framesEncoded: number;
|
|
12
|
+
combinedFrames: number;
|
|
13
|
+
timeToCombine: number | null;
|
|
14
|
+
};
|
|
15
|
+
export type GenericRenderProgress<Provider extends CloudProvider> = {
|
|
16
|
+
chunks: number;
|
|
17
|
+
done: boolean;
|
|
18
|
+
encodingStatus: EncodingProgress | null;
|
|
19
|
+
costs: CostsInfo;
|
|
20
|
+
renderId: string;
|
|
21
|
+
renderMetadata: RenderMetadata<Provider> | null;
|
|
22
|
+
bucket: string;
|
|
23
|
+
outputFile: string | null;
|
|
24
|
+
outKey: string | null;
|
|
25
|
+
outBucket: string | null;
|
|
26
|
+
timeToFinish: number | null;
|
|
27
|
+
errors: EnhancedErrorInfo[];
|
|
28
|
+
fatalErrorEncountered: boolean;
|
|
29
|
+
currentTime: number;
|
|
30
|
+
renderSize: number;
|
|
31
|
+
lambdasInvoked: number;
|
|
32
|
+
cleanup: CleanupInfo | null;
|
|
33
|
+
timeToFinishChunks: number | null;
|
|
34
|
+
timeToRenderFrames: number | null;
|
|
35
|
+
timeToEncode: number | null;
|
|
36
|
+
overallProgress: number;
|
|
37
|
+
retriesInfo: ChunkRetry[];
|
|
38
|
+
mostExpensiveFrameRanges: ExpensiveChunk[] | null;
|
|
39
|
+
framesRendered: number;
|
|
40
|
+
outputSizeInBytes: number | null;
|
|
41
|
+
type: 'success';
|
|
42
|
+
estimatedBillingDurationInMilliseconds: number | null;
|
|
43
|
+
combinedFrames: number;
|
|
44
|
+
timeToCombine: number | null;
|
|
45
|
+
timeoutTimestamp: number;
|
|
46
|
+
functionLaunched: number;
|
|
47
|
+
serveUrlOpened: number | null;
|
|
48
|
+
compositionValidated: number | null;
|
|
49
|
+
artifacts: ReceivedArtifact<Provider>[];
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { VideoConfig } from 'remotion/no-react';
|
|
2
|
+
import type { ServerlessRoutines } from './constants';
|
|
3
|
+
import type { GenericRenderProgress } from './render-progress';
|
|
4
|
+
import type { CloudProvider } from './types';
|
|
5
|
+
export type OrError<T> = T | {
|
|
6
|
+
type: 'error';
|
|
7
|
+
message: string;
|
|
8
|
+
stack: string;
|
|
9
|
+
};
|
|
10
|
+
export interface ServerlessReturnValues<Provider extends CloudProvider> {
|
|
11
|
+
[ServerlessRoutines.start]: Promise<{
|
|
12
|
+
type: 'success';
|
|
13
|
+
bucketName: string;
|
|
14
|
+
renderId: string;
|
|
15
|
+
}>;
|
|
16
|
+
[ServerlessRoutines.launch]: Promise<{
|
|
17
|
+
type: 'success';
|
|
18
|
+
}>;
|
|
19
|
+
[ServerlessRoutines.renderer]: Promise<{
|
|
20
|
+
type: 'success';
|
|
21
|
+
}>;
|
|
22
|
+
[ServerlessRoutines.status]: Promise<GenericRenderProgress<Provider>>;
|
|
23
|
+
[ServerlessRoutines.info]: {
|
|
24
|
+
version: string;
|
|
25
|
+
type: 'success';
|
|
26
|
+
};
|
|
27
|
+
[ServerlessRoutines.still]: Promise<{
|
|
28
|
+
type: 'success';
|
|
29
|
+
} | {
|
|
30
|
+
type: 'error';
|
|
31
|
+
message: string;
|
|
32
|
+
stack: string;
|
|
33
|
+
}>;
|
|
34
|
+
[ServerlessRoutines.compositions]: Promise<{
|
|
35
|
+
compositions: VideoConfig[];
|
|
36
|
+
type: 'success';
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stackback = void 0;
|
|
4
|
+
function FormatStackTrace(error, frames) {
|
|
5
|
+
const lines = [];
|
|
6
|
+
try {
|
|
7
|
+
lines.push(error.toString());
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
try {
|
|
11
|
+
lines.push('<error: ' + e + '>');
|
|
12
|
+
}
|
|
13
|
+
catch (_a) {
|
|
14
|
+
lines.push('<error>');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
for (let i = 0; i < frames.length; i++) {
|
|
18
|
+
const frame = frames[i];
|
|
19
|
+
let line;
|
|
20
|
+
try {
|
|
21
|
+
line = frame.toString();
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
try {
|
|
25
|
+
line = '<error: ' + e + '>';
|
|
26
|
+
}
|
|
27
|
+
catch (_b) {
|
|
28
|
+
// Any code that reaches this point is seriously nasty!
|
|
29
|
+
line = '<error>';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
lines.push(' at ' + line);
|
|
33
|
+
}
|
|
34
|
+
return lines.join('\n');
|
|
35
|
+
}
|
|
36
|
+
const stackback = (error) => {
|
|
37
|
+
// save original stacktrace
|
|
38
|
+
const save = Error.prepareStackTrace;
|
|
39
|
+
// replace capture with our function
|
|
40
|
+
Error.prepareStackTrace = function (err, trace) {
|
|
41
|
+
// cache stack frames so we don't have to get them again
|
|
42
|
+
// use a non-enumerable property
|
|
43
|
+
Object.defineProperty(err, '_sb_callsites', {
|
|
44
|
+
value: trace,
|
|
45
|
+
});
|
|
46
|
+
return (save || FormatStackTrace)(err, trace);
|
|
47
|
+
};
|
|
48
|
+
// force capture of the stack frames
|
|
49
|
+
// eslint-disable-next-line no-unused-expressions
|
|
50
|
+
error.stack;
|
|
51
|
+
// someone already asked for the stack so we can't do this trick
|
|
52
|
+
if (!error._sb_callsites) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
// return original capture function
|
|
56
|
+
Error.prepareStackTrace = save;
|
|
57
|
+
return error._sb_callsites;
|
|
58
|
+
};
|
|
59
|
+
exports.stackback = stackback;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EmittedArtifact, LogLevel } from '@remotion/renderer';
|
|
2
|
+
import type { ServerlessPayload } from './constants';
|
|
3
|
+
import type { OverallProgressHelper } from './overall-render-progress';
|
|
4
|
+
import type { ProviderSpecifics } from './provider-implementation';
|
|
5
|
+
import type { CloudProvider } from './types';
|
|
6
|
+
export declare const streamRendererFunctionWithRetry: <Provider extends CloudProvider>({ payload, files, functionName, outdir, overallProgress, logLevel, onArtifact, providerSpecifics, }: {
|
|
7
|
+
payload: ServerlessPayload<Provider>;
|
|
8
|
+
functionName: string;
|
|
9
|
+
outdir: string;
|
|
10
|
+
overallProgress: OverallProgressHelper<Provider>;
|
|
11
|
+
files: string[];
|
|
12
|
+
logLevel: LogLevel;
|
|
13
|
+
onArtifact: (asset: EmittedArtifact) => {
|
|
14
|
+
alreadyExisted: boolean;
|
|
15
|
+
};
|
|
16
|
+
providerSpecifics: ProviderSpecifics<Provider>;
|
|
17
|
+
}) => Promise<unknown>;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.streamRendererFunctionWithRetry = void 0;
|
|
4
|
+
const renderer_1 = require("@remotion/renderer");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const serialize_artifact_1 = require("./serialize-artifact");
|
|
9
|
+
const streamRenderer = ({ payload, functionName, outdir, overallProgress, files, logLevel, onArtifact, providerSpecifics, }) => {
|
|
10
|
+
if (payload.type !== constants_1.ServerlessRoutines.renderer) {
|
|
11
|
+
throw new Error('Expected renderer type');
|
|
12
|
+
}
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
const receivedStreamingPayload = ({ message }) => {
|
|
15
|
+
if (message.type === 'lambda-invoked') {
|
|
16
|
+
overallProgress.setLambdaInvoked(payload.chunk);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (message.type === 'frames-rendered') {
|
|
20
|
+
overallProgress.setFrames({
|
|
21
|
+
index: payload.chunk,
|
|
22
|
+
encoded: message.payload.encoded,
|
|
23
|
+
rendered: message.payload.rendered,
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (message.type === 'video-chunk-rendered') {
|
|
28
|
+
const filename = (0, path_1.join)(outdir, `chunk:${String(payload.chunk).padStart(8, '0')}:video`);
|
|
29
|
+
(0, fs_1.writeFileSync)(filename, message.payload);
|
|
30
|
+
files.push(filename);
|
|
31
|
+
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `Received video chunk for chunk ${payload.chunk}`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (message.type === 'audio-chunk-rendered') {
|
|
35
|
+
const filename = (0, path_1.join)(outdir, `chunk:${String(payload.chunk).padStart(8, '0')}:audio`);
|
|
36
|
+
(0, fs_1.writeFileSync)(filename, message.payload);
|
|
37
|
+
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `Received audio chunk for chunk ${payload.chunk}`);
|
|
38
|
+
files.push(filename);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (message.type === 'chunk-complete') {
|
|
42
|
+
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `Finished chunk ${payload.chunk}`);
|
|
43
|
+
overallProgress.addChunkCompleted(payload.chunk, message.payload.start, message.payload.rendered);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (message.type === 'artifact-emitted') {
|
|
47
|
+
const artifact = (0, serialize_artifact_1.deserializeArtifact)(message.payload.artifact);
|
|
48
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `Received artifact on frame ${message.payload.artifact.frame}:`, artifact.filename, artifact.content.length + 'bytes.');
|
|
49
|
+
const { alreadyExisted } = onArtifact(artifact);
|
|
50
|
+
if (alreadyExisted) {
|
|
51
|
+
return resolve({
|
|
52
|
+
type: 'error',
|
|
53
|
+
error: `Chunk ${payload.chunk} emitted an asset filename ${message.payload.artifact.filename} at frame ${message.payload.artifact.frame} but there is already another artifact with the same name. https://remotion.dev/docs/artifacts`,
|
|
54
|
+
shouldRetry: false,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (message.type === 'error-occurred') {
|
|
60
|
+
overallProgress.addErrorWithoutUpload(message.payload.errorInfo);
|
|
61
|
+
overallProgress.setFrames({
|
|
62
|
+
encoded: 0,
|
|
63
|
+
index: payload.chunk,
|
|
64
|
+
rendered: 0,
|
|
65
|
+
});
|
|
66
|
+
renderer_1.RenderInternals.Log.error({
|
|
67
|
+
indent: false,
|
|
68
|
+
logLevel,
|
|
69
|
+
}, `Renderer function of chunk ${payload.chunk} failed with error: ${message.payload.error}`);
|
|
70
|
+
renderer_1.RenderInternals.Log.error({
|
|
71
|
+
indent: false,
|
|
72
|
+
logLevel,
|
|
73
|
+
}, `Will retry chunk = ${message.payload.shouldRetry}`);
|
|
74
|
+
resolve({
|
|
75
|
+
type: 'error',
|
|
76
|
+
error: message.payload.error,
|
|
77
|
+
shouldRetry: message.payload.shouldRetry,
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
throw new Error(`Unknown message type ${message.type}`);
|
|
82
|
+
};
|
|
83
|
+
providerSpecifics
|
|
84
|
+
.callFunctionStreaming({
|
|
85
|
+
functionName,
|
|
86
|
+
payload,
|
|
87
|
+
retriesRemaining: 1,
|
|
88
|
+
region: providerSpecifics.getCurrentRegionInFunction(),
|
|
89
|
+
timeoutInTest: 12000,
|
|
90
|
+
type: constants_1.ServerlessRoutines.renderer,
|
|
91
|
+
receivedStreamingPayload,
|
|
92
|
+
})
|
|
93
|
+
.then(() => {
|
|
94
|
+
resolve({
|
|
95
|
+
type: 'success',
|
|
96
|
+
});
|
|
97
|
+
})
|
|
98
|
+
.catch((err) => {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
const shouldRetry = (_b = (_a = err.stack) === null || _a === void 0 ? void 0 : _a.includes('Error: aborted')) !== null && _b !== void 0 ? _b : false;
|
|
101
|
+
resolve({
|
|
102
|
+
type: 'error',
|
|
103
|
+
error: err.stack,
|
|
104
|
+
shouldRetry,
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
const streamRendererFunctionWithRetry = async ({ payload, files, functionName, outdir, overallProgress, logLevel, onArtifact, providerSpecifics, }) => {
|
|
110
|
+
if (payload.type !== constants_1.ServerlessRoutines.renderer) {
|
|
111
|
+
throw new Error('Expected renderer type');
|
|
112
|
+
}
|
|
113
|
+
const result = await streamRenderer({
|
|
114
|
+
files,
|
|
115
|
+
functionName,
|
|
116
|
+
outdir,
|
|
117
|
+
overallProgress,
|
|
118
|
+
payload,
|
|
119
|
+
logLevel,
|
|
120
|
+
onArtifact,
|
|
121
|
+
providerSpecifics,
|
|
122
|
+
});
|
|
123
|
+
if (result.type === 'error') {
|
|
124
|
+
if (!result.shouldRetry) {
|
|
125
|
+
throw new Error(result.error);
|
|
126
|
+
}
|
|
127
|
+
overallProgress.addRetry({
|
|
128
|
+
attempt: payload.attempt + 1,
|
|
129
|
+
time: Date.now(),
|
|
130
|
+
chunk: payload.chunk,
|
|
131
|
+
});
|
|
132
|
+
return (0, exports.streamRendererFunctionWithRetry)({
|
|
133
|
+
files,
|
|
134
|
+
functionName,
|
|
135
|
+
outdir,
|
|
136
|
+
overallProgress,
|
|
137
|
+
payload: {
|
|
138
|
+
...payload,
|
|
139
|
+
attempt: payload.attempt + 1,
|
|
140
|
+
retriesLeft: payload.retriesLeft - 1,
|
|
141
|
+
},
|
|
142
|
+
logLevel,
|
|
143
|
+
onArtifact,
|
|
144
|
+
providerSpecifics,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
exports.streamRendererFunctionWithRetry = streamRendererFunctionWithRetry;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ServerlessPayloads, ServerlessRoutines } from './constants';
|
|
2
|
+
export interface CloudProvider<Region extends string = string, ReceivedArtifactType extends Record<string, unknown> = Record<string, unknown>> {
|
|
3
|
+
type: string;
|
|
4
|
+
region: Region;
|
|
5
|
+
receivedArtifactType: ReceivedArtifactType;
|
|
6
|
+
}
|
|
7
|
+
export type ReceivedArtifact<Provider extends CloudProvider> = {
|
|
8
|
+
filename: string;
|
|
9
|
+
sizeInBytes: number;
|
|
10
|
+
s3Url: string;
|
|
11
|
+
s3Key: string;
|
|
12
|
+
} & Provider['receivedArtifactType'];
|
|
13
|
+
export type CostsInfo = {
|
|
14
|
+
accruedSoFar: number;
|
|
15
|
+
displayCost: string;
|
|
16
|
+
currency: string;
|
|
17
|
+
disclaimer: string;
|
|
18
|
+
};
|
|
19
|
+
export type RenderStillLambdaResponsePayload<Provider extends CloudProvider> = {
|
|
20
|
+
type: 'success';
|
|
21
|
+
output: string;
|
|
22
|
+
outKey: string;
|
|
23
|
+
size: number;
|
|
24
|
+
bucketName: string;
|
|
25
|
+
sizeInBytes: number;
|
|
26
|
+
estimatedPrice: CostsInfo;
|
|
27
|
+
renderId: string;
|
|
28
|
+
receivedArtifacts: ReceivedArtifact<Provider>[];
|
|
29
|
+
};
|
|
30
|
+
export type ChunkRetry = {
|
|
31
|
+
chunk: number;
|
|
32
|
+
attempt: number;
|
|
33
|
+
time: number;
|
|
34
|
+
};
|
|
35
|
+
export type ParsedTiming = {
|
|
36
|
+
chunk: number;
|
|
37
|
+
start: number;
|
|
38
|
+
rendered: number;
|
|
39
|
+
};
|
|
40
|
+
export type CallFunctionOptions<T extends ServerlessRoutines, Provider extends CloudProvider> = {
|
|
41
|
+
functionName: string;
|
|
42
|
+
type: T;
|
|
43
|
+
payload: ServerlessPayloads<Provider>[T];
|
|
44
|
+
region: Provider['region'];
|
|
45
|
+
timeoutInTest: number;
|
|
46
|
+
};
|
|
47
|
+
export type ObjectChunkTimingData = {
|
|
48
|
+
chunk: number;
|
|
49
|
+
frameRange: [number, number];
|
|
50
|
+
startDate: number;
|
|
51
|
+
timings: {
|
|
52
|
+
[key: number]: number;
|
|
53
|
+
};
|
|
54
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const validateDownloadBehavior: (downloadBehavior: unknown) => null | undefined;
|