🎥 Make videos programmatically with React
move stuff around
Jonny Burgerc14eb1ffd301
diff --git a/packages/bundler/src/bundle.ts b/packages/bundler/src/bundle.tsindex b51b5a78b7..6af92aa413 100644--- a/packages/bundler/src/bundle.ts+++ b/packages/bundler/src/bundle.ts@@ -2,7 +2,6 @@ import fs from 'fs';import os from 'os';import path from 'path';import type {WebpackOverrideFn} from 'remotion';-import {Internals} from 'remotion';import {promisify} from 'util';import webpack from 'webpack';import {copyDir} from './copy-dir';@@ -56,11 +55,9 @@ export const getConfig = (userDefinedComponent: entryPoint,outDir,environment: 'production',- webpackOverride:- options?.webpackOverride ?? Internals.defaultOverrideFunction,+ webpackOverride: options?.webpackOverride ?? ((f) => f),onProgressUpdate,- enableCaching:- options?.enableCaching ?? Internals.DEFAULT_WEBPACK_CACHE_ENABLED,+ enableCaching: options?.enableCaching ?? true,maxTimelineTracks: 15,// For production, the variables are set dynamicallyenvVariables: {},diff --git a/packages/bundler/src/setup-environment.ts b/packages/bundler/src/setup-environment.tsindex 511c0c6071..420ad9ffe5 100644--- a/packages/bundler/src/setup-environment.ts+++ b/packages/bundler/src/setup-environment.ts@@ -1,7 +1,6 @@import {Internals} from 'remotion';Internals.setupEnvVariables();-Internals.setupPuppeteerTimeout();Internals.CSSUtils.injectCSS(`.css-reset * {diff --git a/packages/bundler/src/webpack-config.ts b/packages/bundler/src/webpack-config.tsindex 803b4cba88..7fa01ded1d 100644--- a/packages/bundler/src/webpack-config.ts+++ b/packages/bundler/src/webpack-config.ts@@ -40,7 +40,7 @@ export const webpackConfig = ({environment,webpackOverride = (f) => f,onProgressUpdate,- enableCaching = Internals.DEFAULT_WEBPACK_CACHE_ENABLED,+ enableCaching = true,envVariables,maxTimelineTracks,entryPoints,diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex d0a0ff2f0e..c1addfdeb1 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -27,6 +27,7 @@"@remotion/media-utils": "3.1.5","@remotion/player": "3.1.5","@remotion/renderer": "3.1.5",+ "@remotion/config": "3.1.5","better-opn": "2.1.1","dotenv": "9.0.2","memfs": "3.4.3",diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.tsindex 079c03fea4..49777cd7cb 100644--- a/packages/cli/src/get-cli-options.ts+++ b/packages/cli/src/get-cli-options.ts@@ -1,17 +1,23 @@-import type {ChromiumOptions} from '@remotion/renderer';+import {ConfigInternals} from '@remotion/config';+import type {+ BrowserExecutable,+ ChromiumOptions,+ Codec,+ FrameRange,+ PixelFormat,+} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import fs from 'fs';import path from 'path';-import type {BrowserExecutable, Codec, FrameRange, PixelFormat} from 'remotion';-import {Internals} from 'remotion';import {getEnvironmentVariables} from './get-env';+import {getFinalOutputCodec} from './get-final-output-codec';import {getInputProps} from './get-input-props';import {getImageFormat} from './image-formats';import {Log} from './log';import {getUserPassedOutputLocation} from './user-passed-output-location';const getAndValidateFrameRange = () => {- const frameRange = Internals.getRange();+ const frameRange = ConfigInternals.getRange();if (typeof frameRange === 'number') {Log.warn('Selected a single frame. Assuming you want to output an image.');Log.warn(@@ -24,16 +30,16 @@ const getAndValidateFrameRange = () => {};const getFinalCodec = async (options: {isLambda: boolean}) => {- const userCodec = Internals.getOutputCodecOrUndefined();+ const userCodec = ConfigInternals.getOutputCodecOrUndefined();- const codec = Internals.getFinalOutputCodec({+ const codec = getFinalOutputCodec({codec: userCodec,fileExtension: options.isLambda? null: RenderInternals.getExtensionOfFilename(getUserPassedOutputLocation()),emitWarning: true,});- const ffmpegExecutable = Internals.getCustomFfmpegExecutable();+ const ffmpegExecutable = ConfigInternals.getCustomFfmpegExecutable();if (codec === 'vp8' &&!(await RenderInternals.ffmpegHasFeature({@@ -85,7 +91,8 @@ const getFinalCodec = async (options: {isLambda: boolean}) => {return codec;};-const getBrowser = () => Internals.getBrowser() ?? Internals.DEFAULT_BROWSER;+const getBrowser = () =>+ ConfigInternals.getBrowser() ?? RenderInternals.DEFAULT_BROWSER;export const getAndValidateAbsoluteOutputFile = (relativeOutputLocation: string,@@ -113,10 +120,12 @@ const getAndValidateShouldOutputImageSequence = async ({isLambda: boolean;}) => {const shouldOutputImageSequence =- Internals.getShouldOutputImageSequence(frameRange);+ ConfigInternals.getShouldOutputImageSequence(frameRange);// When parsing options locally, we don't need FFMPEG because the render will happen on Lambdaif (!shouldOutputImageSequence && !isLambda) {- await RenderInternals.validateFfmpeg(Internals.getCustomFfmpegExecutable());+ await RenderInternals.validateFfmpeg(+ ConfigInternals.getCustomFfmpegExecutable()+ );}return shouldOutputImageSequence;@@ -126,24 +135,29 @@ const getAndValidateCrf = (shouldOutputImageSequence: boolean,codec: Codec) => {- const crf = shouldOutputImageSequence ? null : Internals.getActualCrf(codec);+ const crf = shouldOutputImageSequence+ ? null+ : ConfigInternals.getActualCrf(codec);if (crf !== null) {- Internals.validateSelectedCrfAndCodecCombination(crf, codec);+ RenderInternals.validateSelectedCrfAndCodecCombination(crf, codec);}return crf;};const getAndValidatePixelFormat = (codec: Codec) => {- const pixelFormat = Internals.getPixelFormat();+ const pixelFormat = ConfigInternals.getPixelFormat();- Internals.validateSelectedPixelFormatAndCodecCombination(pixelFormat, codec);+ RenderInternals.validateSelectedPixelFormatAndCodecCombination(+ pixelFormat,+ codec+ );return pixelFormat;};const getAndValidateProResProfile = (actualCodec: Codec) => {- const proResProfile = Internals.getProResProfile();- Internals.validateSelectedCodecAndProResCombination(+ const proResProfile = ConfigInternals.getProResProfile();+ RenderInternals.validateSelectedCodecAndProResCombination(actualCodec,proResProfile);@@ -163,7 +177,7 @@ const getAndValidateImageFormat = ({const imageFormat = getImageFormat(shouldOutputImageSequence ? undefined : codec);- Internals.validateSelectedPixelFormatAndImageFormatCombination(+ RenderInternals.validateSelectedPixelFormatAndImageFormatCombination(pixelFormat,imageFormat);@@ -203,7 +217,7 @@ export const getCliOptions = async (options: {isLambda: options.isLambda,});- const overwrite = Internals.getShouldOverwrite();+ const overwrite = ConfigInternals.getShouldOverwrite();const crf = getAndValidateCrf(shouldOutputImageSequence, codec);const pixelFormat = getAndValidatePixelFormat(codec);const imageFormat = getAndValidateImageFormat({@@ -212,36 +226,37 @@ export const getCliOptions = async (options: {pixelFormat,});const proResProfile = getAndValidateProResProfile(codec);- const browserExecutable = Internals.getBrowserExecutable();- const ffmpegExecutable = Internals.getCustomFfmpegExecutable();- const ffprobeExecutable = Internals.getCustomFfprobeExecutable();- const scale = Internals.getScale();- const port = Internals.getServerPort();+ const browserExecutable = ConfigInternals.getBrowserExecutable();+ const ffmpegExecutable = ConfigInternals.getCustomFfmpegExecutable();+ const ffprobeExecutable = ConfigInternals.getCustomFfprobeExecutable();+ const scale = ConfigInternals.getScale();+ const port = ConfigInternals.getServerPort();const chromiumOptions: ChromiumOptions = {- disableWebSecurity: Internals.getChromiumDisableWebSecurity(),- ignoreCertificateErrors: Internals.getIgnoreCertificateErrors(),- headless: Internals.getChromiumHeadlessMode(),+ disableWebSecurity: ConfigInternals.getChromiumDisableWebSecurity(),+ ignoreCertificateErrors: ConfigInternals.getIgnoreCertificateErrors(),+ headless: ConfigInternals.getChromiumHeadlessMode(),gl:- Internals.getChromiumOpenGlRenderer() ??- Internals.DEFAULT_OPENGL_RENDERER,+ ConfigInternals.getChromiumOpenGlRenderer() ??+ RenderInternals.DEFAULT_OPENGL_RENDERER,};- const everyNthFrame = Internals.getAndValidateEveryNthFrame(codec);- const numberOfGifLoops = Internals.getAndValidateNumberOfGifLoops(codec);+ const everyNthFrame = ConfigInternals.getAndValidateEveryNthFrame(codec);+ const numberOfGifLoops =+ ConfigInternals.getAndValidateNumberOfGifLoops(codec);- const parallelism = Internals.getConcurrency();+ const parallelism = ConfigInternals.getConcurrency();RenderInternals.validateConcurrency(parallelism, 'concurrency');return {- puppeteerTimeout: Internals.getCurrentPuppeteerTimeout(),+ puppeteerTimeout: ConfigInternals.getCurrentPuppeteerTimeout(),parallelism,frameRange,shouldOutputImageSequence,codec,inputProps: getInputProps(() => undefined),envVariables: await getEnvironmentVariables(),- quality: Internals.getQuality(),+ quality: ConfigInternals.getQuality(),browser: await getAndValidateBrowser(browserExecutable),crf,pixelFormat,@@ -249,11 +264,11 @@ export const getCliOptions = async (options: {proResProfile,everyNthFrame,numberOfGifLoops,- stillFrame: Internals.getStillFrame(),+ stillFrame: ConfigInternals.getStillFrame(),browserExecutable,ffmpegExecutable,ffprobeExecutable,- logLevel: Internals.Logging.getLogLevel(),+ logLevel: ConfigInternals.Logging.getLogLevel(),scale,chromiumOptions,overwrite,diff --git a/packages/cli/src/get-env.ts b/packages/cli/src/get-env.tsindex 8a5fc2759b..270df3e0ce 100644--- a/packages/cli/src/get-env.ts+++ b/packages/cli/src/get-env.ts@@ -1,7 +1,7 @@+import {ConfigInternals} from '@remotion/config';import dotenv from 'dotenv';import fs from 'fs';import path from 'path';-import {Internals} from 'remotion';import {Log} from './log';import {parsedCli} from './parse-command-line';@@ -51,7 +51,7 @@ export const getEnvironmentVariables = (): Promise<Record<string, string>> => {return getEnvForEnvFile(processEnv, envFile);}- const configFileSetting = Internals.getDotEnvLocation();+ const configFileSetting = ConfigInternals.getDotEnvLocation();if (configFileSetting) {const envFile = path.resolve(process.cwd(), configFileSetting);if (!fs.existsSync(envFile)) {diff --git a/packages/cli/src/get-filename.ts b/packages/cli/src/get-filename.tsindex 17d6d70654..db5d193774 100644--- a/packages/cli/src/get-filename.ts+++ b/packages/cli/src/get-filename.ts@@ -1,5 +1,5 @@+import type {Codec} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';-import type {Codec} from 'remotion';import {Log} from './log';import {getOutputLocation} from './user-passed-output-location';diff --git a/packages/cli/src/get-final-output-codec.ts b/packages/cli/src/get-final-output-codec.tsnew file mode 100644index 0000000000..a13e15ea8c--- /dev/null+++ b/packages/cli/src/get-final-output-codec.ts@@ -0,0 +1,93 @@+import type {Codec, CodecOrUndefined} from '@remotion/renderer';+import {RenderInternals} from '@remotion/renderer';+import {Log} from './log';++export const getFinalOutputCodec = ({+ codec: inputCodec,+ fileExtension,+ emitWarning,+}: {+ codec: CodecOrUndefined;+ fileExtension: string | null;+ emitWarning: boolean;+}): Codec => {+ if (inputCodec === undefined && fileExtension === 'webm') {+ if (emitWarning) {+ Log.info(+ 'You have specified a .webm extension, using the VP8 encoder. Use --codec=vp9 to use the Vp9 encoder.'+ );+ }++ return 'vp8';+ }++ if (inputCodec === undefined && fileExtension === 'hevc') {+ if (emitWarning) {+ Log.info('You have specified a .hevc extension, using the H265 encoder.');+ }++ return 'h265';+ }++ if (inputCodec === undefined && fileExtension === 'mp3') {+ if (emitWarning) {+ Log.info('You have specified a .mp3 extension, using the MP3 encoder.');+ }++ return 'mp3';+ }++ if (inputCodec === undefined && fileExtension === 'mov') {+ if (emitWarning) {+ Log.info(+ 'You have specified a .mov extension, using the Apple ProRes encoder.'+ );+ }++ return 'prores';+ }++ if (inputCodec === undefined && fileExtension === 'wav') {+ if (emitWarning) {+ Log.info('You have specified a .wav extension, using the WAV encoder.');+ }++ return 'wav';+ }++ if (inputCodec === undefined && fileExtension === 'aac') {+ if (emitWarning) {+ Log.info('You have specified a .aac extension, using the AAC encoder.');+ }++ return 'aac';+ }++ if (inputCodec === undefined && fileExtension === 'm4a') {+ if (emitWarning) {+ Log.info('You have specified a .m4a extension, using the AAC encoder.');+ }++ return 'aac';+ }++ if (inputCodec === undefined && fileExtension === 'mkv') {+ if (emitWarning) {+ Log.info(+ 'You have specified a .mkv extension, using the H264 encoder and WAV audio format.'+ );+ }++ return 'h264-mkv';+ }++ if (inputCodec === undefined && fileExtension === 'gif') {+ if (emitWarning) {+ Log.info('You have specified a .gif extension, rendering a GIF');+ }++ return 'gif';+ }++ return inputCodec ?? RenderInternals.DEFAULT_CODEC;+};diff --git a/packages/cli/src/image-formats.ts b/packages/cli/src/image-formats.tsindex fc607d12d8..4da99f7f77 100644--- a/packages/cli/src/image-formats.ts+++ b/packages/cli/src/image-formats.ts@@ -1,16 +1,17 @@-import type {ImageFormat} from 'remotion';-import { Internals} from 'remotion';+import {ConfigInternals} from '@remotion/config';+import type {ImageFormat} from '@remotion/renderer';+import {RenderInternals} from '@remotion/renderer';export const getImageFormat = (- codec: ReturnType<typeof Internals.getOutputCodecOrUndefined>+ codec: ReturnType<typeof ConfigInternals.getOutputCodecOrUndefined>): ImageFormat => {- const userPreferred = Internals.getUserPreferredImageFormat();+ const userPreferred = ConfigInternals.getUserPreferredImageFormat();if (typeof userPreferred !== 'undefined') {return userPreferred;}- if (Internals.isAudioCodec(codec)) {+ if (RenderInternals.isAudioCodec(codec)) {return 'none';}diff --git a/packages/cli/src/log.ts b/packages/cli/src/log.tsindex f7fbfcc11e..5e96dbf752 100644--- a/packages/cli/src/log.ts+++ b/packages/cli/src/log.ts@@ -1,13 +1,13 @@/* eslint-disable no-console */-import {Internals} from 'remotion';+import {ConfigInternals} from '@remotion/config';import {chalk} from './chalk';export const Log = {verbose: (...args: Parameters<typeof console.log>) => {if (- Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'verbose')) {@@ -16,8 +16,8 @@ export const Log = {},info: (...args: Parameters<typeof console.log>) => {if (- Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'info')) {@@ -26,8 +26,8 @@ export const Log = {},warn: (...args: Parameters<typeof console.log>) => {if (- Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'warn')) {@@ -36,8 +36,8 @@ export const Log = {},error: (...args: Parameters<typeof console.log>) => {if (- Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'error')) {diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.tsindex 39c209ed4c..1f709d3f3e 100644--- a/packages/cli/src/parse-command-line.ts+++ b/packages/cli/src/parse-command-line.ts@@ -1,16 +1,17 @@-import minimist from 'minimist';-import {resolve} from 'path';+import type {LogLevel} from '@remotion/config';+import {Config, ConfigInternals} from '@remotion/config';import type {BrowserExecutable,Codec,FfmpegExecutable,ImageFormat,- LogLevel,OpenGlRenderer,PixelFormat,ProResProfile,-} from 'remotion';-import {Config, Internals} from 'remotion';+} from '@remotion/renderer';+import minimist from 'minimist';+import {resolve} from 'path';+import type {} from 'remotion';import {Log} from './log';export type CommandLineOptions = {@@ -120,17 +121,17 @@ export const parseCommandLine = (}if (parsedCli.log) {- if (!Internals.Logging.isValidLogLevel(parsedCli.log)) {+ if (!ConfigInternals.Logging.isValidLogLevel(parsedCli.log)) {Log.error('Invalid `--log` value passed.');Log.error(- `Accepted values: ${Internals.Logging.logLevels+ `Accepted values: ${ConfigInternals.Logging.logLevels.map((l) => `'${l}'`).join(', ')}.`);process.exit(1);}- Internals.Logging.setLogLevel(parsedCli.log as LogLevel);+ ConfigInternals.Logging.setLogLevel(parsedCli.log as LogLevel);}if (parsedCli.concurrency) {@@ -149,7 +150,7 @@ export const parseCommandLine = (process.exit(1);}- Internals.setFrameRangeFromCli(parsedCli.frames);+ ConfigInternals.setFrameRangeFromCli(parsedCli.frames);}if (parsedCli.frame) {@@ -160,7 +161,7 @@ export const parseCommandLine = (process.exit(1);}- Internals.setStillFrame(Number(parsedCli.frame));+ ConfigInternals.setStillFrame(Number(parsedCli.frame));}if (parsedCli.png) {diff --git a/packages/cli/src/preview-server/start-server.ts b/packages/cli/src/preview-server/start-server.tsindex f75fd684e7..d7a3089347 100644--- a/packages/cli/src/preview-server/start-server.ts+++ b/packages/cli/src/preview-server/start-server.ts@@ -1,4 +1,5 @@import {BundlerInternals, webpack} from '@remotion/bundler';+import {ConfigInternals} from '@remotion/config';import {RenderInternals} from '@remotion/renderer';import crypto from 'crypto';import fs from 'fs';@@ -6,7 +7,6 @@ import http from 'http';import os from 'os';import path from 'path';import type {WebpackOverrideFn} from 'remotion';-import {Internals} from 'remotion';import {wdm} from './dev-middleware';import {webpackHotMiddleware} from './hot-middleware';import type {LiveEventsServer} from './live-events';@@ -37,7 +37,7 @@ export const startServer = async (outDir: tmpDir,environment: 'development',webpackOverride:- options?.webpackOverride ?? Internals.getWebpackOverrideFn(),+ options?.webpackOverride ?? ConfigInternals.getWebpackOverrideFn(),envVariables: options?.envVariables ?? {},maxTimelineTracks: options?.maxTimelineTracks ?? 15,entryPoints: [diff --git a/packages/cli/src/preview.ts b/packages/cli/src/preview.tsindex a7f227c853..a7f3cf1da1 100644--- a/packages/cli/src/preview.ts+++ b/packages/cli/src/preview.ts@@ -1,6 +1,6 @@+import {ConfigInternals} from '@remotion/config';import betterOpn from 'better-opn';import path from 'path';-import {Internals} from 'remotion';import {getEnvironmentVariables} from './get-env';import {getInputProps} from './get-input-props';import {initializeRenderCli} from './initialize-render-cli';@@ -69,7 +69,7 @@ export const previewCommand = async () => {getCurrentInputProps: () => inputProps,envVariables,port: desiredPort,- maxTimelineTracks: Internals.getMaxTimelineTracks(),+ maxTimelineTracks: ConfigInternals.getMaxTimelineTracks(),});diff --git a/packages/cli/src/progress-bar.ts b/packages/cli/src/progress-bar.tsindex 40de1e50ad..a318287489 100644--- a/packages/cli/src/progress-bar.ts+++ b/packages/cli/src/progress-bar.ts@@ -1,6 +1,6 @@-import type {StitchingState} from '@remotion/renderer';+import {ConfigInternals} from '@remotion/config';+import type {Codec, StitchingState} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';-import type {Codec} from 'remotion';import {Internals} from 'remotion';import {AnsiDiff} from './ansi/ansi-diff';import {chalk} from './chalk';@@ -14,8 +14,8 @@ export const createProgressBar = (update: (str: string) => boolean;} => {if (- !Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ !ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'info')) {diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsxindex 483bb7cefd..b4293e82c5 100644--- a/packages/cli/src/render.tsx+++ b/packages/cli/src/render.tsx@@ -1,3 +1,4 @@+import {ConfigInternals} from '@remotion/config';import type {RenderMediaOnDownload, StitchingState} from '@remotion/renderer';import {getCompositions,@@ -103,8 +104,8 @@ export const render = async () => {const browserInstance = openBrowser(browser, {browserExecutable,- shouldDumpIo: Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ shouldDumpIo: ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'verbose'),chromiumOptions,@@ -146,7 +147,7 @@ export const render = async () => {inputProps,puppeteerInstance,envVariables,- timeoutInMilliseconds: Internals.getCurrentPuppeteerTimeout(),+ timeoutInMilliseconds: ConfigInternals.getCurrentPuppeteerTimeout(),chromiumOptions,browserExecutable,});@@ -248,8 +249,8 @@ export const render = async () => {},outputDir,serveUrl: urlOrBundle,- dumpBrowserLogs: Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ dumpBrowserLogs: ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'verbose'),everyNthFrame,@@ -302,16 +303,20 @@ export const render = async () => {quality,serveUrl: urlOrBundle,onDownload,- dumpBrowserLogs: Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ dumpBrowserLogs: ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'verbose'),chromiumOptions,- timeoutInMilliseconds: Internals.getCurrentPuppeteerTimeout(),+ timeoutInMilliseconds: ConfigInternals.getCurrentPuppeteerTimeout(),scale,port,numberOfGifLoops,everyNthFrame,+ verbose: ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),+ 'verbose'+ ),});Log.info();@@ -341,8 +346,8 @@ export const render = async () => {);if (- Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'verbose')) {diff --git a/packages/cli/src/setup-cache.ts b/packages/cli/src/setup-cache.tsindex 5885f257f7..687876954e 100644--- a/packages/cli/src/setup-cache.ts+++ b/packages/cli/src/setup-cache.ts@@ -1,5 +1,5 @@import {bundle, BundlerInternals} from '@remotion/bundler';-import {Internals} from 'remotion';+import {ConfigInternals} from '@remotion/config';import {Log} from './log';import {quietFlagProvided} from './parse-command-line';import {@@ -15,7 +15,7 @@ export const bundleOnCli = async ({fullPath: string;steps: RenderStep[];}) => {- const shouldCache = Internals.getWebpackCaching();+ const shouldCache = ConfigInternals.getWebpackCaching();const onProgress = (progress: number) => {bundlingProgress.update(@@ -29,8 +29,7 @@ export const bundleOnCli = async ({const options = {enableCaching: shouldCache,- webpackOverride:- Internals.getWebpackOverrideFn() ?? Internals.defaultOverrideFunction,+ webpackOverride: ConfigInternals.getWebpackOverrideFn() ?? ((f) => f),};const [hash] = BundlerInternals.getConfig('', fullPath, onProgress, options);diff --git a/packages/cli/src/still.ts b/packages/cli/src/still.tsindex 4f3cc4d64f..b6f0be4d94 100644--- a/packages/cli/src/still.ts+++ b/packages/cli/src/still.ts@@ -1,3 +1,4 @@+import {Config, ConfigInternals} from '@remotion/config';import type {RenderMediaOnDownload} from '@remotion/renderer';import {getCompositions,@@ -7,7 +8,7 @@ import {} from '@remotion/renderer';import {mkdirSync} from 'fs';import path from 'path';-import {Config, Internals} from 'remotion';+import {Internals} from 'remotion';import {chalk} from './chalk';import {getAndValidateAbsoluteOutputFile,@@ -122,9 +123,8 @@ export const still = async () => {const browserInstance = openBrowser(browser, {browserExecutable,chromiumOptions,-- shouldDumpIo: Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ shouldDumpIo: ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'verbose'),forceDeviceScaleFactor: scale,@@ -210,15 +210,15 @@ export const still = async () => {output: absoluteOutputLocation,serveUrl: await urlOrBundle,quality,- dumpBrowserLogs: Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ dumpBrowserLogs: ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'verbose'),envVariables,imageFormat,inputProps,chromiumOptions,- timeoutInMilliseconds: Internals.getCurrentPuppeteerTimeout(),+ timeoutInMilliseconds: ConfigInternals.getCurrentPuppeteerTimeout(),scale,ffmpegExecutable,browserExecutable,diff --git a/packages/cli/src/test/final-output-codec.test.ts b/packages/cli/src/test/final-output-codec.test.tsnew file mode 100644index 0000000000..07a564d32f--- /dev/null+++ b/packages/cli/src/test/final-output-codec.test.ts@@ -0,0 +1,69 @@+import type {CodecOrUndefined} from '@remotion/renderer';+import {describe, expect, test} from 'vitest';+import {getFinalOutputCodec} from '../get-final-output-codec';++describe('Codec tests valid codec input', () => {+ const validCodecInput: CodecOrUndefined[] = [+ 'h264',+ 'h265',+ 'vp8',+ 'vp9',+ 'mp3',+ 'aac',+ 'wav',+ 'h264-mkv',+ ];+ validCodecInput.forEach((entry) =>+ test(`codec ${entry}`, () =>+ expect(+ getFinalOutputCodec({+ codec: entry,+ emitWarning: false,+ fileExtension: '',+ })+ ).toEqual(entry))+ );+});++describe('Codec tests undefined codec input with known extension', () => {+ const codecExtensionCombination: [string, string][] = [+ ['vp8', 'webm'],+ ['h265', 'hevc'],+ ['mp3', 'mp3'],+ ['wav', 'wav'],+ ['aac', 'aac'],+ ['aac', 'm4a'],+ ];+ const inputCodecs: CodecOrUndefined[] = ['h264', undefined];+ inputCodecs.forEach((codec) =>+ codecExtensionCombination.forEach((entry) =>+ test(+ codec+ ? `should not look for extension ${entry[1]}`+ : `${entry[1]} should be recognized as ${entry[0]}`,+ () =>+ expect(+ getFinalOutputCodec({+ codec,+ emitWarning: false,+ fileExtension: entry[1],+ })+ ).toEqual(codec ?? entry[0])+ )+ )+ );+});++describe('Codec tests undefined codec input with unknown extension', () => {+ const unknownExtensions = ['', 'abc'];+ unknownExtensions.forEach((entry) =>+ test(`testing with "${entry}" as extension`, () =>+ expect(+ getFinalOutputCodec({+ codec: undefined,+ emitWarning: false,+ fileExtension: entry,+ })+ ).toEqual('h264'))+ );+});diff --git a/packages/cli/src/upgrade.ts b/packages/cli/src/upgrade.tsindex 29e7924412..99867178c5 100644--- a/packages/cli/src/upgrade.ts+++ b/packages/cli/src/upgrade.ts@@ -1,7 +1,7 @@+import {ConfigInternals} from '@remotion/config';import {RenderInternals} from '@remotion/renderer';import fs from 'fs';import path from 'path';-import {Internals} from 'remotion';import {getLatestRemotionVersion} from './get-latest-remotion-version';import {Log} from './log';import type {PackageManager} from './preview-server/get-package-manager';@@ -80,8 +80,8 @@ export const upgrade = async () => {});if (- Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'info')) {diff --git a/packages/cli/src/user-passed-output-location.ts b/packages/cli/src/user-passed-output-location.tsindex 6b10fb2540..4dc41853ec 100644--- a/packages/cli/src/user-passed-output-location.ts+++ b/packages/cli/src/user-passed-output-location.ts@@ -1,10 +1,10 @@-import {Internals} from 'remotion';+import {ConfigInternals} from '@remotion/config';import {parsedCli} from './parse-command-line';export const getUserPassedOutputLocation = () => {const filename = parsedCli._[3]? parsedCli._[3]- : Internals.getOutputLocation();+ : ConfigInternals.getOutputLocation();return filename;};diff --git a/packages/cli/src/versions.ts b/packages/cli/src/versions.tsindex 05c7646f2a..15879bde5b 100644--- a/packages/cli/src/versions.ts+++ b/packages/cli/src/versions.ts@@ -1,5 +1,5 @@+import {ConfigInternals} from '@remotion/config';import fs from 'fs';-import {Internals} from 'remotion';import {Log} from './log';import {parseCommandLine} from './parse-command-line';import {resolveFrom} from './resolve-from';@@ -88,8 +88,8 @@ export const validateVersionsBeforeCommand = async () => {'- Remove the `^` character in front of a version to pin a package.');if (- !Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ !ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'verbose')) {@@ -135,8 +135,8 @@ export const versionsCommand = async () => {'- Remove the `^` character in front of a version to pin a package.');if (- !Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),+ !ConfigInternals.Logging.isEqualOrBelowLogLevel(+ ConfigInternals.Logging.getLogLevel(),'verbose')) {diff --git a/packages/config/.eslintrc b/packages/config/.eslintrcnew file mode 100644index 0000000000..d4cc0fb226--- /dev/null+++ b/packages/config/.eslintrc@@ -0,0 +1,3 @@+{+ "extends": "@jonny"+}diff --git a/packages/config/package.json b/packages/config/package.jsonindex f4e23dd2fd..cea0c3dcc9 100644--- a/packages/config/package.json+++ b/packages/config/package.json@@ -1,49 +1,49 @@{- "name": "@remotion/config",- "version": "3.1.4",- "description": "Schema for remotion.config.ts",- "main": "dist/index.js",- "types": "dist/index.d.ts",- "sideEffects": false,- "scripts": {- "lint": "eslint src --ext ts,tsx",- "test": "vitest --run",- "build": "tsc -d",- "watch": "tsc -w"- },- "repository": {- "url": "https://github.com/remotion-dev/remotion"- },- "bugs": {- "url": "https://github.com/remotion-dev/remotion/issues"- },- "author": "",- "license": "SEE LICENSE IN LICENSE.md",- "peerDependencies": {},- "dependencies": {- "@remotion/renderer": "^3.0.14"- },- "devDependencies": {- "@jonny/eslint-config": "3.0.266",- "@types/node": "^16.7.5",- "@types/webpack-env": "^1.16.0",- "@vitejs/plugin-react": "^2.0.0",- "eslint": "8.13.0",- "prettier": "^2.0.5",- "prettier-plugin-organize-imports": "^2.3.4",- "typescript": "^4.7.0",- "vitest": "^0.18.0",- "webpack": "5.72.0"- },- "keywords": [- "remotion",- "ffmpeg",- "video",- "react",- "puppeteer",- "player"- ],- "publishConfig": {- "access": "public"- }+ "name": "@remotion/config",+ "version": "3.1.5",+ "description": "Schema for remotion.config.ts",+ "main": "dist/index.js",+ "types": "dist/index.d.ts",+ "sideEffects": false,+ "scripts": {+ "lint": "eslint src --ext ts,tsx",+ "test": "vitest --run",+ "build": "tsc -d",+ "watch": "tsc -w"+ },+ "repository": {+ "url": "https://github.com/remotion-dev/remotion"+ },+ "bugs": {+ "url": "https://github.com/remotion-dev/remotion/issues"+ },+ "author": "",+ "license": "SEE LICENSE IN LICENSE.md",+ "peerDependencies": {},+ "dependencies": {+ "@remotion/renderer": "^3.0.14"+ },+ "devDependencies": {+ "@jonny/eslint-config": "3.0.266",+ "@types/node": "^16.7.5",+ "@types/webpack-env": "^1.16.0",+ "@vitejs/plugin-react": "^2.0.0",+ "eslint": "8.13.0",+ "prettier": "^2.0.5",+ "prettier-plugin-organize-imports": "^2.3.4",+ "typescript": "^4.7.0",+ "vitest": "^0.18.0",+ "webpack": "5.72.0"+ },+ "keywords": [+ "remotion",+ "ffmpeg",+ "video",+ "react",+ "puppeteer",+ "player"+ ],+ "publishConfig": {+ "access": "public"+ }}diff --git a/packages/config/src/config/crf.ts b/packages/config/src/config/crf.tsindex 8bc0fe9725..2ec3cae7ef 100644--- a/packages/config/src/config/crf.ts+++ b/packages/config/src/config/crf.ts@@ -1,4 +1,5 @@-import {Codec, Crf, RenderInternals} from '@remotion/renderer';+import type {Codec, Crf} from '@remotion/renderer';+import {RenderInternals} from '@remotion/renderer';let currentCrf: Crf;diff --git a/packages/config/src/config/frame-range.ts b/packages/config/src/config/frame-range.tsindex 0e74b68fa9..d9c3b7083c 100644--- a/packages/config/src/config/frame-range.ts+++ b/packages/config/src/config/frame-range.ts@@ -1,4 +1,5 @@-import {FrameRange, RenderInternals} from '@remotion/renderer';+import type {FrameRange} from '@remotion/renderer';+import {RenderInternals} from '@remotion/renderer';let range: FrameRange | null = null;diff --git a/packages/config/src/config/index.ts b/packages/config/src/config/index.tsindex 72cae246e3..f8c381252b 100644--- a/packages/config/src/config/index.ts+++ b/packages/config/src/config/index.ts@@ -15,7 +15,6 @@ import {setFfmpegExecutable, setFfprobeExecutable} from './ffmpeg-executable';import {setFrameRange} from './frame-range';import {setImageFormat} from './image-format';import {setImageSequence} from './image-sequence';-import type {LogLevel} from './log';import {setLogLevel} from './log';import {setMaxTimelineTracks} from './max-timeline-tracks';import {setNumberOfGifLoops} from './number-of-gif-loops';@@ -204,4 +203,4 @@ export const Config = {},} as const;-export type {Concurrency, WebpackConfiguration, WebpackOverrideFn, LogLevel};+export type {Concurrency, WebpackConfiguration, WebpackOverrideFn};diff --git a/packages/config/src/config/log.ts b/packages/config/src/config/log.tsindex df311d8eae..3bf5b1efd1 100644--- a/packages/config/src/config/log.ts+++ b/packages/config/src/config/log.ts@@ -1,10 +1,6 @@-export const logLevels = ['verbose', 'info', 'warn', 'error'] as const;+import type {LogLevel} from '@remotion/renderer';-export type LogLevel = typeof logLevels[number];--export const DEFAULT_LOG_LEVEL: LogLevel = 'info';--let logLevel: LogLevel = DEFAULT_LOG_LEVEL;+let logLevel: LogLevel = 'info';export const getLogLevel = () => {return logLevel;@@ -13,18 +9,3 @@ export const getLogLevel = () => {export const setLogLevel = (newLogLevel: LogLevel) => {logLevel = newLogLevel;};--const getNumberForLogLevel = (level: LogLevel) => {- return logLevels.indexOf(level);-};--export const isValidLogLevel = (level: string) => {- return getNumberForLogLevel(level as LogLevel) > -1;-};--export const isEqualOrBelowLogLevel = (- currentLevel: LogLevel,- level: LogLevel-) => {- return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);-};diff --git a/packages/config/src/index.ts b/packages/config/src/index.tsindex e69de29bb2..0fc57b1aec 100644--- a/packages/config/src/index.ts+++ b/packages/config/src/index.ts@@ -0,0 +1,75 @@+import {getBrowser} from './config/browser';+import {getBrowserExecutable} from './config/browser-executable';+import {+ getChromiumDisableWebSecurity,+ getChromiumHeadlessMode,+ getChromiumOpenGlRenderer,+ getIgnoreCertificateErrors,+} from './config/chromium-flags';+import {getOutputCodecOrUndefined} from './config/codec';+import {getConcurrency} from './config/concurrency';+import {getActualCrf} from './config/crf';+import {getDotEnvLocation} from './config/env-file';+import {getAndValidateEveryNthFrame} from './config/every-nth-frame';+import {+ getCustomFfmpegExecutable,+ getCustomFfprobeExecutable,+} from './config/ffmpeg-executable';+import {getRange, setFrameRangeFromCli} from './config/frame-range';+import {getUserPreferredImageFormat} from './config/image-format';+import {getShouldOutputImageSequence} from './config/image-sequence';+import * as Logging from './config/log';+import {getMaxTimelineTracks} from './config/max-timeline-tracks';+import {getAndValidateNumberOfGifLoops} from './config/number-of-gif-loops';+import {getOutputLocation} from './config/output-location';+import {+ defaultOverrideFunction,+ getWebpackOverrideFn,+} from './config/override-webpack';+import {getShouldOverwrite} from './config/overwrite';+import {getPixelFormat} from './config/pixel-format';+import {getServerPort} from './config/preview-server';+import {getProResProfile} from './config/prores-profile';+import {getQuality} from './config/quality';+import {getScale} from './config/scale';+import {getStillFrame, setStillFrame} from './config/still-frame';+import {getCurrentPuppeteerTimeout} from './config/timeout';+import {getWebpackCaching} from './config/webpack-caching';++export {Config} from './config';++export const ConfigInternals = {+ getRange,+ getOutputCodecOrUndefined,+ getCustomFfmpegExecutable,+ getBrowser,+ getActualCrf,+ getPixelFormat,+ getProResProfile,+ getShouldOverwrite,+ getBrowserExecutable,+ getCustomFfprobeExecutable,+ getScale,+ getServerPort,+ getChromiumDisableWebSecurity,+ getIgnoreCertificateErrors,+ getChromiumHeadlessMode,+ getChromiumOpenGlRenderer,+ getAndValidateEveryNthFrame,+ getAndValidateNumberOfGifLoops,+ getConcurrency,+ getCurrentPuppeteerTimeout,+ getQuality,+ getStillFrame,+ getShouldOutputImageSequence,+ getDotEnvLocation,+ getUserPreferredImageFormat,+ getWebpackOverrideFn,+ getWebpackCaching,+ getOutputLocation,+ Logging,+ setFrameRangeFromCli,+ setStillFrame,+ getMaxTimelineTracks,+ defaultOverrideFunction,+};diff --git a/packages/config/src/test/codec.test.ts b/packages/config/src/test/codec.test.tsindex 8135d6ccdf..fd4e1e716e 100644--- a/packages/config/src/test/codec.test.ts+++ b/packages/config/src/test/codec.test.ts@@ -1,76 +1,8 @@-import {CodecOrUndefined, RenderInternals} from '@remotion/renderer';+import type {CodecOrUndefined} from '@remotion/renderer';import {describe, expect, test} from 'vitest';import {getOutputCodecOrUndefined, setCodec} from '../config/codec';import {expectToThrow} from './expect-to-throw';-// getFinalOutputCodec--describe('Codec tests valid codec input', () => {- const validCodecInput: CodecOrUndefined[] = [- 'h264',- 'h265',- 'vp8',- 'vp9',- 'mp3',- 'aac',- 'wav',- 'h264-mkv',- ];- validCodecInput.forEach((entry) =>- test(`codec ${entry}`, () =>- expect(- RenderInternals.getFinalOutputCodec({- codec: entry,- emitWarning: false,- fileExtension: '',- })- ).toEqual(entry))- );-});--describe('Codec tests undefined codec input with known extension', () => {- const codecExtensionCombination: [string, string][] = [- ['vp8', 'webm'],- ['h265', 'hevc'],- ['mp3', 'mp3'],- ['wav', 'wav'],- ['aac', 'aac'],- ['aac', 'm4a'],- ];- const inputCodecs: CodecOrUndefined[] = ['h264', undefined];- inputCodecs.forEach((codec) =>- codecExtensionCombination.forEach((entry) =>- test(- codec- ? `should not look for extension ${entry[1]}`- : `${entry[1]} should be recognized as ${entry[0]}`,- () =>- expect(- RenderInternals.getFinalOutputCodec({- codec,- emitWarning: false,- fileExtension: entry[1],- })- ).toEqual(codec ?? entry[0])- )- )- );-});--describe('Codec tests undefined codec input with unknown extension', () => {- const unknownExtensions = ['', 'abc'];- unknownExtensions.forEach((entry) =>- test(`testing with "${entry}" as extension`, () =>- expect(- RenderInternals.getFinalOutputCodec({- codec: undefined,- emitWarning: false,- fileExtension: entry,- })- ).toEqual('h264'))- );-});-// setCodecdescribe('Codec tests setOutputFormat', () => {diff --git a/packages/lambda/package.json b/packages/lambda/package.jsonindex d892d0896b..0379105efe 100644--- a/packages/lambda/package.json+++ b/packages/lambda/package.json@@ -33,6 +33,7 @@"@aws-sdk/s3-request-presigner": "3.58.0","@remotion/bundler": "3.1.5","@remotion/cli": "3.1.5",+ "@remotion/config": "3.1.5","@remotion/renderer": "3.1.5","aws-policies": "^1.0.1","mime-types": "2.1.34",diff --git a/packages/lambda/src/api/deploy-site.ts b/packages/lambda/src/api/deploy-site.tsindex 37db67048a..db49e7e500 100644--- a/packages/lambda/src/api/deploy-site.ts+++ b/packages/lambda/src/api/deploy-site.ts@@ -1,5 +1,4 @@-import type { WebpackOverrideFn} from 'remotion';-import {Internals} from 'remotion';+import type {WebpackOverrideFn} from 'remotion';import {deleteSite} from '../api/delete-site';import type {AwsRegion} from '../pricing/aws-regions';import {bundleSite} from '../shared/bundle-site';@@ -12,7 +11,7 @@ import {validateBucketName} from '../shared/validate-bucketname';import {validateSiteName} from '../shared/validate-site-name';import {bucketExistsInRegion} from './bucket-exists';import {enableS3Website} from './enable-s3-website';-import type { UploadDirProgress} from './upload-dir';+import type {UploadDirProgress} from './upload-dir';import {uploadDir} from './upload-dir';export type DeploySiteInput = {@@ -76,9 +75,8 @@ export const deploySite = async ({options?.onBundleProgress ?? (() => undefined),{publicPath: `/${subFolder}/`,- webpackOverride:- options?.webpackOverride ?? Internals.getWebpackOverrideFn(),- enableCaching: options?.enableCaching ?? Internals.getWebpackCaching(),+ webpackOverride: options?.webpackOverride ?? ((f) => f),+ enableCaching: options?.enableCaching ?? true,});diff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda/src/api/render-media-on-lambda.tsindex c2e58b6959..1a530b8eee 100644--- a/packages/lambda/src/api/render-media-on-lambda.ts+++ b/packages/lambda/src/api/render-media-on-lambda.ts@@ -1,12 +1,11 @@-import type {ChromiumOptions} from '@remotion/renderer';import type {+ ChromiumOptions,FrameRange,ImageFormat,LogLevel,PixelFormat,ProResProfile,-} from 'remotion';-import {Internals} from 'remotion';+} from '@remotion/renderer';import type {AwsRegion} from '../pricing/aws-regions';import {callLambda} from '../shared/call-lambda';import type {OutNameInput, Privacy} from '../shared/constants';@@ -120,11 +119,10 @@ export const renderMediaOnLambda = async ({quality,maxRetries,privacy,- logLevel: logLevel ?? Internals.Logging.DEFAULT_LOG_LEVEL,+ logLevel: logLevel ?? 'info',frameRange: frameRange ?? null,outName: outName ?? null,- timeoutInMilliseconds:- timeoutInMilliseconds ?? Internals.DEFAULT_PUPPETEER_TIMEOUT,+ timeoutInMilliseconds: timeoutInMilliseconds ?? 30000,chromiumOptions: chromiumOptions ?? {},scale: scale ?? 1,everyNthFrame: everyNthFrame ?? 1,diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.tsindex 4b3ea77ed8..a1457df628 100644--- a/packages/lambda/src/api/render-still-on-lambda.ts+++ b/packages/lambda/src/api/render-still-on-lambda.ts@@ -1,6 +1,8 @@-import type {ChromiumOptions} from '@remotion/renderer';-import type {LogLevel, StillImageFormat} from 'remotion';-import {Internals} from 'remotion';+import type {+ ChromiumOptions,+ LogLevel,+ StillImageFormat,+} from '@remotion/renderer';import type {AwsRegion} from '../pricing/aws-regions';import {callLambda} from '../shared/call-lambda';import type {CostsInfo, OutNameInput} from '../shared/constants';@@ -87,10 +89,9 @@ export const renderStillOnLambda = async ({frame: frame ?? 0,privacy,attempt: 1,- logLevel: logLevel ?? Internals.Logging.DEFAULT_LOG_LEVEL,+ logLevel: logLevel ?? 'info',outName: outName ?? null,- timeoutInMilliseconds:- timeoutInMilliseconds ?? Internals.DEFAULT_PUPPETEER_TIMEOUT,+ timeoutInMilliseconds: timeoutInMilliseconds ?? 30000,chromiumOptions: chromiumOptions ?? {},scale: scale ?? 1,downloadBehavior: downloadBehavior ?? {type: 'play-in-browser'},diff --git a/packages/lambda/src/cli/commands/sites/create.ts b/packages/lambda/src/cli/commands/sites/create.tsindex 77b67a6808..837f86e9be 100644--- a/packages/lambda/src/cli/commands/sites/create.ts+++ b/packages/lambda/src/cli/commands/sites/create.ts@@ -1,7 +1,7 @@import {CliInternals} from '@remotion/cli';+import {ConfigInternals} from '@remotion/config';import {existsSync, lstatSync} from 'fs';import path from 'path';-import {Internals} from 'remotion';import {deploySite} from '../../../api/deploy-site';import {getOrCreateBucket} from '../../../api/get-or-create-bucket';import {BINARY_NAME} from '../../../shared/constants';@@ -11,7 +11,8 @@ import {getAwsRegion} from '../../get-aws-region';import type {BucketCreationProgress,BundleProgress,- DeployToS3Progress} from '../../helpers/progress-bar';+ DeployToS3Progress,+} from '../../helpers/progress-bar';import {makeBucketProgress,makeBundleProgress,@@ -110,7 +111,6 @@ export const sitesCreateSubcommand = async (args: string[]) => {entryPoint: absoluteFile,siteName: desiredSiteName,bucketName,-options: {onBundleProgress: (progress: number) => {multiProgress.bundleProgress = {@@ -126,9 +126,8 @@ export const sitesCreateSubcommand = async (args: string[]) => {};updateProgress();},- enableCaching: Internals.getWebpackCaching(),- webpackOverride:- Internals.getWebpackOverrideFn() ?? Internals.defaultOverrideFunction,+ enableCaching: ConfigInternals.getWebpackCaching(),+ webpackOverride: ConfigInternals.getWebpackOverrideFn() ?? ((f) => f),},region: getAwsRegion(),});diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.tsindex 84405ac5c7..e8de0bbded 100644--- a/packages/lambda/src/cli/commands/still.ts+++ b/packages/lambda/src/cli/commands/still.ts@@ -1,6 +1,6 @@import {CliInternals} from '@remotion/cli';+import type {StillImageFormat} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';-import type {StillImageFormat} from 'remotion';import {downloadMedia} from '../../api/download-media';import {renderStillOnLambda} from '../../api/render-still-on-lambda';import {diff --git a/packages/lambda/src/functions/helpers/concat-videos.ts b/packages/lambda/src/functions/helpers/concat-videos.tsindex f6af63df71..c31c0c6491 100644--- a/packages/lambda/src/functions/helpers/concat-videos.ts+++ b/packages/lambda/src/functions/helpers/concat-videos.ts@@ -1,3 +1,4 @@+import type {Codec} from '@remotion/renderer';import {combineVideos, RenderInternals} from '@remotion/renderer';import fs, {createWriteStream,@@ -8,7 +9,6 @@ import fs, {rmSync,} from 'fs';import path, {join} from 'path';-import type {Codec} from 'remotion';import type {AwsRegion} from '../../pricing/aws-regions';import {chunkKey,diff --git a/packages/lambda/src/functions/helpers/expected-out-name.ts b/packages/lambda/src/functions/helpers/expected-out-name.tsindex 065028d4e1..b44a0b1e81 100644--- a/packages/lambda/src/functions/helpers/expected-out-name.ts+++ b/packages/lambda/src/functions/helpers/expected-out-name.ts@@ -1,13 +1,7 @@+import type {Codec} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';-import type {Codec} from 'remotion';-import type {- OutNameOutput,- RenderMetadata} from '../../defaults';-import {- customOutName,- outName,- outStillName-} from '../../defaults';+import type {OutNameOutput, RenderMetadata} from '../../defaults';+import {customOutName, outName, outStillName} from '../../defaults';import {validateOutname} from '../../shared/validate-outname';export const getExpectedOutName = (diff --git a/packages/lambda/src/functions/helpers/validate-composition.ts b/packages/lambda/src/functions/helpers/validate-composition.tsindex c12c49f31e..93fff628c9 100644--- a/packages/lambda/src/functions/helpers/validate-composition.ts+++ b/packages/lambda/src/functions/helpers/validate-composition.ts@@ -1,10 +1,10 @@import type {ChromiumOptions,- openBrowser} from '@remotion/renderer';-import {- getCompositions+ FfmpegExecutable,+ openBrowser,} from '@remotion/renderer';-import type {FfmpegExecutable, TCompMetadata} from 'remotion';+import {getCompositions} from '@remotion/renderer';+import type {TCompMetadata} from 'remotion';import type {Await} from '../../shared/await';type ValidateCompositionOptions = {diff --git a/packages/lambda/src/functions/index.ts b/packages/lambda/src/functions/index.tsindex 806b18948d..3e9bad4353 100644--- a/packages/lambda/src/functions/index.ts+++ b/packages/lambda/src/functions/index.ts@@ -1,10 +1,6 @@-import {Internals} from 'remotion';-import type {- LambdaPayload} from '../shared/constants';-import {- COMMAND_NOT_FOUND,- LambdaRoutines,-} from '../shared/constants';+import {RenderInternals} from '@remotion/renderer';+import type {LambdaPayload} from '../shared/constants';+import {COMMAND_NOT_FOUND, LambdaRoutines} from '../shared/constants';import type {LambdaReturnValues} from '../shared/return-values';import {deleteTmpDir} from './helpers/clean-tmpdir';import {getWarm, setWarm} from './helpers/is-warm';@@ -73,7 +69,7 @@ export const handler = async <T extends LambdaRoutines>(renderId: params.renderId,chunk: String(params.chunk),dumpLogs: String(- Internals.Logging.isEqualOrBelowLogLevel(params.logLevel, 'verbose')+ RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose')),inputProps: JSON.stringify(params.inputProps),});diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.tsindex 33ab1b464c..1c8368f98f 100644--- a/packages/lambda/src/functions/launch.ts+++ b/packages/lambda/src/functions/launch.ts@@ -65,10 +65,7 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {const [browserInstance, optimization] = await Promise.all([getBrowserInstance(- Internals.Logging.isEqualOrBelowLogLevel(- Internals.Logging.getLogLevel(),- 'verbose'- ),+ RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose'),params.chromiumOptions),getOptimization({@@ -94,11 +91,15 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {});Internals.validateDurationInFrames(comp.durationInFrames,- 'passed to <Component />'+ 'passed to a Lambda render');- Internals.validateFps(comp.fps, 'passed to <Component />', null);- Internals.validateDimension(comp.height, 'height', 'passed to <Component />');- Internals.validateDimension(comp.width, 'width', 'passed to <Component />');+ Internals.validateFps(comp.fps, 'passed to a Lambda render', false);+ Internals.validateDimension(+ comp.height,+ 'height',+ 'passed to a Lambda render'+ );+ Internals.validateDimension(comp.width, 'width', 'passed to a Lambda render');RenderInternals.validateConcurrency(params.concurrencyPerLambda,@@ -168,7 +169,7 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {proResProfile: params.proResProfile,quality: params.quality,privacy: params.privacy,- logLevel: params.logLevel ?? Internals.Logging.DEFAULT_LOG_LEVEL,+ logLevel: params.logLevel ?? 'info',attempt: 1,timeoutInMilliseconds: params.timeoutInMilliseconds,chromiumOptions: params.chromiumOptions,diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.tsindex 8a113b0adf..1f6a09490a 100644--- a/packages/lambda/src/functions/renderer.ts+++ b/packages/lambda/src/functions/renderer.ts@@ -1,10 +1,8 @@import {InvokeCommand} from '@aws-sdk/client-lambda';-import type {BrowserLog} from '@remotion/renderer';+import type {BrowserLog, Codec} from '@remotion/renderer';import {RenderInternals, renderMedia} from '@remotion/renderer';import fs from 'fs';import path from 'path';-import type {Codec} from 'remotion';-import {Internals} from 'remotion';import {getLambdaClient} from '../shared/aws-clients';import type {LambdaPayload, LambdaPayloads} from '../shared/constants';import {@@ -43,10 +41,8 @@ const renderHandler = async (throw new Error('Params must be renderer');}- Internals.Logging.setLogLevel(params.logLevel);-const browserInstance = await getBrowserInstance(- Internals.Logging.isEqualOrBelowLogLevel(params.logLevel, 'verbose'),+ RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose'),params.chromiumOptions ?? {});@@ -94,7 +90,7 @@ const renderHandler = async (onProgress: ({renderedFrames, encodedFrames, stitchStage}) => {if (renderedFrames % 10 === 0 &&- Internals.Logging.isEqualOrBelowLogLevel(params.logLevel, 'verbose')+ RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose')) {console.log(`Rendered ${renderedFrames} frames, encoded ${encodedFrames} frames, stage = ${stitchStage}`@@ -139,10 +135,11 @@ const renderHandler = async (serveUrl: params.serveUrl,quality: params.quality,envVariables: params.envVariables,- dumpBrowserLogs: Internals.Logging.isEqualOrBelowLogLevel(+ dumpBrowserLogs: RenderInternals.isEqualOrBelowLogLevel(params.logLevel,'verbose'),+ verbose: RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose'),onBrowserLog: (log) => {logs.push(log);},diff --git a/packages/lambda/src/functions/start.ts b/packages/lambda/src/functions/start.tsindex 2db854fd75..bd34c47115 100644--- a/packages/lambda/src/functions/start.ts+++ b/packages/lambda/src/functions/start.ts@@ -1,5 +1,4 @@import {InvokeCommand} from '@aws-sdk/client-lambda';-import {Internals} from 'remotion';import {getOrCreateBucket} from '../api/get-or-create-bucket';import {getLambdaClient} from '../shared/aws-clients';import type {LambdaPayload} from '../shared/constants';@@ -34,7 +33,7 @@ export const startHandler = async (params: LambdaPayload) => {quality: params.quality,maxRetries: params.maxRetries,privacy: params.privacy,- logLevel: params.logLevel ?? Internals.Logging.DEFAULT_LOG_LEVEL,+ logLevel: params.logLevel ?? 'info',frameRange: params.frameRange,outName: params.outName,timeoutInMilliseconds: params.timeoutInMilliseconds,diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.tsindex cec2f4ec6b..f4749189e4 100644--- a/packages/lambda/src/functions/still.ts+++ b/packages/lambda/src/functions/still.ts@@ -1,9 +1,8 @@import {InvokeCommand} from '@aws-sdk/client-lambda';+import type {StillImageFormat} from '@remotion/renderer';import {RenderInternals, renderStill} from '@remotion/renderer';import fs from 'fs';import path from 'path';-import type {StillImageFormat} from 'remotion';-import {Internals} from 'remotion';import {estimatePrice} from '../api/estimate-price';import {getOrCreateBucket} from '../api/get-or-create-bucket';import {getLambdaClient} from '../shared/aws-clients';@@ -60,10 +59,7 @@ const innerStillHandler = async (region: getCurrentRegionInFunction(),}),getBrowserInstance(- Internals.Logging.isEqualOrBelowLogLevel(- lambdaParams.logLevel ?? Internals.Logging.DEFAULT_LOG_LEVEL,- 'verbose'- ),+ RenderInternals.isEqualOrBelowLogLevel(lambdaParams.logLevel, 'verbose'),lambdaParams.chromiumOptions ?? {}),]);diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.tsindex f416e3401f..a30bd26a50 100644--- a/packages/lambda/src/shared/constants.ts+++ b/packages/lambda/src/shared/constants.ts@@ -1,13 +1,13 @@-import type {ChromiumOptions} from '@remotion/renderer';import type {+ ChromiumOptions,Codec,FrameRange,ImageFormat,LogLevel,PixelFormat,ProResProfile,- VideoConfig,-} from 'remotion';+} from '@remotion/renderer';+import type {VideoConfig} from 'remotion';import type {ChunkRetry} from '../functions/helpers/get-retry-stats';import type {EnhancedErrorInfo} from '../functions/helpers/write-lambda-error';import type {AwsRegion} from '../pricing/aws-regions';diff --git a/packages/lambda/src/test/unit/handlers.test.ts b/packages/lambda/src/test/unit/handlers.test.tsindex 0fe4017455..c50dd28356 100644--- a/packages/lambda/src/test/unit/handlers.test.ts+++ b/packages/lambda/src/test/unit/handlers.test.ts@@ -1,11 +1,9 @@-import {Internals} from 'remotion';import {handler} from '../../functions/index';import type {Await} from '../../shared/await';import {LambdaRoutines} from '../../shared/constants';import type {LambdaReturnValues} from '../../shared/return-values';test('Info handler should return version', async () => {- Internals.Logging.setLogLevel('error');const response = await handler({type: LambdaRoutines.info,diff --git a/packages/renderer/src/codec.ts b/packages/renderer/src/codec.tsindex 4c4045cb8e..73c5b8a53d 100644--- a/packages/renderer/src/codec.ts+++ b/packages/renderer/src/codec.ts@@ -15,103 +15,3 @@ export type Codec = typeof validCodecs[number];export type CodecOrUndefined = Codec | undefined;export const DEFAULT_CODEC: Codec = 'h264';--export const getFinalOutputCodec = ({- codec: inputCodec,- fileExtension,- emitWarning,-}: {- codec: CodecOrUndefined;- fileExtension: string | null;- emitWarning: boolean;-}): Codec => {- if (inputCodec === undefined && fileExtension === 'webm') {- if (emitWarning) {- console.info(- 'You have specified a .webm extension, using the VP8 encoder. Use --codec=vp9 to use the Vp9 encoder.'- );- }-- return 'vp8';- }-- if (inputCodec === undefined && fileExtension === 'hevc') {- if (emitWarning) {- console.info(- 'You have specified a .hevc extension, using the H265 encoder.'- );- }-- return 'h265';- }-- if (inputCodec === undefined && fileExtension === 'mp3') {- if (emitWarning) {- console.info(- 'You have specified a .mp3 extension, using the MP3 encoder.'- );- }-- return 'mp3';- }-- if (inputCodec === undefined && fileExtension === 'mov') {- if (emitWarning) {- console.info(- 'You have specified a .mov extension, using the Apple ProRes encoder.'- );- }-- return 'prores';- }-- if (inputCodec === undefined && fileExtension === 'wav') {- if (emitWarning) {- console.info(- 'You have specified a .wav extension, using the WAV encoder.'- );- }-- return 'wav';- }-- if (inputCodec === undefined && fileExtension === 'aac') {- if (emitWarning) {- console.info(- 'You have specified a .aac extension, using the AAC encoder.'- );- }-- return 'aac';- }-- if (inputCodec === undefined && fileExtension === 'm4a') {- if (emitWarning) {- console.info(- 'You have specified a .m4a extension, using the AAC encoder.'- );- }-- return 'aac';- }-- if (inputCodec === undefined && fileExtension === 'mkv') {- if (emitWarning) {- console.info(- 'You have specified a .mkv extension, using the H264 encoder and WAV audio format.'- );- }-- return 'h264-mkv';- }-- if (inputCodec === undefined && fileExtension === 'gif') {- if (emitWarning) {- console.info('You have specified a .gif extension, rendering a GIF');- }-- return 'gif';- }-- return inputCodec ?? DEFAULT_CODEC;-};diff --git a/packages/renderer/src/index.ts b/packages/renderer/src/index.tsindex 85219216a2..a91e896bac 100644--- a/packages/renderer/src/index.ts+++ b/packages/renderer/src/index.ts@@ -3,7 +3,7 @@ import {downloadFile} from './assets/download-file';import {DEFAULT_BROWSER} from './browser';import {DEFAULT_TIMEOUT} from './browser/TimeoutSettings';import {canUseParallelEncoding} from './can-use-parallel-encoding';-import {getFinalOutputCodec, validCodecs} from './codec';+import {DEFAULT_CODEC, validCodecs} from './codec';import {getDefaultCrfForCodec,getValidCrfRanges,@@ -26,14 +26,24 @@ import {getExtensionOfFilename} from './get-extension-of-filename';import {getRealFrameRange} from './get-frame-to-render';import {ensureLocalBrowser} from './get-local-browser-executable';import {getDesiredPort} from './get-port';-import {validImageFormats} from './image-format';+import {+ validateSelectedPixelFormatAndImageFormatCombination,+ validImageFormats,+} from './image-format';+import {isAudioCodec} from './is-audio-codec';import {isServeUrl} from './is-serve-url';+import {isEqualOrBelowLogLevel, logLevels} from './log-level';import {mimeContentType, mimeLookup} from './mime-types';import {normalizeServeUrl} from './normalize-serve-url';import {killAllBrowsers} from './open-browser';import {DEFAULT_OVERWRITE} from './overwrite';import {parseStack} from './parse-browser-error-stack';-import {DEFAULT_PIXEL_FORMAT, validPixelFormats} from './pixel-format';+import {+ DEFAULT_PIXEL_FORMAT,+ validateSelectedPixelFormatAndCodecCombination,+ validPixelFormats,+} from './pixel-format';+import {validateSelectedCodecAndProResCombination} from './prores-profile';import {validateQuality} from './quality';import {isPathInside} from './serve-handler/is-path-inside';import {serveStatic} from './serve-static';@@ -65,7 +75,13 @@ export {FfmpegExecutable} from './ffmpeg-executable';export {FfmpegVersion} from './ffmpeg-flags';export {FrameRange} from './frame-range';export {getCompositions} from './get-compositions';-export {ImageFormat} from './image-format';+export {+ ImageFormat,+ StillImageFormat,+ validateSelectedPixelFormatAndImageFormatCombination,+ validImageFormats,+} from './image-format';+export type {LogLevel} from './log-level';export {CancelSignal, makeCancelSignal} from './make-cancel-signal';export {openBrowser} from './open-browser';export type {ChromiumOptions} from './open-browser';@@ -134,6 +150,12 @@ export const RenderInternals = {validateQuality,validateFrame,DEFAULT_TIMEOUT,- getFinalOutputCodec,getValidCrfRanges,+ validateSelectedPixelFormatAndCodecCombination,+ validateSelectedCodecAndProResCombination,+ validateSelectedPixelFormatAndImageFormatCombination,+ DEFAULT_CODEC,+ isAudioCodec,+ logLevels,+ isEqualOrBelowLogLevel,};diff --git a/packages/renderer/src/log-level.ts b/packages/renderer/src/log-level.tsnew file mode 100644index 0000000000..da99ce150a--- /dev/null+++ b/packages/renderer/src/log-level.ts@@ -0,0 +1,18 @@+export const logLevels = ['verbose', 'info', 'warn', 'error'] as const;++export type LogLevel = typeof logLevels[number];++const getNumberForLogLevel = (level: LogLevel) => {+ return logLevels.indexOf(level);+};++export const isValidLogLevel = (level: string) => {+ return getNumberForLogLevel(level as LogLevel) > -1;+};++export const isEqualOrBelowLogLevel = (+ currentLevel: LogLevel,+ level: LogLevel+) => {+ return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);+};diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex ef852c863c..98fe54d610 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -100,6 +100,7 @@ importers:specifiers:'@jonny/eslint-config': 3.0.266'@remotion/bundler': 3.1.5+ '@remotion/config': 3.1.5'@remotion/media-utils': 3.1.5'@remotion/player': 3.1.5'@remotion/renderer': 3.1.5@@ -130,6 +131,7 @@ importers:vitest: ^0.18.0dependencies:'@remotion/bundler': link:../bundler+ '@remotion/config': link:../config'@remotion/media-utils': link:../media-utils'@remotion/player': link:../player'@remotion/renderer': link:../renderer@@ -547,6 +549,7 @@ importers:'@jonny/eslint-config': 3.0.266'@remotion/bundler': 3.1.5'@remotion/cli': 3.1.5+ '@remotion/config': 3.1.5'@remotion/renderer': 3.1.5'@types/jest': ^27.0.2'@types/mime-types': 2.1.1@@ -575,6 +578,7 @@ importers:'@aws-sdk/s3-request-presigner': 3.58.0'@remotion/bundler': link:../bundler'@remotion/cli': link:../cli+ '@remotion/config': link:../config'@remotion/renderer': link:../rendereraws-policies: 1.0.1mime-types: 2.1.34