Skip to content

🎥 Make videos programmatically with React

separate audio to

Jonny Burgerc7bdc2cbe4e1
diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.ts
index cb40f916ca..957d8fd255 100644
--- a/packages/cli/src/render-flows/render.ts
+++ b/packages/cli/src/render-flows/render.ts
@@ -419,7 +419,7 @@ export const renderVideoFlow = async ({
browserExecutable,
port,
composition: config,
- server: await server,
+ server,
indent,
muted,
onBrowserLog: null,
@@ -499,7 +499,7 @@ export const renderVideoFlow = async ({
onDownload,
onCtrlCExit: addCleanupCallback,
indent,
- server: await server,
+ server,
cancelSignal: cancelSignal ?? undefined,
audioCodec,
preferLossless: false,
diff --git a/packages/renderer/src/options/index.tsx b/packages/renderer/src/options/index.tsx
index 999b9979a9..e15ca02e7b 100644
--- a/packages/renderer/src/options/index.tsx
+++ b/packages/renderer/src/options/index.tsx
@@ -23,6 +23,7 @@ import {overwriteOption} from './overwrite';
import {preferLosslessAudioOption} from './prefer-lossless';
import {reproOption} from './repro';
import {scaleOption} from './scale';
+import {separateAudioOption} from './separate-audio';
import {delayRenderTimeoutInMillisecondsOption} from './timeout';
import {videoBitrateOption} from './video-bitrate';
import {videoCodecOption} from './video-codec';
@@ -59,6 +60,7 @@ export const allOptions = {
overwriteOption,
binariesDirectoryOption,
forSeamlessAacConcatenationOption,
+ separateAudioOption,
};
export type AvailableOptions = keyof typeof allOptions;
diff --git a/packages/renderer/src/options/separate-audio.tsx b/packages/renderer/src/options/separate-audio.tsx
new file mode 100644
index 0000000000..e1e8e15e0b
--- /dev/null
+++ b/packages/renderer/src/options/separate-audio.tsx
@@ -0,0 +1,50 @@
+import path from 'node:path/win32';
+import type {AnyRemotionOption} from './option';
+
+const DEFAULT = null;
+
+let separateAudioTo: string | null = null;
+
+const cliFlag = '--separate-audio-to';
+
+export const separateAudioOption = {
+ cliFlag,
+ description: () => {
+ return (
+ <>
+ If set, the audio will not be included in the main output but rendered
+ as a separate file at the location you pass. The path is relative to the
+ current working directory of the Remotion Root, or in the case of using
+ the server-side rendering APIs, relative to the current working
+ directory. It is recommended to use an absolute path.
+ </>
+ );
+ },
+ docLink: 'https://remotion.dev/docs/renderer/render-media',
+ getValue: ({commandLine}, remotionRoot: string) => {
+ if (commandLine[cliFlag]) {
+ return {
+ source: 'cli',
+ value: path.resolve(commandLine[cliFlag] as string, remotionRoot),
+ };
+ }
+
+ if (separateAudioTo !== DEFAULT) {
+ return {
+ source: 'config',
+ value: path.resolve(separateAudioTo, remotionRoot),
+ };
+ }
+
+ return {
+ source: 'default',
+ value: DEFAULT,
+ };
+ },
+ name: 'Separate audio to',
+ setConfig: (value) => {
+ separateAudioTo = value;
+ },
+ ssrName: 'separateAudioTo',
+ type: 'string' as string | null,
+} satisfies AnyRemotionOption<string | null>;