🎥 Make videos programmatically with React
feat: add output location support in config file
himmelio1a04fec1542b
diff --git a/packages/cli/src/user-passed-output-location.ts b/packages/cli/src/user-passed-output-location.tsindex a4bebfcf7a..58ac667878 100644--- a/packages/cli/src/user-passed-output-location.ts+++ b/packages/cli/src/user-passed-output-location.ts@@ -1,12 +1,9 @@-import {Log} from './log';+import {Internals} from 'remotion';import {parsedCli} from './parse-command-line';export const getUserPassedOutputLocation = () => {- if (!parsedCli._[3]) {- Log.error('Pass an extra argument <output-filename>.');- process.exit(1);- }-- const filename = parsedCli._[3];+ const filename = parsedCli._[3]+ ? parsedCli._[3]+ : Internals.getOutputLocation();return filename;};diff --git a/packages/core/src/config/index.ts b/packages/core/src/config/index.tsindex f1861a7ed1..b35afed713 100644--- a/packages/core/src/config/index.ts+++ b/packages/core/src/config/index.ts@@ -25,6 +25,7 @@ import type {LogLevel} from './log';import {setLogLevel} from './log';import {setMaxTimelineTracks} from './max-timeline-tracks';import {setNumberOfGifLoops} from './number-of-gif-loops';+import {setOutputLocation} from './output-location';import type {WebpackConfiguration, WebpackOverrideFn} from './override-webpack';import {overrideWebpackConfig} from './override-webpack';import {setOverwriteOutput} from './overwrite';@@ -165,6 +166,10 @@ export const Config = {setNumberOfGifLoops,},Output: {+ /**+ * Set the output file location string. Default: `out/video.mp4`+ */+ setOutputLocation,/*** If the video file already exists, should Remotion overwrite* the output? Default: truediff --git a/packages/core/src/config/output-location.ts b/packages/core/src/config/output-location.tsnew file mode 100644index 0000000000..8d413906a1--- /dev/null+++ b/packages/core/src/config/output-location.ts@@ -0,0 +1,21 @@+export const DEFAULT_OUTPUT_LOCATION = 'out/video.mp4';++let currentOutputLocation: string = DEFAULT_OUTPUT_LOCATION;++export const setOutputLocation = (newOutputLocation: string) => {+ if (typeof newOutputLocation !== 'string') {+ throw new Error(+ `outputLocation must be a string but got ${typeof newOutputLocation} (${JSON.stringify(+ newOutputLocation+ )})`+ );+ }++ if (newOutputLocation === '') {+ throw new Error(`outputLocation must not be an empty string`);+ }++ currentOutputLocation = newOutputLocation;+};++export const getOutputLocation = () => currentOutputLocation;diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.tsindex 0dc08e510b..a8c4e1e330 100644--- a/packages/core/src/internals.ts+++ b/packages/core/src/internals.ts@@ -56,6 +56,7 @@ 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 type {WebpackOverrideFn} from './config/override-webpack';import {defaultOverrideFunction,@@ -158,6 +159,7 @@ export const Internals = {getCustomFfprobeExecutable,getPixelFormat,getConcurrency,+ getOutputLocation,getRange,getShouldOverwrite,getOutputCodecOrUndefined,