Skip to content

🎥 Make videos programmatically with React

cleanup

Jonny Burger23475469b62c
diff --git a/packages/lambda/src/functions/helpers/get-progress.ts b/packages/lambda/src/functions/helpers/get-progress.ts
index 7dad7df029..c5ac772b7a 100644
--- a/packages/lambda/src/functions/helpers/get-progress.ts
+++ b/packages/lambda/src/functions/helpers/get-progress.ts
@@ -4,7 +4,6 @@ import type {AwsRegion} from '../../pricing/aws-regions';
import type {CustomCredentials} from '../../shared/aws-clients';
import type {RenderProgress} from '../../shared/constants';
import {
- chunkKey,
MAX_EPHEMERAL_STORAGE_IN_MB,
renderMetadataKey,
rendersPrefix,
@@ -194,8 +193,6 @@ export const getProgress = async ({
const chunkMultiplier = [hasAudio, hasVideo].filter(truthy).length;
- // TODO: Those chunks are not in S3 anymore
- const chunks = contents.filter((c) => c.Key?.startsWith(chunkKey(renderId)));
const overallProgress = await getOverallProgressS3({
renderId,
bucketName,
@@ -203,7 +200,7 @@ export const getProgress = async ({
});
const allChunks =
- chunks.length / chunkMultiplier ===
+ (overallProgress?.chunks ?? []).length / chunkMultiplier ===
(renderMetadata?.totalChunks ?? Infinity);
const renderSize = contents
.map((c) => c.Size ?? 0)
@@ -246,7 +243,6 @@ export const getProgress = async ({
? makeTimeoutError({
timeoutInMilliseconds,
renderMetadata,
- chunks,
renderId,
missingChunks: missingChunks ?? [],
})
diff --git a/packages/lambda/src/functions/helpers/make-timeout-error.ts b/packages/lambda/src/functions/helpers/make-timeout-error.ts
index d4fd653be1..a9af1d04f0 100644
--- a/packages/lambda/src/functions/helpers/make-timeout-error.ts
+++ b/packages/lambda/src/functions/helpers/make-timeout-error.ts
@@ -1,4 +1,3 @@
-import type {_Object} from '@aws-sdk/client-s3';
import type {RenderMetadata} from '../../defaults';
import {makeTimeoutMessage} from './make-timeout-message';
import type {EnhancedErrorInfo} from './write-lambda-error';
@@ -10,7 +9,6 @@ export const makeTimeoutError = ({
renderId,
}: {
timeoutInMilliseconds: number;
- chunks: _Object[];
renderMetadata: RenderMetadata;
renderId: string;
missingChunks: number[];
diff --git a/packages/lambda/src/functions/helpers/overall-render-progress.ts b/packages/lambda/src/functions/helpers/overall-render-progress.ts
index 3131696f71..850926c157 100644
--- a/packages/lambda/src/functions/helpers/overall-render-progress.ts
+++ b/packages/lambda/src/functions/helpers/overall-render-progress.ts
@@ -64,6 +64,7 @@ export const makeOverallRenderProgress = ({
let lastUpload: string | null = null;
// TODO: What if upload fails?
+ // TODO: Is there any chance the latest update will not settle?
const upload = async () => {
if (lastUpload === JSON.stringify(renderProgress)) {
return;
diff --git a/packages/lambda/src/functions/helpers/stream-renderer.ts b/packages/lambda/src/functions/helpers/stream-renderer.ts
index fb16c64e85..9fda7d48cd 100644
--- a/packages/lambda/src/functions/helpers/stream-renderer.ts
+++ b/packages/lambda/src/functions/helpers/stream-renderer.ts
@@ -3,7 +3,7 @@ import {RenderInternals} from '@remotion/renderer';
import {writeFileSync} from 'fs';
import {join} from 'path';
import type {LambdaPayload} from '../../defaults';
-import {LambdaRoutines, chunkKeyForIndex} from '../../defaults';
+import {LambdaRoutines} from '../../defaults';
import {callLambdaWithStreaming} from '../../shared/call-lambda';
import type {OnMessage} from '../streaming/streaming';
import {getCurrentRegionInFunction} from './get-current-region';
@@ -57,10 +57,7 @@ const streamRenderer = ({
if (message.type === 'video-chunk-rendered') {
const filename = join(
outdir,
- chunkKeyForIndex({
- index: payload.chunk,
- type: 'video',
- }),
+ `chunk:${String(payload.chunk).padStart(8, '0')}:video`,
);
writeFileSync(filename, message.payload);
files.push(filename);
@@ -70,10 +67,7 @@ const streamRenderer = ({
if (message.type === 'audio-chunk-rendered') {
const filename = join(
outdir,
- chunkKeyForIndex({
- index: payload.chunk,
- type: 'audio',
- }),
+ `chunk:${String(payload.chunk).padStart(8, '0')}:audio`,
);
writeFileSync(filename, message.payload);
files.push(filename);
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.ts
index 065bb1d1f9..0b516ae81b 100644
--- a/packages/lambda/src/shared/constants.ts
+++ b/packages/lambda/src/shared/constants.ts
@@ -95,15 +95,6 @@ export const lambdaTimingsKey = ({
renderId,
chunk,
)}-start:${start}-rendered:${rendered}.txt`;
-export const chunkKey = (renderId: string) =>
- `${rendersPrefix(renderId)}/chunks/chunk`;
-export const chunkKeyForIndex = ({
- index,
- type,
-}: {
- index: number;
- type: 'video' | 'audio';
-}) => `chunk:${String(index).padStart(8, '0')}:${type}`;
export const getErrorKeyPrefix = (renderId: string) =>
`${rendersPrefix(renderId)}/errors/`;