🎥 Make videos programmatically with React
encoded progress
Jonny Burger6a9ce577a3e9
diff --git a/packages/lambda/src/cli/commands/render/progress.ts b/packages/lambda/src/cli/commands/render/progress.tsindex 30e06a6d62..713a0af9d1 100644--- a/packages/lambda/src/cli/commands/render/progress.ts+++ b/packages/lambda/src/cli/commands/render/progress.ts@@ -18,6 +18,7 @@ type LambdaInvokeProgress = {type ChunkProgress = {doneIn: number | null;framesRendered: number;+ framesEncoded: number;totalFrames: number | null;totalChunks: number | null;chunksEncoded: number;@@ -53,13 +54,11 @@ const makeRenderProgress = ({}: {chunkProgress: ChunkProgress;}) => {- const {chunksEncoded, totalChunks, doneIn} = chunkProgress;+ const {doneIn, framesRendered, totalFrames, framesEncoded} = chunkProgress;const renderProgress =- chunkProgress.totalFrames === null- ? 0- : chunkProgress.framesRendered / chunkProgress.totalFrames;+ totalFrames === null ? 0 : framesRendered / totalFrames;const encodingProgress =- totalChunks === null ? 0 : chunksEncoded / totalChunks;+ totalFrames === null ? 0 : framesEncoded / totalFrames;const frames =chunkProgress.totalFrames === null@@ -78,15 +77,19 @@ const makeRenderProgress = ({.join(' ');const second = [- `${doneIn === null ? 'Encoding' : 'Encoded'} chunks`.padEnd(+ `${doneIn === null ? 'Encoding' : 'Encoded'} frames`.padEnd(CliInternals.LABEL_WIDTH,' ',),CliInternals.makeProgressBar(encodingProgress),doneIn === null- ? `${Math.round(encodingProgress * 100)}%`+ ? totalFrames === null+ ? null+ : `${framesEncoded}/${totalFrames}`: CliInternals.chalk.gray(`${doneIn}ms`),- ].join(' ');+ ]+ .filter(truthy)+ .join(' ');return [first, second];};@@ -183,6 +186,7 @@ export const makeMultiProgressFromStatus = (totalChunks: status.renderMetadata?.totalChunks ?? null,doneIn: status.timeToFinishChunks,framesRendered: status.framesRendered,+ framesEncoded: status.encodingStatus?.framesEncoded ?? 0,totalFrames:status.renderMetadata && status.renderMetadata.type === 'video'? RenderInternals.getFramesToRender(diff --git a/packages/lambda/src/functions/helpers/get-final-encoding-status.ts b/packages/lambda/src/functions/helpers/get-final-encoding-status.tsdeleted file mode 100644index 3d71574463..0000000000--- a/packages/lambda/src/functions/helpers/get-final-encoding-status.ts+++ /dev/null@@ -1,27 +0,0 @@-import type {EncodingProgress, RenderMetadata} from '../../shared/constants';--export const getFinalEncodingStatus = ({- encodingProgress,- renderMetadata,- outputFileExists,-}: {- encodingProgress: EncodingProgress | null;- renderMetadata: RenderMetadata | null;- outputFileExists: boolean;-}): EncodingProgress | null => {- if (!renderMetadata) {- return null;- }-- if (encodingProgress) {- return encodingProgress;- }-- if (outputFileExists) {- return {- framesEncoded: renderMetadata.videoConfig.durationInFrames,- };- }-- return null;-};diff --git a/packages/lambda/src/functions/helpers/get-progress.ts b/packages/lambda/src/functions/helpers/get-progress.tsindex 292e818e87..d06241f48a 100644--- a/packages/lambda/src/functions/helpers/get-progress.ts+++ b/packages/lambda/src/functions/helpers/get-progress.ts@@ -21,7 +21,6 @@ import {getCleanupProgress} from './get-cleanup-progress';import {getCurrentRegionInFunction} from './get-current-region';import {getEncodingMetadata} from './get-encoding-metadata';import {getEncodingProgressStepSize} from './get-encoding-progress-step-size';-import {getFinalEncodingStatus} from './get-final-encoding-status';import {getLambdasInvokedStats} from './get-lambdas-invoked-stats';import {getOverallProgress} from './get-overall-progress';import {getOverallProgressS3} from './get-overall-progress-s3';@@ -230,18 +229,13 @@ export const getProgress = async ({const frameCountOrNull = frameCount === null ? 0 : frameCount;- const encodingStatus = getEncodingMetadata({+ // TODO: This is not needed+ getEncodingMetadata({exists: contents.find((c) => c.Key === encodingProgressKey(renderId)),frameCount: frameCountOrNull,stepSize: getEncodingProgressStepSize(frameCountOrNull),});- const finalEncodingStatus = getFinalEncodingStatus({- encodingProgress: encodingStatus,- outputFileExists: Boolean(outputFile),- renderMetadata,- });-const chunkCount = overallProgress?.chunks.length ?? 0;const missingChunks = renderMetadata@@ -284,7 +278,9 @@ export const getProgress = async ({framesRendered: overallProgress?.framesRendered ?? 0,chunks: chunkCount,done: false,- encodingStatus,+ encodingStatus: {+ framesEncoded: overallProgress?.framesEncoded ?? 0,+ },costs: priceFromBucket? formatCostsInfo(priceFromBucket.accruedSoFar): formatCostsInfo(0),@@ -309,8 +305,8 @@ export const getProgress = async ({overallProgress: getOverallProgress({cleanup: cleanup ? cleanup.filesDeleted / cleanup.minFilesToDelete : 0,encoding:- finalEncodingStatus && renderMetadata && frameCount- ? finalEncodingStatus.framesEncoded / frameCount+ renderMetadata && frameCount+ ? overallProgress?.framesEncoded ?? 0 / frameCount: 0,invoking: renderMetadata? lambdasInvokedStats.lambdasInvoked /