Skip to content

🎥 Make videos programmatically with React

separate audio to

Jonny Burger39a100abd7a7
diff --git a/packages/docs/docs/renderer/render-media.mdx b/packages/docs/docs/renderer/render-media.mdx
index 8ee28a2a66..9df5df2e55 100644
--- a/packages/docs/docs/renderer/render-media.mdx
+++ b/packages/docs/docs/renderer/render-media.mdx
@@ -453,6 +453,10 @@ _boolean - default `false`_
<Options id="binaries-directory" />
+### `separateAudioTo?`<AvailableFrom v="4.0.123" />
+
+<Options cli id="separate-audio-to" />
+
### `forSeamlessAacConcatenation?`<AvailableFrom v="4.0.123" />
<Options id="for-seamless-aac-concatenation" />
diff --git a/packages/docs/docs/renderer/stitch-frames-to-video.mdx b/packages/docs/docs/renderer/stitch-frames-to-video.mdx
index 9e470674c4..956db21dd2 100644
--- a/packages/docs/docs/renderer/stitch-frames-to-video.mdx
+++ b/packages/docs/docs/renderer/stitch-frames-to-video.mdx
@@ -2,7 +2,7 @@
image: /generated/articles-docs-renderer-stitch-frames-to-video.png
id: stitch-frames-to-video
title: stitchFramesToVideo()
-crumb: "@remotion/renderer"
+crumb: '@remotion/renderer'
---
_Part of the `@remotion/renderer` package._
@@ -17,10 +17,6 @@ In Remotion 3.0, we added the [`renderMedia()`](/docs/renderer/render-media) API
An object with the following properties:
-### `dir`
-
-A `string` containing the absolute path of the directory where the frames are located. This will be the directory where the `ffmpeg` command will be executed.
-
### `fps`
A `number` specifying the desired frame rate of the output video.
@@ -35,7 +31,8 @@ A `number` specifying the desired output height in pixels for the video.
### `assetsInfo`
-Information about the audio mix. This is part of the return value of [renderFrames()](/docs/renderer/render-frames#return-value).
+Information about the frames and audio mix. This is part of the return value of [`renderFrames()`](/docs/renderer/render-frames#return-value).
+The data structure is not stable between Remotion versions.
### `outputLocation?`
@@ -78,19 +75,19 @@ Refer to the [Encoding guide](/docs/encoding/#audio-codec) to see defaults and s
### `audioBitrate?`<AvailableFrom v="3.2.32" />
-<Options id="audio-bitrate"/>
+<Options id="audio-bitrate" />
### `videoBitrate?`<AvailableFrom v="3.2.32" />
-<Options id="video-bitrate"/>
+<Options id="video-bitrate" />
### `bufferSize?`<AvailableFrom v="4.0.78" />
-<Options id="buffer-size"/>
+<Options id="buffer-size" />
### `maxRate?`<AvailableFrom v="4.0.78" />
-<Options id="max-rate"/>
+<Options id="max-rate" />
### `crf?`
@@ -152,14 +149,32 @@ _optional_
A token that allows the render to be cancelled. See: [`makeCancelSignal()`](/docs/renderer/make-cancel-signal)
+### `enforceAudioTrack?`<AvailableFrom v="3.2.1" />
+
+Render a silent audio track if there wouldn't be any otherwise.
+
### `binariesDirectory?`<AvailableFrom v="4.0.120" />
<Options id="binaries-directory" />
+### `separateAudioTo?`<AvailableFrom v="4.0.123" />
+
+<Options cli id="separate-audio-to" />
+
### `forSeamlessAacConcatenation?`<AvailableFrom v="4.0.123" />
<Options id="for-seamless-aac-concatenation" />
+### `x264Preset?`
+
+_string - optional_
+
+<Options id="x264-preset" />
+
+### `colorSpace?`<AvailableFrom v="4.0.28"/>
+
+<Options id="color-space" />
+
### `ffmpegOverride?`<AvailableFrom v="3.2.22" />
_function - optional_
@@ -167,11 +182,11 @@ _function - optional_
Modifies the FFMPEG command that Remotion uses under the hood. It works reducer-style, meaning that you pass a function that takes a command as an argument and returns a new command.
```tsx twoslash
-import type { FfmpegOverrideFn } from "@remotion/renderer";
+import type {FfmpegOverrideFn} from '@remotion/renderer';
-const ffmpegOverride: FfmpegOverrideFn = ({ type, args }) => {
+const ffmpegOverride: FfmpegOverrideFn = ({type, args}) => {
console.log(type); // "stitcher" | "pre-stitcher
- return [...args, "-vf", "eq=brightness=0:saturation=1"];
+ return [...args, '-vf', 'eq=brightness=0:saturation=1'];
};
```
diff --git a/packages/renderer/src/options/separate-audio.tsx b/packages/renderer/src/options/separate-audio.tsx
index dc64880108..23f4a48dd8 100644
--- a/packages/renderer/src/options/separate-audio.tsx
+++ b/packages/renderer/src/options/separate-audio.tsx
@@ -6,8 +6,14 @@ const cliFlag = 'separate-audio-to';
export const separateAudioOption = {
cliFlag,
- description: () =>
- `If set, the audio will not be included in the main output but rendered as a separate file at the location you pass. It is recommended to use an absolute path. If a relative path is passed, it is relative to the Remotion Root.`,
+ description: () => (
+ <>
+ If set, the audio will not be included in the main output but rendered as
+ a separate file at the location you pass. It is recommended to use an
+ absolute path. If a relative path is passed, it is relative to the{' '}
+ <a href="/docs/terminology/remotion-root">Remotion Root</a>.
+ </>
+ ),
docLink: 'https://remotion.dev/docs/renderer/render-media',
getValue: ({commandLine}) => {
if (commandLine[cliFlag]) {
diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.ts
index 610652a084..19eaaf35c3 100644
--- a/packages/renderer/src/render-media.ts
+++ b/packages/renderer/src/render-media.ts
@@ -716,8 +716,8 @@ const internalRenderMediaRaw = ({
ffmpegOverride: ffmpegOverride ?? null,
audioBitrate,
videoBitrate,
- encodingBufferSize,
- encodingMaxRate,
+ bufferSize: encodingBufferSize,
+ maxRate: encodingMaxRate,
audioCodec,
x264Preset: x264Preset ?? null,
colorSpace,
diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.ts
index 0ee431e59e..e9d98488a0 100644
--- a/packages/renderer/src/stitch-frames-to-video.ts
+++ b/packages/renderer/src/stitch-frames-to-video.ts
@@ -43,8 +43,8 @@ import {validateBitrate} from './validate-videobitrate';
type InternalStitchFramesToVideoOptions = {
audioBitrate: string | null;
videoBitrate: string | null;
- encodingMaxRate: string | null;
- encodingBufferSize: string | null;
+ maxRate: string | null;
+ bufferSize: string | null;
fps: number;
width: number;
height: number;
@@ -73,16 +73,16 @@ type InternalStitchFramesToVideoOptions = {
} & ToOptions<typeof optionsMap.stitchFramesToVideo>;
export type StitchFramesToVideoOptions = {
- audioBitrate?: string | null;
- videoBitrate?: string | null;
- encodingMaxRate?: string | null;
- encodingBufferSize?: string | null;
fps: number;
width: number;
height: number;
- outputLocation?: string | null;
- force: boolean;
assetsInfo: RenderAssetInfo;
+ force?: boolean;
+ audioBitrate?: string | null;
+ videoBitrate?: string | null;
+ maxRate?: string | null;
+ bufferSize?: string | null;
+ outputLocation?: string | null;
pixelFormat?: PixelFormat;
numberOfGifLoops?: number | null;
codec?: Codec;
@@ -126,8 +126,8 @@ const innerStitchFramesToVideo = async (
proResProfile,
logLevel,
videoBitrate,
- encodingMaxRate,
- encodingBufferSize,
+ maxRate,
+ bufferSize,
width,
numberOfGifLoops,
onProgress,
@@ -154,9 +154,9 @@ const innerStitchFramesToVideo = async (
validateBitrate(audioBitrate, 'audioBitrate');
validateBitrate(videoBitrate, 'videoBitrate');
- validateBitrate(encodingMaxRate, 'encodingMaxRate');
- // encodingBufferSize is not a bitrate but need to be validated using the same format
- validateBitrate(encodingBufferSize, 'encodingBufferSize');
+ validateBitrate(maxRate, 'maxRate');
+ // bufferSize is not a bitrate but need to be validated using the same format
+ validateBitrate(bufferSize, 'bufferSize');
validateFps(fps, 'in `stitchFramesToVideo()`', false);
assetsInfo.downloadMap.preventCleanup();
@@ -249,8 +249,8 @@ const innerStitchFramesToVideo = async (
crf,
codec,
videoBitrate,
- encodingMaxRate,
- encodingBufferSize,
+ encodingMaxRate: maxRate,
+ encodingBufferSize: bufferSize,
});
validateSelectedPixelFormatAndCodecCombination(pixelFormat, codec);
@@ -351,8 +351,8 @@ const innerStitchFramesToVideo = async (
codec,
crf,
videoBitrate,
- encodingMaxRate,
- encodingBufferSize,
+ encodingMaxRate: maxRate,
+ encodingBufferSize: bufferSize,
hasPreencoded: Boolean(preEncodedFileLocation),
proResProfileName,
pixelFormat,
@@ -514,8 +514,8 @@ export const stitchFramesToVideo = ({
proResProfile,
verbose,
videoBitrate,
- encodingMaxRate,
- encodingBufferSize,
+ maxRate,
+ bufferSize,
x264Preset,
colorSpace,
binariesDirectory,
@@ -524,15 +524,15 @@ export const stitchFramesToVideo = ({
return internalStitchFramesToVideo({
assetsInfo,
audioBitrate: audioBitrate ?? null,
- encodingMaxRate: encodingMaxRate ?? null,
- encodingBufferSize: encodingBufferSize ?? null,
+ maxRate: maxRate ?? null,
+ bufferSize: bufferSize ?? null,
audioCodec: audioCodec ?? null,
cancelSignal: cancelSignal ?? null,
codec: codec ?? DEFAULT_CODEC,
crf: crf ?? null,
enforceAudioTrack: enforceAudioTrack ?? false,
ffmpegOverride: ffmpegOverride ?? null,
- force,
+ force: force ?? true,
fps,
height,
indent: false,