🎥 Make videos programmatically with React
add to renderMediaOnLambda(), renderStill(), renderStillOnLambda()
Jonny Burgerf315fedaf0a4
diff --git a/packages/cli/src/versions.ts b/packages/cli/src/versions.tsindex b33b7f1c23..68be29584c 100644--- a/packages/cli/src/versions.ts+++ b/packages/cli/src/versions.ts@@ -85,7 +85,12 @@ export const validateVersionsBeforeCommand = async () => {Log.warn('- Remove the `^` character in front of a version to pin a package.');- if (!Internals.Logging.isEqualOrBelowLogLevel('verbose')) {+ if (+ !Internals.Logging.isEqualOrBelowLogLevel(+ Internals.Logging.getLogLevel(),+ 'verbose'+ )+ ) {Log.warn('- Run `npx remotion versions --log=verbose` to see the path of the modules resolved.');@@ -125,7 +130,12 @@ export const versionsCommand = async () => {Log.info('- Remove the `^` character in front of a version to pin a package.');- if (!Internals.Logging.isEqualOrBelowLogLevel('verbose')) {+ if (+ !Internals.Logging.isEqualOrBelowLogLevel(+ Internals.Logging.getLogLevel(),+ 'verbose'+ )+ ) {Log.info('- Rerun this command with --log=verbose to see the path of the modules resolved.');diff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda/src/api/render-media-on-lambda.tsindex 936341d05b..62d01c0832 100644--- a/packages/lambda/src/api/render-media-on-lambda.ts+++ b/packages/lambda/src/api/render-media-on-lambda.ts@@ -32,6 +32,7 @@ export type RenderMediaOnLambdaInput = {logLevel?: LogLevel;frameRange?: FrameRange;outName?: string;+ timeoutInMilliseconds?: number;};export type RenderMediaOnLambdaOutput = {@@ -79,6 +80,7 @@ export const renderMediaOnLambda = async ({logLevel,frameRange,outName,+ timeoutInMilliseconds,}: RenderMediaOnLambdaInput): Promise<RenderMediaOnLambdaOutput> => {validateFramesPerLambda(framesPerLambda ?? null);const realServeUrl = await convertToServeUrl(serveUrl, region);@@ -103,6 +105,8 @@ export const renderMediaOnLambda = async ({logLevel: logLevel ?? Internals.Logging.DEFAULT_LOG_LEVEL,frameRange: frameRange ?? null,outName: outName ?? null,+ timeoutInMilliseconds:+ timeoutInMilliseconds ?? Internals.DEFAULT_PUPPETEER_TIMEOUT,},region,});diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.tsindex 7d9af955bf..c9d5c5f675 100644--- a/packages/lambda/src/api/render-still-on-lambda.ts+++ b/packages/lambda/src/api/render-still-on-lambda.ts@@ -1,4 +1,4 @@-import {LogLevel, StillImageFormat} from 'remotion';+import {Internals, LogLevel, StillImageFormat} from 'remotion';import {AwsRegion} from '../pricing/aws-regions';import {callLambda} from '../shared/call-lambda';import {@@ -22,6 +22,7 @@ export type RenderStillOnLambdaInput = {frame?: number;logLevel?: LogLevel;outName?: string;+ timeoutInMilliseconds?: number;};export type RenderStillOnLambdaOutput = {@@ -63,6 +64,7 @@ export const renderStillOnLambda = async ({frame,logLevel,outName,+ timeoutInMilliseconds,}: RenderStillOnLambdaInput): Promise<RenderStillOnLambdaOutput> => {const realServeUrl = await convertToServeUrl(serveUrl, region);@@ -82,6 +84,8 @@ export const renderStillOnLambda = async ({attempt: 1,logLevel,outName: outName ?? null,+ timeoutInMilliseconds:+ timeoutInMilliseconds ?? Internals.DEFAULT_PUPPETEER_TIMEOUT,},region,});diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.tsindex 01a665b0fd..726eb03e18 100644--- a/packages/lambda/src/functions/launch.ts+++ b/packages/lambda/src/functions/launch.ts@@ -111,6 +111,7 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {validateOutname(params.outName);validatePrivacy(params.privacy);+ RenderInternals.validatePuppeteerTimeout(params.timeoutInMilliseconds);const {chunks, didUseOptimization} = planFrameRanges({chunkCount,@@ -148,6 +149,7 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {privacy: params.privacy,logLevel: params.logLevel ?? Internals.Logging.DEFAULT_LOG_LEVEL,attempt: 1,+ timeoutInMilliseconds: params.timeoutInMilliseconds,};return payload;});diff --git a/packages/lambda/src/functions/start.ts b/packages/lambda/src/functions/start.tsindex 2ded9d52e6..c949059877 100644--- a/packages/lambda/src/functions/start.ts+++ b/packages/lambda/src/functions/start.ts@@ -1,4 +1,5 @@import {InvokeCommand} from '@aws-sdk/client-lambda';+import {RenderInternals} from '@remotion/renderer';import {Internals} from 'remotion';import {getOrCreateBucket} from '../api/get-or-create-bucket';import {getLambdaClient} from '../shared/aws-clients';@@ -20,6 +21,8 @@ export const startHandler = async (params: LambdaPayload) => {);}+ RenderInternals.validatePuppeteerTimeout(params.timeoutInMilliseconds);+const {bucketName} = await getOrCreateBucket({region: getCurrentRegionInFunction(),});@@ -46,6 +49,7 @@ export const startHandler = async (params: LambdaPayload) => {logLevel: params.logLevel ?? Internals.Logging.DEFAULT_LOG_LEVEL,frameRange: params.frameRange,outName: params.outName,+ timeoutInMilliseconds: params.timeoutInMilliseconds,};await getLambdaClient(getCurrentRegionInFunction()).send(new InvokeCommand({diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.tsindex cbbec1aabc..851b8df715 100644--- a/packages/lambda/src/shared/constants.ts+++ b/packages/lambda/src/shared/constants.ts@@ -171,6 +171,7 @@ export type LambdaPayloads = {logLevel: LogLevel;frameRange: FrameRange | null;outName: string | null;+ timeoutInMilliseconds: number;};launch: {type: LambdaRoutines.launch;@@ -193,6 +194,7 @@ export type LambdaPayloads = {logLevel: LogLevel;frameRange: FrameRange | null;outName: string | null;+ timeoutInMilliseconds: number;};fire: {type: LambdaRoutines.fire;@@ -228,6 +230,7 @@ export type LambdaPayloads = {privacy: Privacy;attempt: number;logLevel: LogLevel;+ timeoutInMilliseconds: number;};still: {type: LambdaRoutines.still;@@ -243,6 +246,7 @@ export type LambdaPayloads = {privacy: Privacy;logLevel?: LogLevel;outName: string | null;+ timeoutInMilliseconds: number;};};diff --git a/packages/renderer/src/index.ts b/packages/renderer/src/index.tsindex c6e4af7b18..5e17300517 100644--- a/packages/renderer/src/index.ts+++ b/packages/renderer/src/index.ts@@ -21,6 +21,7 @@ import {isServeUrl} from './is-serve-url';import {ensureOutputDirectory} from './ensure-output-directory';import got from 'got';import {getRealFrameRange} from './get-frame-to-render';+import {validatePuppeteerTimeout} from './validate-puppeteer-timeout';declare global {interface Window {@@ -70,4 +71,5 @@ export const RenderInternals = {ensureOutputDirectory,gotStream: got.stream,getRealFrameRange,+ validatePuppeteerTimeout,};diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.tsindex 03860fc7dc..abfcf0a09c 100644--- a/packages/renderer/src/render-media.ts+++ b/packages/renderer/src/render-media.ts@@ -57,6 +57,7 @@ export type RenderMediaOptions = {dumpBrowserLogs?: boolean;onBrowserLog?: ((log: BrowserLog) => void) | undefined;onStart?: (data: OnStartData) => void;+ timeoutInMilliseconds?: number;} & ServeUrlOrWebpackBundle;type Await<T> = T extends PromiseLike<infer U> ? U : T;@@ -82,6 +83,7 @@ export const renderMedia = async ({dumpBrowserLogs,onBrowserLog,onStart,+ timeoutInMilliseconds,...options}: RenderMediaOptions) => {Internals.validateQuality(quality);@@ -182,6 +184,7 @@ export const renderMedia = async ({dumpBrowserLogs,onBrowserLog,onDownload,+ timeoutInMilliseconds,});if (stitcherFfmpeg) {await waitForFinish();