π₯ Make videos programmatically with React
Kill Log.warn() too
Jonny Burgere676e4fb9900
diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.tsindex 7c395fd2fe..a472e76158 100644--- a/packages/cli/src/get-cli-options.ts+++ b/packages/cli/src/get-cli-options.ts@@ -12,14 +12,21 @@ import {getEnvironmentVariables} from './get-env';import {getInputProps} from './get-input-props';import {Log} from './log';-const getAndValidateFrameRange = () => {+const getAndValidateFrameRange = (logLevel: LogLevel, indent: boolean) => {const frameRange = ConfigInternals.getRange();if (typeof frameRange === 'number') {- Log.warn('Selected a single frame. Assuming you want to output an image.');- Log.warn(+ Log.warnAdvanced(+ {logLevel, indent},+ 'Selected a single frame. Assuming you want to output an image.',+ );+ Log.warnAdvanced(+ {logLevel, indent},`If you want to render a video, pass a range: '--frames=${frameRange}-${frameRange}'.`,);- Log.warn("To dismiss this message, add the '--sequence' flag explicitly.");+ Log.warnAdvanced(+ {indent, logLevel},+ "To dismiss this message, add the '--sequence' flag explicitly.",+ );}return frameRange;@@ -108,7 +115,7 @@ export const getCliOptions = async (options: {remotionRoot: string;logLevel: LogLevel;}) => {- const frameRange = getAndValidateFrameRange();+ const frameRange = getAndValidateFrameRange(options.logLevel, false);const shouldOutputImageSequence =options.type === 'still'@@ -159,8 +166,8 @@ export const getCliOptions = async (options: {concurrency,frameRange,shouldOutputImageSequence,- inputProps: getInputProps(null),- envVariables: await getEnvironmentVariables(null),+ inputProps: getInputProps(null, options.logLevel),+ envVariables: await getEnvironmentVariables(null, options.logLevel),jpegQuality: ConfigInternals.getJpegQuality(),browser: await getAndValidateBrowser({browserExecutable,diff --git a/packages/cli/src/get-env.ts b/packages/cli/src/get-env.tsindex d6f4b8116f..9ef2566fa9 100644--- a/packages/cli/src/get-env.ts+++ b/packages/cli/src/get-env.ts@@ -1,3 +1,4 @@+import type {LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import dotenv from 'dotenv';import fs from 'node:fs';@@ -26,10 +27,12 @@ const watchEnvFile = ({processEnv,envFile,onUpdate,+ logLevel,}: {processEnv: ReturnType<typeof getProcessEnv>;envFile: string;onUpdate: (newProps: Record<string, string>) => void;+ logLevel: LogLevel;}): (() => void) => {const updateFile = async () => {const file = await fs.promises.readFile(envFile, 'utf-8');@@ -44,7 +47,10 @@ const watchEnvFile = ({onChange: async (type) => {try {if (type === 'deleted') {- Log.warn(`${envFile} was deleted.`);+ Log.warnAdvanced(+ {indent: false, logLevel},+ `${envFile} was deleted.`,+ );} else if (type === 'changed') {await updateFile();Log.info(chalk.blueBright(`Updated env file ${envFile}`));@@ -66,16 +72,18 @@ const getEnvForEnvFile = async (processEnv: ReturnType<typeof getProcessEnv>,envFile: string,onUpdate: null | ((newProps: Record<string, string>) => void),+ logLevel: LogLevel,) => {try {const envFileData = await fs.promises.readFile(envFile);if (onUpdate) {if (typeof fs.watchFile === 'undefined') {- Log.warn(+ Log.warnAdvanced(+ {indent: false, logLevel},'Unsupported feature (fs.watchFile): .env file will not hot reload.',);} else {- watchEnvFile({processEnv, envFile, onUpdate});+ watchEnvFile({processEnv, envFile, onUpdate, logLevel});}}@@ -92,6 +100,7 @@ const getEnvForEnvFile = async (export const getEnvironmentVariables = (onUpdate: null | ((newProps: Record<string, string>) => void),+ logLevel: LogLevel,): Promise<Record<string, string>> => {const processEnv = getProcessEnv();@@ -104,7 +113,7 @@ export const getEnvironmentVariables = (process.exit(1);}- return getEnvForEnvFile(processEnv, envFile, onUpdate);+ return getEnvForEnvFile(processEnv, envFile, onUpdate, logLevel);}const remotionRoot = RenderInternals.findRemotionRoot();@@ -121,19 +130,23 @@ export const getEnvironmentVariables = (process.exit(1);}- return getEnvForEnvFile(processEnv, envFile, onUpdate);+ return getEnvForEnvFile(processEnv, envFile, onUpdate, logLevel);}const defaultEnvFile = path.resolve(remotionRoot, '.env');if (!fs.existsSync(defaultEnvFile)) {if (onUpdate) {if (typeof fs.watchFile === 'undefined') {- Log.warn('Unsupported Bun feature: .env file will not hot reload.');+ Log.warnAdvanced(+ {indent: false, logLevel},+ 'Unsupported Bun feature: .env file will not hot reload.',+ );} else {watchEnvFile({processEnv,envFile: defaultEnvFile,onUpdate,+ logLevel,});}}@@ -141,5 +154,5 @@ export const getEnvironmentVariables = (return Promise.resolve(processEnv);}- return getEnvForEnvFile(processEnv, defaultEnvFile, onUpdate);+ return getEnvForEnvFile(processEnv, defaultEnvFile, onUpdate, logLevel);};diff --git a/packages/cli/src/get-input-props.ts b/packages/cli/src/get-input-props.tsindex ca17a9c8ad..d7487428b8 100644--- a/packages/cli/src/get-input-props.ts+++ b/packages/cli/src/get-input-props.ts@@ -1,3 +1,4 @@+import type {LogLevel, LogOptions} from '@remotion/renderer';import fs from 'node:fs';import os from 'node:os';import path from 'node:path';@@ -6,6 +7,7 @@ import {parsedCli} from './parse-command-line';export const getInputProps = (onUpdate: ((newProps: Record<string, unknown>) => void) | null,+ logLevel: LogLevel,): Record<string, unknown> => {if (!parsedCli.props) {return {};@@ -43,15 +45,24 @@ export const getInputProps = ('Check that your input is parseable using `JSON.parse` and try again.',);if (os.platform() === 'win32') {- Log.warn(+ const logOptions: LogOptions = {+ indent: false,+ logLevel,+ };+ Log.warnAdvanced(+ logOptions,'Note: Windows handles escaping of quotes very weirdly in the command line.',);- Log.warn('This might have led to you having this problem.');- Log.warn(+ Log.warnAdvanced(+ logOptions,+ 'This might have led to you having this problem.',+ );+ Log.warnAdvanced(+ logOptions,'Consider using the alternative API for --props which is to pass',);- Log.warn('a path to a JSON file:');- Log.warn(' --props=path/to/props.json');+ Log.warnAdvanced(logOptions, 'a path to a JSON file:');+ Log.warnAdvanced(logOptions, ' --props=path/to/props.json');}process.exit(1);diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsxindex e672201a03..166c514e7d 100644--- a/packages/cli/src/index.tsx+++ b/packages/cli/src/index.tsx@@ -47,7 +47,7 @@ export const cli = async () => {const remotionRoot = RenderInternals.findRemotionRoot();if (command !== VERSIONS_COMMAND) {- await validateVersionsBeforeCommand(remotionRoot);+ await validateVersionsBeforeCommand(remotionRoot, 'info');}const isBun = typeof Bun !== 'undefined';diff --git a/packages/cli/src/initialize-cli.ts b/packages/cli/src/initialize-cli.tsindex 5c0872d70f..2db831ae5c 100644--- a/packages/cli/src/initialize-cli.ts+++ b/packages/cli/src/initialize-cli.ts@@ -18,7 +18,8 @@ export const initializeCli = async (remotionRoot,);if (remotionRoot !== process.cwd()) {- Log.warn(+ Log.warnAdvanced(+ {indent: false, logLevel},`Warning: The root directory of your project is ${remotionRoot}, but you are executing this command from ${process.cwd()}. The recommendation is to execute commands from the root directory.`,);}diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.tsindex b21eae2380..c0169ef8cb 100644--- a/packages/cli/src/parse-command-line.ts+++ b/packages/cli/src/parse-command-line.ts@@ -217,7 +217,10 @@ export const parseCommandLine = () => {}if (typeof parsedCli.quality !== 'undefined') {- Log.warn('The --quality flag has been renamed to --jpeg-quality instead.');+ Log.warnAdvanced(+ {indent: false, logLevel: 'info'},+ 'The --quality flag has been renamed to --jpeg-quality instead.',+ );Config.setJpegQuality(parsedCli.quality);}diff --git a/packages/cli/src/studio.ts b/packages/cli/src/studio.tsindex b8dbf59890..a74ad8225f 100644--- a/packages/cli/src/studio.ts+++ b/packages/cli/src/studio.ts@@ -105,7 +105,7 @@ export const studioCommand = async (newProps,});});- });+ }, logLevel);let envVariables = await getEnvironmentVariables((newEnvVariables) => {waitForLiveEventsListener().then((listener) => {envVariables = newEnvVariables;@@ -114,7 +114,7 @@ export const studioCommand = async (newEnvVariables,});});- });+ }, logLevel);const publicDir = getAbsolutePublicDir({userPassedPublicDir: ConfigInternals.getPublicDir(),diff --git a/packages/cli/src/versions.ts b/packages/cli/src/versions.tsindex 3b5b3c2278..e01397f2ab 100644--- a/packages/cli/src/versions.ts+++ b/packages/cli/src/versions.ts@@ -1,4 +1,4 @@-import type {LogLevel} from '@remotion/renderer';+import type {LogLevel, LogOptions} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import fs from 'node:fs';import {ConfigInternals} from './config';@@ -48,7 +48,10 @@ const getAllVersions = async (export const VERSIONS_COMMAND = 'versions';-export const validateVersionsBeforeCommand = async (remotionRoot: string) => {+export const validateVersionsBeforeCommand = async (+ remotionRoot: string,+ logLevel: LogLevel,+) => {const versions = await getAllVersions(remotionRoot);const grouped = groupBy(versions);@@ -59,27 +62,30 @@ export const validateVersionsBeforeCommand = async (remotionRoot: string) => {return;}- Log.warn('-------------');- Log.warn('Version mismatch:');+ const logOptions: LogOptions = {indent: false, logLevel};+ Log.warnAdvanced(logOptions, '-------------');+ Log.warnAdvanced(logOptions, 'Version mismatch:');for (const version of installedVersions) {- Log.warn(`- On version: ${version}`);+ Log.warnAdvanced(logOptions, `- On version: ${version}`);for (const pkg of grouped[version]) {- Log.warn(` - ${pkg}`);+ Log.warnAdvanced(logOptions, ` - ${pkg}`);}Log.info();}- Log.warn('You may experience breakages such as:');- Log.warn('- React context and hooks not working');- Log.warn('- Type errors and feature incompatibilities');- Log.warn('- Failed renders and unclear errors');- Log.warn();- Log.warn('To resolve:');- Log.warn(+ Log.warnAdvanced(logOptions, 'You may experience breakages such as:');+ Log.warnAdvanced(logOptions, '- React context and hooks not working');+ Log.warnAdvanced(logOptions, '- Type errors and feature incompatibilities');+ Log.warnAdvanced(logOptions, '- Failed renders and unclear errors');+ Log.warnAdvanced(logOptions);+ Log.warnAdvanced(logOptions, 'To resolve:');+ Log.warnAdvanced(+ logOptions,'- Make sure your package.json has all Remotion packages pointing to the same version.',);- Log.warn(+ Log.warnAdvanced(+ logOptions,'- Remove the `^` character in front of a version to pin a package.',);if (@@ -88,12 +94,13 @@ export const validateVersionsBeforeCommand = async (remotionRoot: string) => {'verbose',)) {- Log.warn(+ Log.warnAdvanced(+ logOptions,'- Run `npx remotion versions --log=verbose` to see the path of the modules resolved.',);}- Log.warn('-------------');+ Log.warnAdvanced(logOptions, '-------------');Log.info();};diff --git a/packages/cloudrun/src/cli/commands/sites/index.ts b/packages/cloudrun/src/cli/commands/sites/index.tsindex 62c878f67f..b6cbd8a97e 100644--- a/packages/cloudrun/src/cli/commands/sites/index.ts+++ b/packages/cloudrun/src/cli/commands/sites/index.ts@@ -59,7 +59,7 @@ export const sitesCommand = (logLevel: LogLevel,) => {if (args[0] === SITES_LS_SUBCOMMAND) {- return sitesLsSubcommand();+ return sitesLsSubcommand(logLevel);}if (args[0] === SITES_RM_COMMAND) {diff --git a/packages/cloudrun/src/cli/commands/sites/ls.ts b/packages/cloudrun/src/cli/commands/sites/ls.tsindex 11eee91b8e..cc764b8fc3 100644--- a/packages/cloudrun/src/cli/commands/sites/ls.ts+++ b/packages/cloudrun/src/cli/commands/sites/ls.ts@@ -1,4 +1,5 @@import {CliInternals} from '@remotion/cli';+import type {LogLevel} from '@remotion/renderer';import {displaySiteInfo} from '.';import {getSites} from '../../../api/get-sites';import {parsedCloudrunCli} from '../../args';@@ -7,7 +8,7 @@ import {Log} from '../../log';export const SITES_LS_SUBCOMMAND = 'ls';-export const sitesLsSubcommand = async () => {+export const sitesLsSubcommand = async (logLevel: LogLevel) => {// check if --allRegions flag is provided// if so, list all sites// else, list only the sites that are in the current project@@ -18,7 +19,8 @@ export const sitesLsSubcommand = async () => {const {sites, buckets} = await getSites(region);if (buckets.length > 1 && !CliInternals.quietFlagProvided() && !allRegions) {- Log.warn(+ Log.warnAdvanced(+ {indent: false, logLevel},`Warning: You have more than one Remotion Cloud Storage bucket in ${region}, but only one is needed. This can lead to conflicts. Remove all but one of them.`,);}diff --git a/packages/cloudrun/src/functions/helpers/get-composition-from-body.ts b/packages/cloudrun/src/functions/helpers/get-composition-from-body.tsindex 057800d3a8..f656a6b751 100644--- a/packages/cloudrun/src/functions/helpers/get-composition-from-body.ts+++ b/packages/cloudrun/src/functions/helpers/get-composition-from-body.ts@@ -26,7 +26,8 @@ export const getCompositionFromBody = async (body: CloudRunPayloadType) => {);if (propsSize > 10_000_000) {- RenderInternals.Log.warn(+ RenderInternals.Log.warnAdvanced(+ {indent: false, logLevel: body.logLevel},`The props of your composition are large (${propsSize} bytes). This may cause slowdown.`,);}diff --git a/packages/compositor-darwin-arm64/compositor b/packages/compositor-darwin-arm64/compositorindex 95404762af..bb4ca4a84d 100755Binary files a/packages/compositor-darwin-arm64/compositor and b/packages/compositor-darwin-arm64/compositor differdiff --git a/packages/lambda/src/cli/commands/quotas/increase.ts b/packages/lambda/src/cli/commands/quotas/increase.tsindex ab4195e9e6..ec9c3c3895 100644--- a/packages/lambda/src/cli/commands/quotas/increase.ts+++ b/packages/lambda/src/cli/commands/quotas/increase.ts@@ -4,6 +4,7 @@ import {ListRequestedServiceQuotaChangeHistoryByQuotaCommand,RequestServiceQuotaIncreaseCommand,} from '@aws-sdk/client-service-quotas';+import type {LogLevel, LogOptions} from '@remotion/renderer';import {exit} from 'node:process';import {QUOTAS_COMMAND} from '.';import type {AwsRegion} from '../../../client';@@ -27,7 +28,7 @@ const makeQuotaUrl = ({return `https://${region}.console.aws.amazon.com/servicequotas/home/services/lambda/quotas/${quotaId}`;};-export const quotasIncreaseCommand = async () => {+export const quotasIncreaseCommand = async (logLevel: LogLevel) => {const region = getAwsRegion();const [concurrencyLimit, defaultConcurrencyLimit, changes] =@@ -56,10 +57,16 @@ export const quotasIncreaseCommand = async () => {(r) => r.Status === 'CASE_OPENED',);if (openCase) {- Log.warn(+ const logOptions: LogOptions = {+ indent: false,+ logLevel,+ };+ Log.warnAdvanced(+ logOptions,`A request to increase it to ${openCase.DesiredValue} is already pending:`,);- Log.warn(+ Log.warnAdvanced(+ logOptions,`https://${region}.console.aws.amazon.com/support/home#/case/?displayId=${openCase.CaseId}`,);exit(1);diff --git a/packages/lambda/src/cli/commands/quotas/index.ts b/packages/lambda/src/cli/commands/quotas/index.tsindex b249af4748..cf5369fc51 100644--- a/packages/lambda/src/cli/commands/quotas/index.ts+++ b/packages/lambda/src/cli/commands/quotas/index.ts@@ -1,4 +1,5 @@import {CliInternals} from '@remotion/cli';+import type {LogLevel} from '@remotion/renderer';import {BINARY_NAME} from '../../../defaults';import {INCREASE_SUBCOMMAND, quotasIncreaseCommand} from './increase';import {quotasListCommand} from './list';@@ -18,13 +19,13 @@ const printHelp = () => {CliInternals.Log.info(CliInternals.chalk.gray('Increase Lambda quotas.'));};-export const quotasCommand = (args: string[]) => {+export const quotasCommand = (args: string[], logLevel: LogLevel) => {if (args.filter(Boolean).length === 0) {- return quotasListCommand();+ return quotasListCommand(logLevel);}if (args[0] === INCREASE_SUBCOMMAND) {- return quotasIncreaseCommand();+ return quotasIncreaseCommand(logLevel);}CliInternals.Log.error('Subcommand ' + args[0] + ' not found.');diff --git a/packages/lambda/src/cli/commands/quotas/list.ts b/packages/lambda/src/cli/commands/quotas/list.tsindex b3fba6c7b7..a53ae142c2 100644--- a/packages/lambda/src/cli/commands/quotas/list.ts+++ b/packages/lambda/src/cli/commands/quotas/list.ts@@ -4,6 +4,7 @@ import {ListRequestedServiceQuotaChangeHistoryByQuotaCommand,} from '@aws-sdk/client-service-quotas';import {CliInternals} from '@remotion/cli';+import type {LogLevel} from '@remotion/renderer';import {QUOTAS_COMMAND} from '.';import {BINARY_NAME,@@ -15,7 +16,7 @@ import {getAwsRegion} from '../../get-aws-region';import {Log} from '../../log';import {INCREASE_SUBCOMMAND} from './increase';-export const quotasListCommand = async () => {+export const quotasListCommand = async (logLevel: LogLevel) => {const region = getAwsRegion();Log.info(CliInternals.chalk.gray(`Region = ${region}`));Log.info();@@ -71,10 +72,12 @@ export const quotasListCommand = async () => {}if (openCase) {- Log.warn(+ Log.warnAdvanced(+ {indent: false, logLevel},`A request to increase it to ${openCase.DesiredValue} is pending:`,);- Log.warn(+ Log.warnAdvanced(+ {indent: false, logLevel},`https://${region}.console.aws.amazon.com/support/home#/case/?displayId=${openCase.CaseId}`,);}diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.tsindex 5d7c3a8179..631f2fef77 100644--- a/packages/lambda/src/cli/commands/render/render.ts+++ b/packages/lambda/src/cli/commands/render/render.ts@@ -166,7 +166,7 @@ export const renderCommand = async (const framesPerLambda = parsedLambdaCli['frames-per-lambda'] ?? undefined;validateFramesPerLambda({framesPerLambda, durationInFrames: 1});- const webhookCustomData = getWebhookCustomData();+ const webhookCustomData = getWebhookCustomData(logLevel);const res = await internalRenderMediaOnLambdaRaw({functionName,diff --git a/packages/lambda/src/cli/commands/sites/index.ts b/packages/lambda/src/cli/commands/sites/index.tsindex ec93c30d15..1ec34c9569 100644--- a/packages/lambda/src/cli/commands/sites/index.ts+++ b/packages/lambda/src/cli/commands/sites/index.ts@@ -49,7 +49,7 @@ export const sitesCommand = (logLevel: LogLevel,) => {if (args[0] === SITES_LS_SUBCOMMAND) {- return sitesLsSubcommand();+ return sitesLsSubcommand(logLevel);}if (args[0] === SITES_RM_COMMAND) {diff --git a/packages/lambda/src/cli/commands/sites/ls.ts b/packages/lambda/src/cli/commands/sites/ls.tsindex 0cb5f6ee6d..05de31e811 100644--- a/packages/lambda/src/cli/commands/sites/ls.ts+++ b/packages/lambda/src/cli/commands/sites/ls.ts@@ -1,4 +1,5 @@import {CliInternals} from '@remotion/cli';+import type {LogLevel} from '@remotion/renderer';import {getSites} from '../../../api/get-sites';import {getAwsRegion} from '../../get-aws-region';import {dateString} from '../../helpers/date-string';@@ -16,12 +17,13 @@ const logRow = (data: [string, string, string, string]) => {].join('');};-export const sitesLsSubcommand = async () => {+export const sitesLsSubcommand = async (logLevel: LogLevel) => {const region = getAwsRegion();const {sites, buckets} = await getSites({region});if (buckets.length > 1 && !CliInternals.quietFlagProvided()) {- CliInternals.Log.warn(+ CliInternals.Log.warnAdvanced(+ {indent: false, logLevel},'Warning: You have more than one Remotion S3 bucket, but only one is needed. This can lead to conflicts. Remove all but one of them.',);}diff --git a/packages/lambda/src/cli/helpers/get-webhook-custom-data.ts b/packages/lambda/src/cli/helpers/get-webhook-custom-data.tsindex a664dca51e..132e70a294 100644--- a/packages/lambda/src/cli/helpers/get-webhook-custom-data.ts+++ b/packages/lambda/src/cli/helpers/get-webhook-custom-data.ts@@ -1,3 +1,4 @@+import type {LogLevel, LogOptions} from '@remotion/renderer';import {BrowserSafeApis} from '@remotion/renderer/client';import fs from 'node:fs';import os from 'node:os';@@ -5,7 +6,9 @@ import path from 'node:path';import {parsedLambdaCli} from '../args';import {Log} from '../log';-export const getWebhookCustomData = (): Record<string, unknown> | null => {+export const getWebhookCustomData = (+ logLevel: LogLevel,+): Record<string, unknown> | null => {const flagName = BrowserSafeApis.options.webhookCustomDataOption.cliFlag;const webhookFlag = parsedLambdaCli[flagName];@@ -31,15 +34,24 @@ export const getWebhookCustomData = (): Record<string, unknown> | null => {'Check that your input is parseable using `JSON.parse` and try again.',);if (os.platform() === 'win32') {- Log.warn(+ const logOptions: LogOptions = {+ indent: false,+ logLevel,+ };+ Log.warnAdvanced(+ logOptions,'Note: Windows handles escaping of quotes very weirdly in the command line.',);- Log.warn('This might have led to you having this problem.');- Log.warn(+ Log.warnAdvanced(+ logOptions,+ 'This might have led to you having this problem.',+ );+ Log.warnAdvanced(+ logOptions,'Consider using the alternative API for --props which is to pass',);- Log.warn('a path to a JSON file:');- Log.warn(` --${flagName}=path/to/props.json`);+ Log.warnAdvanced(logOptions, 'a path to a JSON file:');+ Log.warnAdvanced(logOptions, ` --${flagName}=path/to/props.json`);}process.exit(1);diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.tsindex 3e617aaab9..9feecf2db7 100644--- a/packages/lambda/src/cli/index.ts+++ b/packages/lambda/src/cli/index.ts@@ -74,7 +74,7 @@ const matchCommand = (}if (args[0] === QUOTAS_COMMAND) {- return quotasCommand(args.slice(1));+ return quotasCommand(args.slice(1), logLevel);}if (args[0] === POLICIES_COMMAND) {diff --git a/packages/renderer/src/get-available-memory.ts b/packages/renderer/src/get-available-memory.tsindex e3e2059e56..e212acc21b 100644--- a/packages/renderer/src/get-available-memory.ts+++ b/packages/renderer/src/get-available-memory.ts@@ -1,5 +1,6 @@import {existsSync, readFileSync} from 'node:fs';import {freemem} from 'node:os';+import type {LogLevel} from './log-level';import {Log} from './logger';const getFreeMemoryFromProcMeminfo = (): number | null => {@@ -37,15 +38,16 @@ const getFreeMemoryFromProcMeminfo = (): number | null => {}};-export const getAvailableMemory = () => {+export const getAvailableMemory = (logLevel: LogLevel) => {if (existsSync('/proc/meminfo')) {try {getFreeMemoryFromProcMeminfo();} catch (err) {- Log.warn(+ Log.warnAdvanced(+ {indent: false, logLevel},'Tried to get available memory from /proc/meminfo but failed. Falling back to os.freemem(). Error:',);- Log.warn(err);+ Log.warnAdvanced({indent: false, logLevel}, err);}}diff --git a/packages/renderer/src/get-compositions.ts b/packages/renderer/src/get-compositions.tsindex 5ded247dc9..5fef76931c 100644--- a/packages/renderer/src/get-compositions.ts+++ b/packages/renderer/src/get-compositions.ts@@ -109,7 +109,13 @@ const innerGetCompositions = async ({args: [],});- await waitForReady({page, timeoutInMilliseconds, frame: null});+ await waitForReady({+ page,+ timeoutInMilliseconds,+ frame: null,+ indent,+ logLevel,+ });const {value: result} = await puppeteerEvaluateWithCatch({pageFunction: () => {return window.getStaticCompositions();diff --git a/packages/renderer/src/get-video-threads-flag.ts b/packages/renderer/src/get-video-threads-flag.tsindex 5670b08b1f..65ed2edbf9 100644--- a/packages/renderer/src/get-video-threads-flag.ts+++ b/packages/renderer/src/get-video-threads-flag.ts@@ -1,10 +1,12 @@import {getAvailableMemory} from './get-available-memory';import {getCpuCount} from './get-cpu-count';+import type {LogLevel} from './log-level';+const MEMORY_USAGE_PER_THREAD = 400_000_000; // 400MBconst RESERVED_MEMORY = 2_000_000_000;-export const getIdealVideoThreadsFlag = () => {- const freeMemory = getAvailableMemory();+export const getIdealVideoThreadsFlag = (logLevel: LogLevel) => {+ const freeMemory = getAvailableMemory(logLevel);const cpus = getCpuCount();const maxRecommendedBasedOnCpus = (cpus * 2) / 3;diff --git a/packages/renderer/src/index.ts b/packages/renderer/src/index.tsindex 837acc6e4b..9b91c07d4d 100644--- a/packages/renderer/src/index.ts+++ b/packages/renderer/src/index.ts@@ -98,6 +98,7 @@ export {VideoImageFormat,} from './image-format';export type {LogLevel} from './log-level';+export {LogOptions} from './logger';export {CancelSignal, makeCancelSignal} from './make-cancel-signal';export {openBrowser} from './open-browser';export type {ChromiumOptions} from './open-browser';diff --git a/packages/renderer/src/logger.ts b/packages/renderer/src/logger.tsindex 8cce537ce3..8b30289609 100644--- a/packages/renderer/src/logger.ts+++ b/packages/renderer/src/logger.ts@@ -6,7 +6,7 @@ import {truthy} from './truthy';export const INDENT_TOKEN = chalk.gray('β');-type LogOptions = {+export type LogOptions = {indent: boolean;logLevel: LogLevel;};@@ -50,11 +50,7 @@ export const Log = {...[options.indent ? INDENT_TOKEN : null].filter(truthy).concat(args),);},- warn: (...args: Parameters<typeof console.log>) => {- if (isEqualOrBelowLogLevel(getLogLevel(), 'warn')) {- Log.warnAdvanced({indent: false, logLevel: getLogLevel()}, ...args);- }- },+warnAdvanced: (options: LogOptions,...args: Parameters<typeof console.log>diff --git a/packages/renderer/src/open-browser.ts b/packages/renderer/src/open-browser.tsindex 6b67c85086..4e0536a0f5 100644--- a/packages/renderer/src/open-browser.ts+++ b/packages/renderer/src/open-browser.ts@@ -134,7 +134,7 @@ export const internalOpenBrowser = async ({'--force-color-profile=srgb','--metrics-recording-only','--no-first-run',- '--video-threads=' + getIdealVideoThreadsFlag(),+ '--video-threads=' + getIdealVideoThreadsFlag(logLevel),'--enable-automation','--password-store=basic','--use-mock-keychain',diff --git a/packages/renderer/src/prestitcher-memory-usage.ts b/packages/renderer/src/prestitcher-memory-usage.tsindex eed1f100d5..3d1db8fa7d 100644--- a/packages/renderer/src/prestitcher-memory-usage.ts+++ b/packages/renderer/src/prestitcher-memory-usage.ts@@ -1,4 +1,5 @@import {getAvailableMemory} from './get-available-memory';+import type {LogLevel} from './log-level';const estimateMemoryUsageForPrestitcher = ({width,@@ -18,11 +19,13 @@ const estimateMemoryUsageForPrestitcher = ({export const shouldUseParallelEncoding = ({width,height,+ logLevel,}: {width: number;height: number;+ logLevel: LogLevel;}) => {- const freeMemory = getAvailableMemory();+ const freeMemory = getAvailableMemory(logLevel);const estimatedUsage = estimateMemoryUsageForPrestitcher({height,width,diff --git a/packages/renderer/src/render-frames.ts b/packages/renderer/src/render-frames.tsindex 2f1a6e180a..9bd6d8505a 100644--- a/packages/renderer/src/render-frames.ts+++ b/packages/renderer/src/render-frames.ts@@ -392,6 +392,8 @@ const innerRenderFrames = async ({page: freePage,composition: compId,timeoutInMilliseconds,+ indent,+ logLevel,});const timeToSeek = Date.now() - startSeeking;diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.tsindex 63354ad992..5a106870bd 100644--- a/packages/renderer/src/render-media.ts+++ b/packages/renderer/src/render-media.ts@@ -287,6 +287,7 @@ const internalRenderMediaRaw = ({shouldUseParallelEncoding({height: composition.height,width: composition.width,+ logLevel,});const parallelEncoding =!disallowParallelEncoding &&diff --git a/packages/renderer/src/render-still.ts b/packages/renderer/src/render-still.tsindex 39d2c79089..5c8872f6c9 100644--- a/packages/renderer/src/render-still.ts+++ b/packages/renderer/src/render-still.ts@@ -317,6 +317,8 @@ const innerRenderStill = async ({page,composition: composition.id,timeoutInMilliseconds,+ indent,+ logLevel,});const {buffer} = await takeFrameAndCompose({diff --git a/packages/renderer/src/seek-to-frame.ts b/packages/renderer/src/seek-to-frame.tsindex 2e2c650e72..5b50694ee1 100644--- a/packages/renderer/src/seek-to-frame.ts+++ b/packages/renderer/src/seek-to-frame.ts@@ -1,9 +1,10 @@-import {RenderInternals} from '.';import {BrowserEmittedEvents} from './browser/Browser';import type {Page} from './browser/BrowserPage';import {PageEmittedEvents} from './browser/BrowserPage';import type {JSHandle} from './browser/JSHandle';import {SymbolicateableError} from './error-handling/symbolicateable-error';+import type {LogLevel} from './log-level';+import {Log} from './logger';import {parseStack} from './parse-browser-error-stack';import {puppeteerEvaluateWithCatch,@@ -14,10 +15,14 @@ export const waitForReady = ({page,timeoutInMilliseconds,frame,+ indent,+ logLevel,}: {page: Page;timeoutInMilliseconds: number;frame: number | null;+ indent: boolean;+ logLevel: LogLevel;}) => {const waitForReadyProm = new Promise<JSHandle>((resolve, reject) => {page@@ -69,7 +74,8 @@ export const waitForReady = ({);}).catch((newErr) => {- RenderInternals.Log.warn(+ Log.warnAdvanced(+ {indent, logLevel},'Tried to get delayRender() handles for timeout, but could not do so because of',newErr,);@@ -148,13 +154,23 @@ export const seekToFrame = async ({page,composition,timeoutInMilliseconds,+ logLevel,+ indent,}: {frame: number;composition: string;page: Page;timeoutInMilliseconds: number;+ logLevel: LogLevel;+ indent: boolean;}) => {- await waitForReady({page, timeoutInMilliseconds, frame: null});+ await waitForReady({+ page,+ timeoutInMilliseconds,+ frame: null,+ indent,+ logLevel,+ });await puppeteerEvaluateWithCatchAndTimeout({pageFunction: (f: number, c: string) => {window.remotion_setFrame(f, c);@@ -163,6 +179,6 @@ export const seekToFrame = async ({frame,page,});- await waitForReady({page, timeoutInMilliseconds, frame});+ await waitForReady({page, timeoutInMilliseconds, frame, indent, logLevel});await page.evaluateHandle('document.fonts.ready');};diff --git a/packages/renderer/src/select-composition.ts b/packages/renderer/src/select-composition.tsindex 170c638a3d..d387ccf9c8 100644--- a/packages/renderer/src/select-composition.ts+++ b/packages/renderer/src/select-composition.ts@@ -115,7 +115,13 @@ const innerSelectComposition = async ({args: [],});- await waitForReady({page, timeoutInMilliseconds, frame: null});+ await waitForReady({+ page,+ timeoutInMilliseconds,+ frame: null,+ logLevel,+ indent,+ });Log.verboseAdvanced({