Skip to content

🎥 Make videos programmatically with React

works out

Jonny Burgerdfa0a7a74b25
diff --git a/packages/lambda/src/cli/commands/render/progress.ts b/packages/lambda/src/cli/commands/render/progress.ts
index 2269d8b9a2..1718c5abca 100644
--- a/packages/lambda/src/cli/commands/render/progress.ts
+++ b/packages/lambda/src/cli/commands/render/progress.ts
@@ -2,7 +2,6 @@ import {CliInternals} from '@remotion/cli';
import {RenderInternals} from '@remotion/renderer';
import {NoReactInternals} from 'remotion/no-react';
import type {RenderProgress} from '../../../defaults';
-import type {ChunkRetry} from '../../../functions/helpers/get-retry-stats';
import {truthy} from '../../../shared/truthy';
type LambdaInvokeProgress = {
@@ -19,10 +18,7 @@ type ChunkProgress = {
chunksEncoded: number;
};
-const makeInvokeProgress = (
- overall: RenderProgress,
- retriesInfo: ChunkRetry[],
-) => {
+const makeInvokeProgress = (overall: RenderProgress) => {
const invokeProgress: LambdaInvokeProgress = {
lambdasInvoked: overall.lambdasInvoked,
totalLambdas:
@@ -40,7 +36,9 @@ const makeInvokeProgress = (
: totalLambdas === null
? null
: `${lambdasInvoked}/${totalLambdas}`,
- retriesInfo.length > 0 ? `(+${retriesInfo.length} retries)` : [],
+ overall.retriesInfo.length > 0
+ ? `(+${overall.retriesInfo.length} retries)`
+ : [],
].join(' ');
};
@@ -99,18 +97,22 @@ const makeRenderProgress = (progress: RenderProgress) => {
return [first, second];
};
-const makeCombinationProgress = ({
- totalFrames,
- progress: prog,
-}: {
- progress: RenderProgress;
- totalFrames: number | null;
-}) => {
+function getTotalFrames(status: RenderProgress): number | null {
+ return status.renderMetadata && status.renderMetadata.type === 'video'
+ ? RenderInternals.getFramesToRender(
+ status.renderMetadata.frameRange,
+ status.renderMetadata.everyNthFrame,
+ ).length
+ : null;
+}
+
+const makeCombinationProgress = (prog: RenderProgress) => {
const encodingProgress = {
framesEncoded: prog.encodingStatus?.framesEncoded ?? 0,
combinedFrames: prog.combinedFrames,
timeToCombine: prog.timeToCombine,
};
+ const totalFrames = getTotalFrames(prog);
const {combinedFrames, timeToCombine} = encodingProgress;
const progress = totalFrames === null ? 0 : combinedFrames / totalFrames;
@@ -158,22 +160,15 @@ type DownloadedInfo = {
export const makeProgressString = ({
downloadInfo,
- retriesInfo,
- totalFrames,
overall,
}: {
overall: RenderProgress;
downloadInfo: DownloadedInfo | null;
- retriesInfo: ChunkRetry[];
- totalFrames: number | null;
}) => {
return [
- makeInvokeProgress(overall, retriesInfo),
+ makeInvokeProgress(overall),
...makeRenderProgress(overall),
- makeCombinationProgress({
- progress: overall,
- totalFrames,
- }),
+ makeCombinationProgress(overall),
downloadInfo ? makeDownloadProgress(downloadInfo) : null,
]
.filter(NoReactInternals.truthy)
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index 4d41dcf095..30547e1d4d 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -8,7 +8,6 @@ import {downloadMedia} from '../../../api/download-media';
import {getRenderProgress} from '../../../api/get-render-progress';
import {internalRenderMediaOnLambdaRaw} from '../../../api/render-media-on-lambda';
import type {EnhancedErrorInfo} from '../../../functions/helpers/write-lambda-error';
-import type {RenderProgress} from '../../../shared/constants';
import {
BINARY_NAME,
@@ -31,15 +30,6 @@ import {makeProgressString} from './progress';
export const RENDER_COMMAND = 'render';
-function getTotalFrames(status: RenderProgress): number | null {
- return status.renderMetadata && status.renderMetadata.type === 'video'
- ? RenderInternals.getFramesToRender(
- status.renderMetadata.frameRange,
- status.renderMetadata.everyNthFrame,
- ).length
- : null;
-}
-
const {
x264Option,
audioBitrateOption,
@@ -372,8 +362,6 @@ export const renderCommand = async (
progressBar.update(
makeProgressString({
downloadInfo: null,
- retriesInfo: status.retriesInfo,
- totalFrames: getTotalFrames(status),
overall: status,
}),
false,
@@ -391,10 +379,8 @@ export const renderCommand = async (
});
progressBar.update(
makeProgressString({
- retriesInfo: newStatus.retriesInfo,
downloadInfo: null,
- totalFrames: getTotalFrames(newStatus),
- overall: status,
+ overall: newStatus,
}),
false,
);
@@ -403,9 +389,7 @@ export const renderCommand = async (
progressBar.update(
makeProgressString({
downloadInfo: null,
- retriesInfo: newStatus.retriesInfo,
- totalFrames: getTotalFrames(newStatus),
- overall: status,
+ overall: newStatus,
}),
false,
);
@@ -420,14 +404,12 @@ export const renderCommand = async (
onProgress: ({downloaded, totalSize}) => {
progressBar.update(
makeProgressString({
- retriesInfo: newStatus.retriesInfo,
downloadInfo: {
doneIn: null,
downloaded,
totalSize,
},
- totalFrames: getTotalFrames(newStatus),
- overall: status,
+ overall: newStatus,
}),
false,
);
@@ -435,14 +417,12 @@ export const renderCommand = async (
});
progressBar.update(
makeProgressString({
- retriesInfo: newStatus.retriesInfo,
downloadInfo: {
doneIn: Date.now() - downloadStart,
downloaded: sizeInBytes,
totalSize: sizeInBytes,
},
- totalFrames: getTotalFrames(newStatus),
- overall: status,
+ overall: newStatus,
}),
false,
);