Skip to content

🎥 Make videos programmatically with React

fix timing profiles

Jonny Burger8ced0562e50e
diff --git a/packages/docs/docs/lambda.md b/packages/docs/docs/lambda.md
index 61b31f263b..5fad65e77c 100644
--- a/packages/docs/docs/lambda.md
+++ b/packages/docs/docs/lambda.md
@@ -30,6 +30,15 @@ title: "@remotion/lambda"
[**See here**](/docs/lambda-setup)
+## Considerations
+
+Currently hardcoded but you will need to decide in the future:
+
+- Decide memory limit
+- Decide lambda timeout
+- Decide parallelism
+- Decide Region
+
## Limitations
- You only have 512MB of storage available in lambda function. This must be sufficient for both the chunks and the output, therefore the output file can only be about ~250MB maximum.
diff --git a/packages/lambda/src/cli/render.ts b/packages/lambda/src/cli/render.ts
index 1099cf6ab9..8986fc4855 100644
--- a/packages/lambda/src/cli/render.ts
+++ b/packages/lambda/src/cli/render.ts
@@ -19,7 +19,9 @@ export const renderCommand = async () => {
'Pass an additional argument specifying a URL where your Remotion project is hosted.'
);
Log.info();
- Log.info(`${BINARY_NAME} render <http://remotion.s3.amazonaws.com>`);
+ Log.info(
+ `${BINARY_NAME} ${RENDER_COMMAND} <http://remotion.s3.amazonaws.com>`
+ );
process.exit(1);
}
diff --git a/packages/lambda/src/functions/chunk-optimization/collect-data.ts b/packages/lambda/src/functions/chunk-optimization/collect-data.ts
index 4ab6fb7449..206b9e45df 100644
--- a/packages/lambda/src/functions/chunk-optimization/collect-data.ts
+++ b/packages/lambda/src/functions/chunk-optimization/collect-data.ts
@@ -1,4 +1,4 @@
-import {rendersPrefix, timingProfileName} from '../../shared/constants';
+import {lambdaInitializedKey} from '../../../dist/constants';
import {streamToString} from '../../shared/stream-to-string';
import {lambdaLs, lambdaReadFile} from '../helpers/io';
import {ChunkTimingData} from './types';
@@ -7,7 +7,7 @@ export const collectChunkInformation = async (
bucketName: string,
renderId: string
) => {
- const prefix = rendersPrefix(timingProfileName(renderId));
+ const prefix = lambdaInitializedKey(renderId);
const timingFiles = await lambdaLs({
bucketName,
prefix,
diff --git a/packages/lambda/src/functions/chunk-optimization/optimize-profile.ts b/packages/lambda/src/functions/chunk-optimization/optimize-profile.ts
index c4d86537fd..17635e48bd 100644
--- a/packages/lambda/src/functions/chunk-optimization/optimize-profile.ts
+++ b/packages/lambda/src/functions/chunk-optimization/optimize-profile.ts
@@ -57,13 +57,13 @@ export const optimizeProfile = (_profile: TimingProfile) => {
const indexOfFastest = sortedByStart.indexOf(sortedByDuration[0]);
if (indexOfFastest === -1) {
- throw new Error('something went wrong');
+ throw new Error('invalid timing profile: ' + JSON.stringify(_profile));
}
const slowest = sortedByDuration[sortedByDuration.length - 1];
const indexOfSlowest = sortedByStart.indexOf(slowest);
if (indexOfSlowest === -1) {
- throw new Error('something went wrong');
+ throw new Error('invalid timing profile: ' + JSON.stringify(_profile));
}
const frameRanges = getFrameRangesFromProfile(sortedByStart);
diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.ts
index a7587340ea..891c5f622d 100644
--- a/packages/lambda/src/functions/renderer.ts
+++ b/packages/lambda/src/functions/renderer.ts
@@ -134,13 +134,18 @@ const renderHandler = async (params: LambdaPayload) => {
});
stitchLabel.end();
- await lambdaWriteFile({
- bucketName: params.bucketName,
- key: `${chunkKey(params.renderId)}${String(params.chunk).padStart(8, '0')}`,
- body: fs.createReadStream(outputLocation),
- });
await Promise.all([
uploadMetricsData,
+ lambdaWriteFile({
+ bucketName: params.bucketName,
+ key: `${chunkKey(params.renderId)}${String(params.chunk).padStart(
+ 8,
+ '0'
+ )}`,
+ body: fs.createReadStream(outputLocation),
+ }),
+ ]);
+ await Promise.all([
fs.promises.rm(outputLocation, {recursive: true}),
fs.promises.rm(outputPath, {recursive: true}),
]);