🎥 Make videos programmatically with React
hmm
Jonny Burger016123d8e27c
diff --git a/packages/lambda/src/concat-videos.ts b/packages/lambda/src/concat-videos.tsindex 44b269d977..74ccafcccf 100644--- a/packages/lambda/src/concat-videos.ts+++ b/packages/lambda/src/concat-videos.ts@@ -5,7 +5,6 @@ import {existsSync,mkdirSync,promises,- readdirSync,rmdirSync,} from 'fs';import {join} from 'path';@@ -41,38 +40,6 @@ const downloadS3File = async ({});};-const getAllFiles = async ({- efsRemotionVideoPath,- expectedFiles,- efsRemotionVideoRenderDone,-}: {- efsRemotionVideoPath: string;- expectedFiles: number;- efsRemotionVideoRenderDone: string;-}): Promise<string[]> => {- return new Promise<string[]>((resolve) => {- const loop = async () => {- const files = readdirSync(efsRemotionVideoPath);- const txtFiles = readdirSync(efsRemotionVideoRenderDone);- const areAllFilesDownloading = Boolean(- files.length === expectedFiles && txtFiles.length === expectedFiles- );-- if (!areAllFilesDownloading) {- setTimeout(() => {- loop();- }, 100);- }-- if (areAllFilesDownloading) {- resolve(files.map((file) => join(efsRemotionVideoPath, file)));- }- };-- loop();- });-};-const getAllFilesS3 = async ({s3Client,bucket,@@ -149,42 +116,6 @@ const getAllFilesS3 = async ({});};-export const concatVideos = async ({- efsRemotionVideoPath,- efsRemotionVideoRenderDone,- expectedFiles,- onProgress,-}: {- efsRemotionVideoPath: string;- efsRemotionVideoRenderDone: string;- expectedFiles: number;- onProgress: (progress: number) => void;-}) => {- const getAllTimes = timer('get all files');- const files = await getAllFiles({- efsRemotionVideoPath,- expectedFiles,- efsRemotionVideoRenderDone,- });- getAllTimes.end();-- const outfile = join(tmpDir('remotion-concated'), 'concat.mp4');- const combine = timer('Combine videos');- const filelistDir = tmpDir('remotion-filelist');- await combineVideos({- files,- filelistDir,- output: outfile,- onProgress,- });- combine.end();-- rmdirSync(efsRemotionVideoPath, {- recursive: true,- });- return outfile;-};-export const concatVideosS3 = async ({s3Client,bucket,diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.tsindex 762d5fb1fc..fda3024b94 100644--- a/packages/lambda/src/functions/launch.ts+++ b/packages/lambda/src/functions/launch.ts@@ -2,10 +2,9 @@ import {InvokeCommand} from '@aws-sdk/client-lambda';import fs from 'fs';import {lambdaClient, s3Client} from '../aws-clients';import {chunk} from '../chunk';-import {concatVideos, concatVideosS3} from '../concat-videos';+import {concatVideosS3} from '../concat-videos';import {EFS_MOUNT_PATH,- ENABLE_EFS,EncodingProgress,ENCODING_PROGRESS_KEY,LambdaPayload,@@ -28,19 +27,7 @@ const innerLaunchHandler = async (params: LambdaPayload) => {const efsRemotionVideoRenderDone = EFS_MOUNT_PATH + '/render-done';const efsRemotionVideoPath = EFS_MOUNT_PATH + '/remotion-video';- if (ENABLE_EFS) {- if (fs.existsSync(efsRemotionVideoPath)) {- fs.rmdirSync(efsRemotionVideoPath, {recursive: true});- }-- fs.mkdirSync(efsRemotionVideoPath);- if (fs.existsSync(efsRemotionVideoRenderDone)) {- fs.rmdirSync(efsRemotionVideoRenderDone, {recursive: true});- }-- fs.mkdirSync(efsRemotionVideoRenderDone);- }- // const bucketTimer = timer('Creating bucket');+ // TODO: Cleanup EFS after render, it is not ephemereal// TODO: Better validationif (!params.chunkSize) {@@ -141,19 +128,12 @@ const innerLaunchHandler = async (params: LambdaPayload) => {});};- const out = ENABLE_EFS- ? await concatVideos({- efsRemotionVideoPath,- efsRemotionVideoRenderDone,- expectedFiles: chunkCount,- onProgress,- })- : await concatVideosS3({- s3Client,- bucket: params.bucketName,- expectedFiles: chunkCount,- onProgress,- });+ const out = await concatVideosS3({+ s3Client,+ bucket: params.bucketName,+ expectedFiles: chunkCount,+ onProgress,+ });await lambdaWriteFile({bucketName: params.bucketName,key: OUT_NAME,