π₯ Make videos programmatically with React
this works
Jonny Burger5d060de425c8
diff --git a/packages/lambda/src/functions/helpers/create-post-render-data.ts b/packages/lambda/src/functions/helpers/create-post-render-data.tsindex 9f3e6486b4..e9160b5332 100644--- a/packages/lambda/src/functions/helpers/create-post-render-data.ts+++ b/packages/lambda/src/functions/helpers/create-post-render-data.ts@@ -24,6 +24,7 @@ export const createPostRenderData = ({timeToCombine,overallProgress,timeToFinish,+ outputSize,}: {region: AwsRegion;memorySizeInMb: number;@@ -36,6 +37,7 @@ export const createPostRenderData = ({timeToCombine: number | null;overallProgress: OverallRenderProgress;timeToFinish: number;+ outputSize: number;}): PostRenderData => {const parsedTimings = overallProgress.timings;@@ -79,7 +81,7 @@ export const createPostRenderData = ({errors: errorExplanations,startTime: renderMetadata.startedDate,endTime,- outputSize: outputFile.size,+ outputSize,renderSize,filesCleanedUp: 0,timeToEncode,diff --git a/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts b/packages/lambda/src/functions/helpers/find-output-file-in-bucket.tsindex b77927b1fe..db38b15d9c 100644--- a/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts+++ b/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts@@ -1,27 +1,22 @@-import type {AwsRegion} from '../..';import {ROLE_NAME} from '../../api/iam-validation/suggested-policy';import type {CustomCredentials} from '../../shared/aws-clients';import type {RenderMetadata} from '../../shared/constants';import {getExpectedOutName} from './expected-out-name';import {getOutputUrlFromMetadata} from './get-output-url-from-metadata';-import {lambdaHeadCommand} from './io';export type OutputFileMetadata = {url: string;- size: number;};-export const findOutputFileInBucket = async ({- region,+export const findOutputFileInBucket = ({renderMetadata,bucketName,customCredentials,}: {- region: AwsRegion;renderMetadata: RenderMetadata;bucketName: string;customCredentials: CustomCredentials | null;-}): Promise<OutputFileMetadata | null> => {+}): OutputFileMetadata | null => {if (!renderMetadata) {throw new Error('unexpectedly did not get renderMetadata');}@@ -33,14 +28,7 @@ export const findOutputFileInBucket = async ({);try {- const head = await lambdaHeadCommand({- bucketName,- key,- region,- customCredentials,- });return {- size: head.ContentLength as number,url: getOutputUrlFromMetadata(renderMetadata,bucketName,diff --git a/packages/lambda/src/functions/helpers/get-progress.ts b/packages/lambda/src/functions/helpers/get-progress.tsindex d93375d4b6..c5da5e7785 100644--- a/packages/lambda/src/functions/helpers/get-progress.ts+++ b/packages/lambda/src/functions/helpers/get-progress.ts@@ -11,7 +11,6 @@ import {truthy} from '../../shared/truthy';import {calculateChunkTimes} from './calculate-chunk-times';import {estimatePriceFromBucket} from './calculate-price-from-bucket';import {getExpectedOutName} from './expected-out-name';-import {findOutputFileInBucket} from './find-output-file-in-bucket';import {formatCostsInfo} from './format-costs-info';import {getCurrentRegionInFunction} from './get-current-region';import {getOverallProgress} from './get-overall-progress';@@ -131,21 +130,12 @@ export const getProgress = async ({expectedBucketOwner,});- if (renderMetadata?.type === 'still') {+ if (renderMetadata && renderMetadata.type === 'still') {throw new Error("You don't need to call getRenderProgress() on a still render. Once you have obtained the `renderId`, the render is already done! π",);}- const outputFile = renderMetadata- ? await findOutputFileInBucket({- bucketName,- renderMetadata,- region,- customCredentials,- })- : null;-const priceFromBucket = estimatePriceFromBucket({renderMetadata,memorySizeInMb,@@ -234,7 +224,7 @@ export const getProgress = async ({renderId,renderMetadata,bucket: bucketName,- outputFile: outputFile?.url ?? null,+ outputFile: null,timeToFinish: null,errors: allErrors,fatalErrorEncountered: allErrors.some((f) => f.isFatal && !f.willRetry),@@ -263,18 +253,11 @@ export const getProgress = async ({frames: (overallProgress.framesRendered ?? 0) / (frameCount ?? 1),}),retriesInfo: overallProgress.retries ?? [],- outKey:- outputFile && renderMetadata- ? getExpectedOutName(renderMetadata, bucketName, customCredentials).key- : null,- outBucket:- outputFile && renderMetadata- ? getExpectedOutName(renderMetadata, bucketName, customCredentials)- .renderBucketName- : null,+ outKey: null,+ outBucket: null,mostExpensiveFrameRanges: null,timeToEncode: null,- outputSizeInBytes: outputFile?.size ?? null,+ outputSizeInBytes: null,estimatedBillingDurationInMilliseconds: priceFromBucket? priceFromBucket.estimatedBillingDurationInMilliseconds: null,diff --git a/packages/lambda/src/functions/helpers/merge-chunks.ts b/packages/lambda/src/functions/helpers/merge-chunks.tsindex 57682abbd4..825978ea31 100644--- a/packages/lambda/src/functions/helpers/merge-chunks.ts+++ b/packages/lambda/src/functions/helpers/merge-chunks.ts@@ -81,10 +81,10 @@ export const mergeChunksAndFinishRender = async (options: {const encodingStop = Date.now();options.overallProgress.setTimeToCombine(encodingStop - encodingStart);- const outputSize = fs.statSync(outfile);+ const outputSize = fs.statSync(outfile).size;const writeToS3 = timer(- `Writing to S3 (${outputSize.size} bytes)`,+ `Writing to S3 (${outputSize} bytes)`,options.logLevel,);@@ -145,11 +145,11 @@ export const mergeChunksAndFinishRender = async (options: {cleanupSerializedInputPropsProm,cleanupResolvedInputPropsProm,])- ).reduce((a, b) => a + b, 0),+ ).reduce((a, b) => Math.max(a, b), 0),outputFile: {- size: outputSize.size,url: outputUrl,},+ outputSize,timeToCombine: encodingStop - encodingStart,overallProgress: options.overallProgress.get(),timeToFinish: Date.now() - options.startTime,diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.tsindex 64853d7571..cb22045605 100644--- a/packages/lambda/src/functions/launch.ts+++ b/packages/lambda/src/functions/launch.ts@@ -309,10 +309,9 @@ const innerLaunchHandler = async ({);// TODO: Once we don't check for output file in S3, we can do this asynchronously- const output = await findOutputFileInBucket({+ const output = findOutputFileInBucket({bucketName: params.bucketName,customCredentials,- region: getCurrentRegionInFunction(),renderMetadata,});diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.tsindex b1c15bf076..f7b1d14098 100644--- a/packages/lambda/src/functions/still.ts+++ b/packages/lambda/src/functions/still.ts@@ -278,7 +278,7 @@ const innerStillHandler = async ({customCredentials,);- await onStream({+ onStream({type: 'still-rendered',payload: {type: 'success' as const,