Skip to content

🎥 Make videos programmatically with React

refactor

Jonny Burger57413cd67674
diff --git a/packages/lambda/src/cli/commands/render/progress.ts b/packages/lambda/src/cli/commands/render/progress.ts
index e0052b7cff..3afd171fb1 100644
--- a/packages/lambda/src/cli/commands/render/progress.ts
+++ b/packages/lambda/src/cli/commands/render/progress.ts
@@ -12,7 +12,6 @@ import {truthy} from '../../../shared/truthy';
type LambdaInvokeProgress = {
totalLambdas: number | null;
lambdasInvoked: number;
- doneIn: number | null;
};
type ChunkProgress = {
@@ -35,20 +34,16 @@ const makeInvokeProgress = (
totalSteps: number,
retriesInfo: ChunkRetry[]
) => {
- const {lambdasInvoked, totalLambdas, doneIn} = invokeProgress;
- const progress = doneIn
- ? 1
- : totalLambdas === null
- ? 0
- : lambdasInvoked / totalLambdas;
+ const {lambdasInvoked, totalLambdas} = invokeProgress;
+ const progress = totalLambdas === null ? 0 : lambdasInvoked / totalLambdas;
return [
'⚡️',
`(1/${totalSteps})`,
CliInternals.makeProgressBar(progress),
- `${doneIn === null ? 'Invoking' : 'Invoked'} lambdas`,
- doneIn === null
- ? `${Math.round(progress * 100)}%`
- : CliInternals.chalk.gray(`${doneIn}ms`),
+ `${progress === 0 ? 'Invoked' : 'Invoking'} lambdas`,
+ progress === 1
+ ? CliInternals.chalk.gray('100%')
+ : `${Math.round(progress * 100)}%`,
retriesInfo.length > 0 ? `(+${retriesInfo.length} retries)` : [],
].join(' ');
};
@@ -100,12 +95,16 @@ const makeEncodingProgress = ({
encodingProgress,
chunkProgress,
totalSteps,
+ totalFrames,
+ timeToEncode: doneIn,
}: {
encodingProgress: EncodingProgress;
chunkProgress: ChunkProgress;
totalSteps: number;
+ totalFrames: number | null;
+ timeToEncode: number | null;
}) => {
- const {framesEncoded, totalFrames, doneIn} = encodingProgress;
+ const {framesEncoded} = encodingProgress;
const progress = totalFrames === null ? 0 : framesEncoded / totalFrames;
const chunksDone = chunkProgress.doneIn !== null;
const shouldShow = progress > 0 || chunksDone;
@@ -200,12 +199,8 @@ export const makeMultiProgressFromStatus = (
},
encodingProgress: {
framesEncoded: status.encodingStatus?.framesEncoded ?? 0,
- totalFrames: status.renderMetadata?.videoConfig.durationInFrames ?? 1,
- doneIn: status.encodingStatus?.doneIn ?? null,
- timeToInvoke: status.encodingStatus?.timeToInvoke ?? null,
},
lambdaInvokeProgress: {
- doneIn: status.timeToInvokeLambdas,
lambdasInvoked: status.lambdasInvoked,
totalLambdas:
status.renderMetadata?.estimatedRenderLambdaInvokations ?? null,
@@ -226,12 +221,16 @@ export const makeProgressString = ({
downloadInfo,
retriesInfo,
verbose,
+ timeToEncodeIn,
+ totalFrames,
}: {
progress: MultiRenderProgress;
steps: number;
downloadInfo: DownloadedInfo | null;
retriesInfo: ChunkRetry[];
verbose: boolean;
+ timeToEncodeIn: number | null;
+ totalFrames: number | null;
}) => {
return [
makeInvokeProgress(progress.lambdaInvokeProgress, steps, retriesInfo),
@@ -243,6 +242,8 @@ export const makeProgressString = ({
encodingProgress: progress.encodingProgress,
chunkProgress: progress.chunkProgress,
totalSteps: steps,
+ timeToEncode: timeToEncodeIn,
+ totalFrames,
}),
makeCleanupProgress(progress.cleanupInfo, steps, verbose),
downloadInfo ? makeDownloadProgress(downloadInfo, steps) : null,
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index 1c485e0f54..f12e8c41a2 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -3,6 +3,7 @@ import {getCompositions, RenderInternals} from '@remotion/renderer';
import {downloadMedia} from '../../../api/download-media';
import {getRenderProgress} from '../../../api/get-render-progress';
import {renderMediaOnLambda} from '../../../api/render-media-on-lambda';
+import type {RenderProgress} from '../../../shared/constants';
import {
BINARY_NAME,
DEFAULT_MAX_RETRIES,
@@ -173,6 +174,8 @@ export const renderCommand = async (args: string[], remotionRoot: string) => {
downloadInfo: null,
retriesInfo: status.retriesInfo,
verbose,
+ totalFrames: getTotalFrames(status),
+ timeToEncodeIn: status.timeToEncode,
})
);
@@ -193,6 +196,8 @@ export const renderCommand = async (args: string[], remotionRoot: string) => {
retriesInfo: newStatus.retriesInfo,
downloadInfo: null,
verbose,
+ timeToEncodeIn: newStatus.timeToEncode,
+ totalFrames: getTotalFrames(newStatus),
})
);
@@ -204,6 +209,8 @@ export const renderCommand = async (args: string[], remotionRoot: string) => {
downloadInfo: null,
retriesInfo: newStatus.retriesInfo,
verbose,
+ timeToEncodeIn: newStatus.timeToEncode,
+ totalFrames: getTotalFrames(newStatus),
})
);
if (downloadName) {
@@ -225,6 +232,8 @@ export const renderCommand = async (args: string[], remotionRoot: string) => {
totalSize,
},
verbose,
+ timeToEncodeIn: newStatus.timeToEncode,
+ totalFrames: getTotalFrames(newStatus),
})
);
},
@@ -240,6 +249,8 @@ export const renderCommand = async (args: string[], remotionRoot: string) => {
totalSize: sizeInBytes,
},
verbose,
+ timeToEncodeIn: newStatus.timeToEncode,
+ totalFrames: getTotalFrames(newStatus),
})
);
Log.info();
@@ -301,3 +312,12 @@ export const renderCommand = async (args: string[], remotionRoot: string) => {
}
}
};
+
+function getTotalFrames(status: RenderProgress): number | null {
+ return status.renderMetadata
+ ? RenderInternals.getFramesToRender(
+ status.renderMetadata.frameRange,
+ status.renderMetadata.everyNthFrame
+ ).length
+ : null;
+}
diff --git a/packages/lambda/src/functions/helpers/concat-videos.ts b/packages/lambda/src/functions/helpers/concat-videos.ts
index c87990bceb..5aee063357 100644
--- a/packages/lambda/src/functions/helpers/concat-videos.ts
+++ b/packages/lambda/src/functions/helpers/concat-videos.ts
@@ -196,7 +196,7 @@ export const concatVideosS3 = async ({
}: {
bucket: string;
expectedFiles: number;
- onProgress: (frames: number, encodingStart: number) => void;
+ onProgress: (frames: number) => void;
onErrors: (errors: EnhancedErrorInfo[]) => Promise<void>;
numberOfFrames: number;
renderId: string;
@@ -232,15 +232,13 @@ export const concatVideosS3 = async ({
);
const combine = timer('Combine videos');
const filelistDir = RenderInternals.tmpDir(REMOTION_FILELIST_TOKEN);
- const encodingStart = Date.now();
-
const codecForCombining: Codec = codec === 'h264-mkv' ? 'h264' : codec;
await combineVideos({
files,
filelistDir,
output: outfile,
- onProgress: (p) => onProgress(p, encodingStart),
+ onProgress: (p) => onProgress(p),
numberOfFrames,
codec: codecForCombining,
fps,
@@ -253,5 +251,5 @@ export const concatVideosS3 = async ({
const cleanupChunksProm = (fs.promises.rm ?? fs.promises.rmdir)(outdir, {
recursive: true,
});
- return {outfile, cleanupChunksProm, encodingStart};
+ return {outfile, cleanupChunksProm};
};
diff --git a/packages/lambda/src/functions/helpers/create-post-render-data.ts b/packages/lambda/src/functions/helpers/create-post-render-data.ts
index f0c4e37774..88f427150d 100644
--- a/packages/lambda/src/functions/helpers/create-post-render-data.ts
+++ b/packages/lambda/src/functions/helpers/create-post-render-data.ts
@@ -15,7 +15,6 @@ import {calculateChunkTimes} from './calculate-chunk-times';
import type {OutputFileMetadata} from './find-output-file-in-bucket';
import {getCurrentArchitecture} from './get-current-architecture';
import {getFilesToDelete} from './get-files-to-delete';
-import {getLambdasInvokedStats} from './get-lambdas-invoked-stats';
import {getRetryStats} from './get-retry-stats';
import {getTimeToFinish} from './get-time-to-finish';
import type {EnhancedErrorInfo} from './write-lambda-error';
@@ -84,20 +83,8 @@ export const createPostRenderData = ({
.map((c) => c.Size ?? 0)
.reduce((a, b) => a + b, 0);
- const {timeToInvokeLambdas} = getLambdasInvokedStats({
- contents,
- renderId,
- estimatedRenderLambdaInvokations:
- renderMetadata.estimatedRenderLambdaInvokations,
- startDate: renderMetadata.startedDate,
- checkIfAllLambdasWereInvoked: false,
- });
const retriesInfo = getRetryStats({contents, renderId});
- if (timeToInvokeLambdas === null) {
- throw new Error('should have timing for all lambdas');
- }
-
return {
cost: {
currency: 'USD',
@@ -128,7 +115,7 @@ export const createPostRenderData = ({
renderId,
type: 'absolute-time',
}),
- timeToInvokeLambdas,
+ timeToInvokeLambdas: 0,
retriesInfo,
mostExpensiveFrameRanges: getMostExpensiveChunks(
parsedTimings,
diff --git a/packages/lambda/src/functions/helpers/get-encoding-metadata.ts b/packages/lambda/src/functions/helpers/get-encoding-metadata.ts
index 1e2e104b42..1395677ae6 100644
--- a/packages/lambda/src/functions/helpers/get-encoding-metadata.ts
+++ b/packages/lambda/src/functions/helpers/get-encoding-metadata.ts
@@ -1,40 +1,17 @@
+import type {_Object} from '@aws-sdk/client-s3';
import type {EncodingProgress} from '../../defaults';
-import {encodingProgressKey} from '../../defaults';
-import type {AwsRegion} from '../../pricing/aws-regions';
-import {streamToString} from '../../shared/stream-to-string';
-import {lambdaReadFile} from './io';
+import {getProgressOfChunk} from '../../shared/chunk-progress';
-export const getEncodingMetadata = async ({
+export const getEncodingMetadata = ({
exists,
- bucketName,
- renderId,
- region,
- expectedBucketOwner,
}: {
- exists: boolean;
- bucketName: string;
- renderId: string;
- region: AwsRegion;
- expectedBucketOwner: string;
-}): Promise<EncodingProgress | null> => {
+ exists: _Object | undefined;
+}): EncodingProgress | null => {
if (!exists) {
return null;
}
- try {
- const Body = await lambdaReadFile({
- bucketName,
- key: encodingProgressKey(renderId),
- region,
- expectedBucketOwner,
- });
- const encodingProgress = JSON.parse(
- await streamToString(Body)
- ) as EncodingProgress;
+ const framesEncoded = getProgressOfChunk(exists.ETag as string);
- return encodingProgress;
- } catch (err) {
- // The file may not yet have been fully written or already have been cleaned up again
- return null;
- }
+ return {framesEncoded};
};
diff --git a/packages/lambda/src/functions/helpers/get-final-encoding-status.ts b/packages/lambda/src/functions/helpers/get-final-encoding-status.ts
index 85feb485c8..3d71574463 100644
--- a/packages/lambda/src/functions/helpers/get-final-encoding-status.ts
+++ b/packages/lambda/src/functions/helpers/get-final-encoding-status.ts
@@ -1,16 +1,13 @@
import type {EncodingProgress, RenderMetadata} from '../../shared/constants';
-import type {LambdaInvokeStats} from './get-lambdas-invoked-stats';
export const getFinalEncodingStatus = ({
- encodingStatus: encodingProgress,
+ encodingProgress,
renderMetadata,
outputFileExists,
- lambdaInvokeStatus,
}: {
- encodingStatus: EncodingProgress | null;
+ encodingProgress: EncodingProgress | null;
renderMetadata: RenderMetadata | null;
outputFileExists: boolean;
- lambdaInvokeStatus: LambdaInvokeStats;
}): EncodingProgress | null => {
if (!renderMetadata) {
return null;
@@ -23,9 +20,6 @@ export const getFinalEncodingStatus = ({
if (outputFileExists) {
return {
framesEncoded: renderMetadata.videoConfig.durationInFrames,
- totalFrames: renderMetadata.videoConfig.durationInFrames,
- doneIn: null,
- timeToInvoke: lambdaInvokeStatus.timeToInvokeLambdas,
};
}
diff --git a/packages/lambda/src/functions/helpers/get-lambdas-invoked-stats.ts b/packages/lambda/src/functions/helpers/get-lambdas-invoked-stats.ts
index fda0232dad..af86a4ca6b 100644
--- a/packages/lambda/src/functions/helpers/get-lambdas-invoked-stats.ts
+++ b/packages/lambda/src/functions/helpers/get-lambdas-invoked-stats.ts
@@ -1,42 +1,23 @@
import type {_Object} from '@aws-sdk/client-s3';
import {lambdaChunkInitializedPrefix} from '../../shared/constants';
import {parseLambdaInitializedKey} from '../../shared/parse-lambda-initialized-key';
-import {max} from './min-max';
export type LambdaInvokeStats = {
- timeToInvokeLambdas: number | null;
lambdasInvoked: number;
};
export const getLambdasInvokedStats = ({
contents,
renderId,
- estimatedRenderLambdaInvokations,
- startDate,
- checkIfAllLambdasWereInvoked,
}: {
contents: _Object[];
renderId: string;
- estimatedRenderLambdaInvokations: number | null;
- startDate: number | null;
- checkIfAllLambdasWereInvoked: boolean;
}): LambdaInvokeStats => {
const lambdasInvoked = contents
.filter((c) => c.Key?.startsWith(lambdaChunkInitializedPrefix(renderId)))
.filter((c) => parseLambdaInitializedKey(c.Key as string).attempt === 1);
- const allLambdasInvoked =
- !checkIfAllLambdasWereInvoked ||
- lambdasInvoked.length === estimatedRenderLambdaInvokations;
-
- const timeToInvokeLambdas =
- !allLambdasInvoked || startDate === null
- ? null
- : (max(lambdasInvoked.map((l) => l.LastModified?.getTime() as number)) ??
- 0) - startDate;
-
return {
- timeToInvokeLambdas,
lambdasInvoked: lambdasInvoked.length,
};
};
diff --git a/packages/lambda/src/functions/helpers/get-overall-progress.ts b/packages/lambda/src/functions/helpers/get-overall-progress.ts
index 55f4241de6..c9eb4b8e3a 100644
--- a/packages/lambda/src/functions/helpers/get-overall-progress.ts
+++ b/packages/lambda/src/functions/helpers/get-overall-progress.ts
@@ -1,10 +1,11 @@
-type Factors = 'invoking' | 'rendering' | 'encoding' | 'cleanup';
+type Factors = 'invoking' | 'rendering' | 'frames' | 'encoding' | 'cleanup';
const weights: {[key in Factors]: number} = {
cleanup: 0.1,
- encoding: 0.3,
- rendering: 0.3,
- invoking: 0.3,
+ encoding: 0.225,
+ rendering: 0.225,
+ frames: 0.225,
+ invoking: 0.225,
};
export const getOverallProgress = ({
@@ -12,16 +13,19 @@ export const getOverallProgress = ({
encoding,
rendering,
invoking,
+ frames,
}: {
cleanup: number;
encoding: number;
rendering: number;
invoking: number;
+ frames: number;
}) => {
return (
cleanup * weights.cleanup +
encoding * weights.encoding +
rendering * weights.rendering +
- invoking * weights.invoking
+ invoking * weights.invoking +
+ frames * weights.frames
);
};
diff --git a/packages/lambda/src/functions/helpers/get-progress.ts b/packages/lambda/src/functions/helpers/get-progress.ts
index 168105a8fc..6a69b635b4 100644
--- a/packages/lambda/src/functions/helpers/get-progress.ts
+++ b/packages/lambda/src/functions/helpers/get-progress.ts
@@ -66,13 +66,13 @@ export const getProgress = async ({
customCredentials
);
- const frameCount = RenderInternals.getFramesToRender(
+ const totalFrameCount = RenderInternals.getFramesToRender(
postRenderData.renderMetadata.frameRange,
postRenderData.renderMetadata.everyNthFrame
).length;
return {
- framesRendered: frameCount,
+ framesRendered: totalFrameCount,
bucket: bucketName,
renderSize: postRenderData.renderSize,
chunks: postRenderData.renderMetadata.totalChunks,
@@ -90,10 +90,7 @@ export const getProgress = async ({
currentTime: Date.now(),
done: true,
encodingStatus: {
- framesEncoded: frameCount,
- totalFrames: frameCount,
- doneIn: postRenderData.timeToEncode,
- timeToInvoke: postRenderData.timeToInvokeLambdas,
+ framesEncoded: totalFrameCount,
},
errors: postRenderData.errors,
fatalErrorEncountered: false,
@@ -109,6 +106,7 @@ export const getProgress = async ({
outKey: outData.key,
outBucket: outData.renderBucketName,
mostExpensiveFrameRanges: postRenderData.mostExpensiveFrameRanges ?? null,
+ timeToEncode: postRenderData.timeToEncode,
};
}
@@ -130,34 +128,26 @@ export const getProgress = async ({
contents.find((c) => c.Key === renderMetadataKey(renderId))
);
- const [encodingStatus, renderMetadata, errorExplanations] = await Promise.all(
- [
- getEncodingMetadata({
- exists: Boolean(
- contents.find((c) => c.Key === encodingProgressKey(renderId))
- ),
- bucketName,
- renderId,
- region: getCurrentRegionInFunction(),
- expectedBucketOwner,
- }),
- renderMetadataExists
- ? getRenderMetadata({
- bucketName,
- renderId,
- region: getCurrentRegionInFunction(),
- expectedBucketOwner,
- })
- : null,
- inspectErrors({
- contents,
- renderId,
- bucket: bucketName,
- region: getCurrentRegionInFunction(),
- expectedBucketOwner,
- }),
- ]
- );
+ const encodingStatus = getEncodingMetadata({
+ exists: contents.find((c) => c.Key === encodingProgressKey(renderId)),
+ });
+ const [renderMetadata, errorExplanations] = await Promise.all([
+ renderMetadataExists
+ ? getRenderMetadata({
+ bucketName,
+ renderId,
+ region: getCurrentRegionInFunction(),
+ expectedBucketOwner,
+ })
+ : null,
+ inspectErrors({
+ contents,
+ renderId,
+ bucket: bucketName,
+ region: getCurrentRegionInFunction(),
+ expectedBucketOwner,
+ }),
+ ]);
if (renderMetadata?.type === 'still') {
throw new Error(
@@ -226,10 +216,6 @@ export const getProgress = async ({
const lambdasInvokedStats = getLambdasInvokedStats({
contents,
renderId,
- estimatedRenderLambdaInvokations:
- renderMetadata?.estimatedRenderLambdaInvokations ?? null,
- startDate: renderMetadata?.startedDate ?? null,
- checkIfAllLambdasWereInvoked: true,
});
const retriesInfo = getRetryStats({
@@ -238,10 +224,9 @@ export const getProgress = async ({
});
const finalEncodingStatus = getFinalEncodingStatus({
- encodingStatus,
+ encodingProgress: encodingStatus,
outputFileExists: Boolean(outputFile),
renderMetadata,
- lambdaInvokeStatus: lambdasInvokedStats,
});
const chunkCount = outputFile
@@ -272,6 +257,13 @@ export const getProgress = async ({
...errorExplanations,
].filter(Internals.truthy);
+ const frameCount = renderMetadata
+ ? RenderInternals.getFramesToRender(
+ renderMetadata.frameRange,
+ renderMetadata.everyNthFrame
+ ).length
+ : null;
+
return {
framesRendered,
chunks: chunkCount,
@@ -296,20 +288,19 @@ export const getProgress = async ({
type: 'absolute-time',
})
: null,
- timeToInvokeLambdas:
- encodingStatus?.timeToInvoke ?? lambdasInvokedStats.timeToInvokeLambdas,
+ timeToInvokeLambdas: 0,
overallProgress: getOverallProgress({
cleanup: cleanup ? cleanup.filesDeleted / cleanup.minFilesToDelete : 0,
encoding:
- finalEncodingStatus && renderMetadata
- ? finalEncodingStatus.framesEncoded /
- renderMetadata.videoConfig.durationInFrames
+ finalEncodingStatus && renderMetadata && frameCount
+ ? finalEncodingStatus.framesEncoded / frameCount
: 0,
invoking: renderMetadata
? lambdasInvokedStats.lambdasInvoked /
renderMetadata.estimatedRenderLambdaInvokations
: 0,
rendering: renderMetadata ? chunkCount / renderMetadata.totalChunks : 0,
+ frames: frameCount === null ? 0 : framesRendered / frameCount,
}),
retriesInfo,
outKey:
@@ -322,5 +313,6 @@ export const getProgress = async ({
.renderBucketName
: null,
mostExpensiveFrameRanges: null,
+ timeToEncode: null,
};
};
diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.ts
index 5bcf50a977..62decdcc02 100644
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@ -5,11 +5,7 @@ import {Internals} from 'remotion';
import {VERSION} from 'remotion/version';
import {getLambdaClient} from '../shared/aws-clients';
import {cleanupSerializedInputProps} from '../shared/cleanup-serialized-input-props';
-import type {
- EncodingProgress,
- LambdaPayload,
- RenderMetadata,
-} from '../shared/constants';
+import type {LambdaPayload, RenderMetadata} from '../shared/constants';
import {
encodingProgressKey,
initalizedMetadataKey,
@@ -35,7 +31,6 @@ import {findOutputFileInBucket} from './helpers/find-output-file-in-bucket';
import {getBrowserInstance} from './helpers/get-browser-instance';
import {getCurrentRegionInFunction} from './helpers/get-current-region';
import {getFilesToDelete} from './helpers/get-files-to-delete';
-import {getLambdasInvokedStats} from './helpers/get-lambdas-invoked-stats';
import {getOutputUrlFromMetadata} from './helpers/get-output-url-from-metadata';
import {inspectErrors} from './helpers/inspect-errors';
import {lambdaDeleteFile, lambdaLs, lambdaWriteFile} from './helpers/io';
@@ -355,15 +350,11 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {
reqSend.end();
let lastProgressUploaded = 0;
- let encodingStop: number | null = null;
- const onProgress = (framesEncoded: number, start: number) => {
+ const onProgress = (framesEncoded: number) => {
const relativeProgress = framesEncoded / frameCount.length;
const deltaSinceLastProgressUploaded =
relativeProgress - lastProgressUploaded;
- if (relativeProgress === 1) {
- encodingStop = Date.now();
- }
if (deltaSinceLastProgressUploaded < 0.1) {
return;
@@ -371,16 +362,10 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {
lastProgressUploaded = relativeProgress;
- const encodingProgress: EncodingProgress = {
- framesEncoded,
- totalFrames: frameCount.length,
- doneIn: encodingStop ? encodingStop - start : null,
- timeToInvoke: null,
- };
lambdaWriteFile({
bucketName: params.bucketName,
key: encodingProgressKey(params.renderId),
- body: JSON.stringify(encodingProgress),
+ body: String(framesEncoded),
region: getCurrentRegionInFunction(),
privacy: 'private',
expectedBucketOwner: options.expectedBucketOwner,
@@ -441,7 +426,8 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {
const fps = comp.fps / params.everyNthFrame;
- const {outfile, cleanupChunksProm, encodingStart} = await concatVideosS3({
+ const encodingStart = Date.now();
+ const {outfile, cleanupChunksProm} = await concatVideosS3({
bucket: params.bucketName,
expectedFiles: chunkCount,
onProgress,
@@ -456,9 +442,7 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {
remotionRoot: process.cwd(),
onErrors,
});
- if (!encodingStop) {
- encodingStop = Date.now();
- }
+ const encodingStop = Date.now();
const outputSize = fs.statSync(outfile);
@@ -479,23 +463,10 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {
expectedBucketOwner: options.expectedBucketOwner,
region: getCurrentRegionInFunction(),
});
- const finalEncodingProgress: EncodingProgress = {
- framesEncoded: frameCount.length,
- totalFrames: frameCount.length,
- doneIn: encodingStop ? encodingStop - encodingStart : null,
- timeToInvoke: getLambdasInvokedStats({
- contents,
- renderId: params.renderId,
- estimatedRenderLambdaInvokations:
- renderMetadata.estimatedRenderLambdaInvokations,
- checkIfAllLambdasWereInvoked: false,
- startDate: renderMetadata.startedDate,
- }).timeToInvokeLambdas,
- };
const finalEncodingProgressProm = lambdaWriteFile({
bucketName: params.bucketName,
key: encodingProgressKey(params.renderId),
- body: JSON.stringify(finalEncodingProgress),
+ body: String(frameCount.length),
region: getCurrentRegionInFunction(),
privacy: 'private',
expectedBucketOwner: options.expectedBucketOwner,
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.ts
index 2a1d4a3685..9743fb5f76 100644
--- a/packages/lambda/src/shared/constants.ts
+++ b/packages/lambda/src/shared/constants.ts
@@ -363,9 +363,6 @@ export type LambdaPayload = LambdaPayloads[LambdaRoutines];
export type EncodingProgress = {
framesEncoded: number;
- totalFrames: number | null;
- doneIn: number | null;
- timeToInvoke: number | null;
};
export type RenderMetadata = {
@@ -448,6 +445,7 @@ export type RenderProgress = {
cleanup: CleanupInfo | null;
timeToFinishChunks: number | null;
timeToInvokeLambdas: number | null;
+ timeToEncode: number | null;
overallProgress: number;
retriesInfo: ChunkRetry[];
mostExpensiveFrameRanges: ExpensiveChunk[] | null;