Skip to content

🎥 Make videos programmatically with React

Docs: Completely revamp Audio Docs

Jonny Burgerb2e6204d5ebd
diff --git a/packages/core/src/use-media-in-timeline.ts b/packages/core/src/use-media-in-timeline.ts
index 119ee1eca8..f5d87bb26b 100644
--- a/packages/core/src/use-media-in-timeline.ts
+++ b/packages/core/src/use-media-in-timeline.ts
@@ -94,7 +94,7 @@ export const useMediaInTimeline = ({
useEffect(() => {
if (typeof volume === 'number' && volume !== initialVolume) {
warnOnce(
- `Remotion: The ${mediaType} with src ${src} has changed it's volume. Prefer the callback syntax for setting volume to get better timeline display: https://www.remotion.dev/docs/using-audio/#controlling-volume`,
+ `Remotion: The ${mediaType} with src ${src} has changed it's volume. Prefer the callback syntax for setting volume to get better timeline display: https://www.remotion.dev/docs/audio/volume`,
);
}
}, [initialVolume, mediaType, src, volume]);
diff --git a/packages/docs/blog/2021-04-15-remotion-2-0.mdx b/packages/docs/blog/2021-04-15-remotion-2-0.mdx
index 07ee5b5cb5..82b73dd7ba 100644
--- a/packages/docs/blog/2021-04-15-remotion-2-0.mdx
+++ b/packages/docs/blog/2021-04-15-remotion-2-0.mdx
@@ -27,7 +27,7 @@ With newly introduced audio visualization APIs, you can make your visuals react
What you need are the new [`getAudioData()`](/docs/get-audio-data) and [`visualizeAudio()`](/docs/visualize-audio) APIs that have been published [in it's own package](/docs/media-utils/).
-Read more about [audio visualization](/docs/audio-visualization) in the docs or [watch a sample video](https://twitter.com/JNYBGR/status/1378444074634592262) (the source can be found [here](https://github.com/yuta0801/remotion/blob/1103092f4902fb11f41877a05398dab6ce7203e7/packages/example/src/AudioVisualization/index.tsx)).
+Read more about [audio visualization](/docs/audio/visualization) in the docs or [watch a sample video](https://twitter.com/JNYBGR/status/1378444074634592262) (the source can be found [here](https://github.com/yuta0801/remotion/blob/1103092f4902fb11f41877a05398dab6ce7203e7/packages/example/src/AudioVisualization/index.tsx)).
## Export as MP3, AAC, WAV
@@ -98,7 +98,6 @@ Learn more about the [`--frames`](/docs/config#setframerange) CLI option.
</video>
</div>
-
A new GIF component released in the `@remotion/gif` package is now available. The `<Gif />` component allows to load a local or remote GIF and synchronizes it with Remotions `useCurrentFrame()`. For that it parses the GIF using WebAssembly - basically it's really cool tech! Thanks a lot to [@jeetiss](https://github.com/jeetiss) for contributing this new component.
[Learn more about the GIF component here](/docs/gif).
@@ -118,11 +117,7 @@ In the editor, you can now resize the timeline as well as the left sidebar. Than
`interpolate()` now supports arrays with lengths bigger than 2. Really useful for a lot of scenarios - for example you can create a combined fade in/fade out transition with one line.
```tsx
-const opacity = interpolate(
- frame,
- [0, 10, durationInFrames - 10, durationInFrames],
- [0, 1, 1, 0],
-);
+const opacity = interpolate(frame, [0, 10, durationInFrames - 10, durationInFrames], [0, 1, 1, 0]);
```
## 170+ tests added
diff --git a/packages/docs/docs/audio.mdx b/packages/docs/docs/audio.mdx
index 327c258d78..bd239d27d2 100644
--- a/packages/docs/docs/audio.mdx
+++ b/packages/docs/docs/audio.mdx
@@ -188,7 +188,7 @@ To prevent synthetic amplification, set a volume not higher than 1.
- [Source code for this component](https://github.com/remotion-dev/remotion/blob/main/packages/core/src/audio/Audio.tsx)
- [Using audio](/docs/using-audio)
-- [Audio visualization](/docs/audio-visualization)
+- [Audio visualization](/docs/audio/visualization)
- [`<Video />`](/docs/video)
<Credits
diff --git a/packages/docs/docs/audio/TableOfContents.tsx b/packages/docs/docs/audio/TableOfContents.tsx
new file mode 100644
index 0000000000..373bf72cd7
--- /dev/null
+++ b/packages/docs/docs/audio/TableOfContents.tsx
@@ -0,0 +1,52 @@
+import React from 'react';
+import {Grid} from '../../components/TableOfContents/Grid';
+import {TOCItem} from '../../components/TableOfContents/TOCItem';
+
+export const TableOfContents: React.FC = () => {
+ return (
+ <div>
+ <Grid>
+ <TOCItem link="/docs/audio/importing">
+ <strong>{'Importing audio'}</strong>
+ <div>Add audio to your compositions</div>
+ </TOCItem>
+ <TOCItem link="/docs/audio/delaying">
+ <strong>{'Delaying audio'}</strong>
+ <div>Delay the start time of audio elements</div>
+ </TOCItem>
+ <TOCItem link="/docs/audio/from-video">
+ <strong>{'Creating audio from video'}</strong>
+ <div>Use audio from videos</div>
+ </TOCItem>
+ <TOCItem link="/docs/audio/volume">
+ <strong>{'Controlling volume'}</strong>
+ <div>Control the volume of audio elements</div>
+ </TOCItem>
+ <TOCItem link="/docs/audio/muting">
+ <strong>{'Muting audio'}</strong>
+ <div>Mute audio elements</div>
+ </TOCItem>
+ <TOCItem link="/docs/audio/speed">
+ <strong>{'Controlling speed'}</strong>
+ <div>Change the speed of audio elements</div>
+ </TOCItem>
+ <TOCItem link="/docs/audio/pitch">
+ <strong>{'Controlling pitch'}</strong>
+ <div>Change the pitch of audio elements</div>
+ </TOCItem>
+ <TOCItem link="/docs/audio/visualization">
+ <strong>{'Visualizing audio'}</strong>
+ <div>Visualize audio elements</div>
+ </TOCItem>
+ <TOCItem link="/docs/audio/exporting">
+ <strong>{'Exporting audio'}</strong>
+ <div>Export audio</div>
+ </TOCItem>
+ <TOCItem link="/docs/audio/order-of-operations">
+ <strong>{'Order of operations'}</strong>
+ <div>Control the order of operations for audio elements</div>
+ </TOCItem>
+ </Grid>
+ </div>
+ );
+};
diff --git a/packages/docs/docs/audio/delaying.mdx b/packages/docs/docs/audio/delaying.mdx
new file mode 100644
index 0000000000..a21853bd01
--- /dev/null
+++ b/packages/docs/docs/audio/delaying.mdx
@@ -0,0 +1,28 @@
+---
+image: /generated/articles-docs-audio-delaying.png
+title: Delaying Audio
+sidebar_label: Delaying Audio
+id: delaying
+crumb: 'Audio'
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+Use a [`<Sequence>`](/docs/sequence) with a positive [`from`](/docs/sequence#from) value to delay the audio from playing.
+
+In the following example, the audio will start playing after 100 frames.
+
+```tsx twoslash {6-8}
+import {AbsoluteFill, Audio, Sequence, staticFile} from 'remotion';
+
+export const MyComposition = () => {
+ return (
+ <AbsoluteFill>
+ <Sequence from={100}>
+ <Audio src={staticFile('audio.mp3')} />
+ </Sequence>
+ </AbsoluteFill>
+ );
+};
+```
diff --git a/packages/docs/docs/audio/exporting.mdx b/packages/docs/docs/audio/exporting.mdx
new file mode 100644
index 0000000000..3f4dab7a52
--- /dev/null
+++ b/packages/docs/docs/audio/exporting.mdx
@@ -0,0 +1,197 @@
+---
+image: /generated/articles-docs-audio-exporting.png
+title: Exporting Audio
+sidebar_label: Exporting Audio
+id: exporting
+crumb: 'Audio'
+---
+
+If you export your video from Remotion, the audio is automatically included.
+Additionally, this page shows you can export the audio only, or omit the audio, and how the export process works.
+
+## Audio Only
+
+Exporting as `mp3`, `aac` and `wav` is supported:
+
+### Command Line
+
+To render only the audio via CLI, specify an extension when exporting via CLI:
+
+```sh
+npx remotion render src/index.ts my-comp out/audio.mp3
+```
+
+or use the `--codec` flag to automatically choose a good output file name:
+
+```sh
+npx remotion render src/index.ts my-comp --codec=mp3
+```
+
+### `renderMedia()`
+
+To render only the audio via the server-side rendering APIs, use [`renderMedia()`](/docs/renderer/render-media) and set the [`codec`](/docs/renderer/render-media#codec) to an audio codec.
+
+```tsx twoslash title="render.js"
+import {bundle} from '@remotion/bundler';
+import {getCompositions, renderMedia} from '@remotion/renderer'; // The composition you want to render
+import path from 'path';
+const compositionId = 'HelloWorld';
+
+// You only have to do this once, you can reuse the bundle.
+const entry = './src/index';
+console.log('Creating a Webpack bundle of the video');
+const bundleLocation = await bundle(path.resolve(entry), () => undefined, {
+ // If you have a Webpack override, make sure to add it here
+ webpackOverride: (config) => config,
+});
+
+// Parametrize the video by passing arbitrary props to your component.
+const inputProps = {
+ foo: 'bar',
+};
+
+// Extract all the compositions you have defined in your project
+// from the webpack bundle.
+const comps = await getCompositions(bundleLocation, {
+ // You can pass custom input props that you can retrieve using getInputProps()
+ // in the composition list. Use this if you want to dynamically set the duration or
+ // dimensions of the video.
+ inputProps,
+});
+
+// Select the composition you want to render.
+const composition = comps.find((c) => c.id === compositionId);
+
+// Ensure the composition exists
+if (!composition) {
+ throw new Error(`No composition with the ID ${compositionId} found.
+ Review "${entry}" for the correct ID.`);
+}
+const outputLocation = `out/${compositionId}.mp4`;
+
+// ---cut---
+await renderMedia({
+ composition,
+ serveUrl: bundleLocation,
+ codec: 'mp3',
+ outputLocation,
+ inputProps,
+});
+```
+
+### `renderMediaOnLambda()`
+
+To render only the audio via Lambda, use [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda) and set the [`codec`](/docs/lambda/rendermediaonlambda#codec) to an audio codec and [`imageFormat`](/docs/lambda/rendermediaonlambda#imageformat) to `none`.
+
+```tsx twoslash
+import {renderMediaOnLambda} from '@remotion/lambda';
+// ---cut---
+
+const {bucketName, renderId} = await renderMediaOnLambda({
+ region: 'us-east-1',
+ functionName: 'remotion-render-bds9aab',
+ composition: 'MyVideo',
+ serveUrl: 'https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw',
+ inputProps: {},
+ codec: 'mp3',
+ imageFormat: 'none',
+});
+```
+
+### Lambda CLI
+
+To render via the Lambda CLI, use the [`npx remotion lambda render`](/docs/lambda/cli/render) command and pass the [`--codec`](/docs/lambda/cli/render#--codec) flag:
+
+```sh
+npx remotion lambda render --codec=mp3 https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw my-comp
+```
+
+## Excluding audio
+
+### Command Line
+
+Pass `--muted` to not export audio.
+
+```sh
+npx remotion render --muted
+```
+
+### `renderMedia()`
+
+Pass [`muted: true`](/docs/renderer/render-media#muted) to [`renderMedia()`](/docs/renderer/render-media) to mute a render.
+
+```tsx twoslash title="render.js"
+import {bundle} from '@remotion/bundler';
+import {getCompositions, renderMedia} from '@remotion/renderer'; // The composition you want to render
+import path from 'path';
+const compositionId = 'HelloWorld';
+
+// You only have to do this once, you can reuse the bundle.
+const entry = './src/index';
+console.log('Creating a Webpack bundle of the video');
+const bundleLocation = await bundle(path.resolve(entry), () => undefined, {
+ // If you have a Webpack override, make sure to add it here
+ webpackOverride: (config) => config,
+});
+
+// Parametrize the video by passing arbitrary props to your component.
+const inputProps = {
+ foo: 'bar',
+};
+
+// Extract all the compositions you have defined in your project
+// from the webpack bundle.
+const comps = await getCompositions(bundleLocation, {
+ // You can pass custom input props that you can retrieve using getInputProps()
+ // in the composition list. Use this if you want to dynamically set the duration or
+ // dimensions of the video.
+ inputProps,
+});
+
+// Select the composition you want to render.
+const composition = comps.find((c) => c.id === compositionId);
+
+// Ensure the composition exists
+if (!composition) {
+ throw new Error(`No composition with the ID ${compositionId} found.
+ Review "${entry}" for the correct ID.`);
+}
+const outputLocation = `out/${compositionId}.mp4`;
+
+// ---cut---
+await renderMedia({
+ composition,
+ serveUrl: bundleLocation,
+ codec: 'h264',
+ muted: true,
+ outputLocation,
+ inputProps,
+});
+```
+
+### `renderMediaOnLambda()`
+
+Pass [`muted: true`](/docs/lambda/rendermediaonlambda#muted) to [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda) to mute the render.
+
+```tsx twoslash
+import {renderMediaOnLambda} from '@remotion/lambda';
+// ---cut---
+
+const {bucketName, renderId} = await renderMediaOnLambda({
+ region: 'us-east-1',
+ functionName: 'remotion-render-bds9aab',
+ composition: 'MyVideo',
+ serveUrl: 'https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw',
+ inputProps: {},
+ codec: 'h264',
+ muted: true,
+});
+```
+
+### Lambda CLI
+
+Pass [`--muted`](/docs/lambda/cli/render#--muted) to [`npx remotion lambda render`](/docs/lambda/cli/render) to mute a render when using the Lambda Command Line.
+
+```sh
+npx remotion lambda render --muted https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw my-comp
+```
diff --git a/packages/docs/docs/audio/from-video.mdx b/packages/docs/docs/audio/from-video.mdx
new file mode 100644
index 0000000000..1eaea9a03f
--- /dev/null
+++ b/packages/docs/docs/audio/from-video.mdx
@@ -0,0 +1,26 @@
+---
+image: /generated/articles-docs-audio-from-video.png
+title: Use Audio from video
+sidebar_label: Use Audio from video
+id: from-video
+crumb: 'Audio'
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+Audio from [`<Video />`](/docs/video) and [`<OffthreadVideo />`](/docs/offthreadvideo) tags are also included in the output.
+
+The same principles apply as for audio - you may [trim](/docs/audio/trimming), [delay](/docs/audio/delaying), [mute](/docs/audio/muting), [speed up](/docs/audio/speed) and [reduce the volume](/docs/audio/volume) of your videos.
+
+```tsx twoslash {6} title="MyComp.tsx"
+import {AbsoluteFill, OffthreadVideo, staticFile} from 'remotion';
+
+export const MyComposition = () => {
+ return (
+ <AbsoluteFill>
+ <OffthreadVideo src={staticFile('video.mp4')} playbackRate={2} volume={0.5} />
+ </AbsoluteFill>
+ );
+};
+```
diff --git a/packages/docs/docs/audio/importing.mdx b/packages/docs/docs/audio/importing.mdx
new file mode 100644
index 0000000000..6521e9917d
--- /dev/null
+++ b/packages/docs/docs/audio/importing.mdx
@@ -0,0 +1,42 @@
+---
+image: /generated/articles-docs-audio-importing.png
+title: Importing Audio
+sidebar_label: Importing Audio
+id: importing
+crumb: 'Audio'
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+[Put an audio file into the `public/` folder](/docs/assets) and use [`staticFile()`](/docs/staticfile) to reference it.
+Add an [`<Audio/>`](/docs/audio) tag to your component to add sound to it.
+
+```tsx twoslash title="MyComp.tsx"
+import {AbsoluteFill, Audio, staticFile} from 'remotion';
+
+export const MyComposition = () => {
+ return (
+ <AbsoluteFill>
+ <Audio src={staticFile('audio.mp3')} />
+ </AbsoluteFill>
+ );
+};
+```
+
+You can also add remote audio by passing a URL:
+
+```tsx twoslash title="MyComp.tsx"
+import {AbsoluteFill, Audio} from 'remotion';
+
+export const MyComposition = () => {
+ return (
+ <AbsoluteFill>
+ <Audio src="https://example.com/audio.mp3" />
+ </AbsoluteFill>
+ );
+};
+```
+
+By default, the audio will play from the start, at full volume and full length.
+You can mix multiple tracks together by adding more audio tags.
diff --git a/packages/docs/docs/audio/muting.mdx b/packages/docs/docs/audio/muting.mdx
new file mode 100644
index 0000000000..59bb2d9a92
--- /dev/null
+++ b/packages/docs/docs/audio/muting.mdx
@@ -0,0 +1,30 @@
+---
+image: /generated/articles-docs-audio-muting.png
+title: Muting Audio
+sidebar_label: Muting Audio
+id: muting
+crumb: 'Audio'
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+import {AvailableFrom} from '../../src/components/AvailableFrom';
+
+You may pass in the [`muted`](/docs/audio#muted) prop to [`<Audio>`](/docs/audio), [`<OffthreadVideo>`](/docs/offthreadvideo) and [`<Video>`](/docs/video) and even change it over time.
+
+When [`muted`](/docs/audio#muted) is true, audio will be omitted at that time. In the following example, we are muting the track between seconds 2 and 4.
+
+```tsx twoslash {9}
+import {AbsoluteFill, Audio, staticFile, useCurrentFrame, useVideoConfig} from 'remotion';
+
+export const MyComposition = () => {
+ const frame = useCurrentFrame();
+ const {fps} = useVideoConfig();
+
+ return (
+ <AbsoluteFill>
+ <Audio src={staticFile('audio.mp3')} muted={frame >= 2 * fps && frame <= 4 * fps} />
+ </AbsoluteFill>
+ );
+};
+```
diff --git a/packages/docs/docs/audio/order-of-operations.mdx b/packages/docs/docs/audio/order-of-operations.mdx
new file mode 100644
index 0000000000..d514a6ad34
--- /dev/null
+++ b/packages/docs/docs/audio/order-of-operations.mdx
@@ -0,0 +1,29 @@
+---
+image: /generated/articles-docs-audio-order-of-operations.png
+title: Order of Operations
+sidebar_label: Order of Operations
+id: order-of-operations
+crumb: 'Audio'
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+import {AvailableFrom} from '../../src/components/AvailableFrom';
+
+Before Remotion v4.0.141, it was not defined in which order audio operations would be applied and behavior in preview and render could deviate.
+
+Since Remotion v4.0.141, the order of operations is guaranteed to be the following:
+
+1. Trim audio (using [`startFrom`](/docs/audio#startfrom--endat)).
+2. Offset audio (by putting it in a [`<Sequence>`](/docs/sequence)).
+3. Stretch audio (by adding a [`playbackRate`](/docs/audio#playbackrate)).
+
+Example for a 30 FPS composition which is 60 frames long:
+
+1. An [`<Audio>`](/docs/audio) tag has a [`startFrom`](/docs/audio#startfrom--endat) value of 45. The first 1.5 seconds of the audio get trimmed off.
+2. The [`<Audio>`](/docs/audio) tag is in a [`<Sequence>`](/docs/sequence) which starts at `30`. The audio only begins playing at the 1.0 second timeline mark at the 1.5 second audio position.
+3. The [`<Audio>`](/docs/audio) has a [`playbackRate`](/docs/audio#playbackrate) of `2`. The audio gets sped up by 2x, but the starting position and start offset is not affected.
+4. The composition is 60 frames long, so the audio must stop at the 3.5 second mark:
+ > (comp_duration - offset) \* playback_rate + start_from
+ > (60 - 30) \* 2 + 45 => frame 105 or the 3.5 second mark
+5. Result: The section of 1.5sec - 3.5sec gets cut out of the audio and is played in the Remotion timeline between frames 30 and 59 at 2x speed.
diff --git a/packages/docs/docs/audio/pitch.mdx b/packages/docs/docs/audio/pitch.mdx
new file mode 100644
index 0000000000..7615809e7d
--- /dev/null
+++ b/packages/docs/docs/audio/pitch.mdx
@@ -0,0 +1,33 @@
+---
+image: /generated/articles-docs-audio-pitch.png
+title: Controlling Pitch
+sidebar_label: Controlling Pitch
+id: pitch
+crumb: 'Audio'
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+:::warning
+Pitch correction is currently only applied during rendering.
+:::
+
+You can use the [`toneFrequency`](/docs/audio#tonefrequency) prop to control the pitch of the audio during rendering.
+
+Values between `0.01` and `2` are accepted, where `1` represents the original pitch. Values less than `1` will decrease the pitch, while values greater than `1` will increase it.
+
+A [`toneFrequency`](/docs/audio#tonefrequency) of 0.5 would lower the pitch by half, and a [`toneFrequency`](/docs/audio#tonefrequency) of `1.5` would increase the pitch by 50%.
+
+```tsx twoslash {7} title="MyComp.tsx"
+import {Audio, staticFile, AbsoluteFill} from 'remotion';
+
+export const MyComposition = () => {
+ return (
+ <AbsoluteFill>
+ <div>Hello World!</div>
+ <Audio src={staticFile('audio.mp3')} toneFrequency={0.8} />
+ </AbsoluteFill>
+ );
+};
+```
diff --git a/packages/docs/docs/audio/speed.mdx b/packages/docs/docs/audio/speed.mdx
new file mode 100644
index 0000000000..c9eb78306a
--- /dev/null
+++ b/packages/docs/docs/audio/speed.mdx
@@ -0,0 +1,28 @@
+---
+image: /generated/articles-docs-audio-speed.png
+title: Controlling playback speed
+sidebar_label: Audio Speed
+id: speed
+crumb: 'Audio'
+---
+
+# Controlling playback speed<AvailableFrom v="2.2" />
+
+You can use the [`playbackRate`](/docs/audio#playbackrate) prop to control the speed of the audio.
+
+- `1` is the default.
+- `0.5` slows down the audio so it's twice as long
+- `2` speeds up the audio so it's twice as fast
+- Google Chrome supports playback rates between `0.0625` and `16`.
+
+```tsx twoslash {6} title="MyComp.tsx"
+import {AbsoluteFill, Audio, staticFile} from 'remotion';
+
+export const MyComposition = () => {
+ return (
+ <AbsoluteFill>
+ <Audio src={staticFile('audio.mp3')} playbackRate={2} />
+ </AbsoluteFill>
+ );
+};
+```
diff --git a/packages/docs/docs/audio/trimming.mdx b/packages/docs/docs/audio/trimming.mdx
new file mode 100644
index 0000000000..0e4ec1ce04
--- /dev/null
+++ b/packages/docs/docs/audio/trimming.mdx
@@ -0,0 +1,31 @@
+---
+image: /generated/articles-docs-audio-trimming.png
+title: Trimming Audio
+sidebar_label: Trimming Audio
+id: trimming
+crumb: 'Audio'
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+The [`<Audio />`](/docs/audio) tag supports the [`startFrom`](/docs/audio#startfrom--endat) and [`endAt`](/docs/audio#startfrom--endat) props.
+With it, you can trim off parts of the audio.
+
+```tsx twoslash {8} title="MyComp.tsx"
+import {AbsoluteFill, Audio, staticFile, useVideoConfig} from 'remotion';
+
+export const MyComposition = () => {
+ const {fps} = useVideoConfig();
+
+ return (
+ <AbsoluteFill>
+ <Audio src={staticFile('audio.mp3')} startFrom={2 * fps} endAt={4 * fps} />
+ </AbsoluteFill>
+ );
+};
+```
+
+This will result the audio to play the range from `00:02:00` to `00:04:00`, meaning the audio will play for 2 seconds.
+
+The audio will still play immediately at the beginning - to see how to shift the audio to appear later in the composition, see the [next article](/docs/audio/delaying).
diff --git a/packages/docs/docs/audio-visualization.mdx b/packages/docs/docs/audio/visualization.mdx
similarity index 93%
rename from packages/docs/docs/audio-visualization.mdx
rename to packages/docs/docs/audio/visualization.mdx
index 2a2b5b8326..a61be8178c 100644
--- a/packages/docs/docs/audio-visualization.mdx
+++ b/packages/docs/docs/audio/visualization.mdx
@@ -1,8 +1,9 @@
---
image: /generated/articles-docs-audio-visualization.png
-title: Audio visualization
-id: audio-visualization
-crumb: 'Techniques'
+title: Audio Visualization
+sidebar_label: Visualizing audio
+id: visualization
+crumb: 'Audio'
---
Remotion has APIs for visualizing audio, for example for creating audiograms or music visualizers.
@@ -54,7 +55,7 @@ export const MyComponent: React.FC = () => {
See an example for a waveform visualizations using [`visualizeAudioWaveform()`](/docs/media-utils/visualize-audio-waveform) here.
-import {AudioWaveFormExample} from '../components/AudioWaveformExamples.tsx';
+import {AudioWaveFormExample} from '../../components/AudioWaveformExamples.tsx';
<AudioWaveFormExample type="moving" />
diff --git a/packages/docs/docs/audio/volume.mdx b/packages/docs/docs/audio/volume.mdx
new file mode 100644
index 0000000000..bd12baf267
--- /dev/null
+++ b/packages/docs/docs/audio/volume.mdx
@@ -0,0 +1,66 @@
+---
+image: /generated/articles-docs-audio-volume.png
+title: Controlling Volume
+sidebar_label: Controlling Volume
+id: volume
+crumb: 'Audio'
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+You can use the [`volume`](/docs/audio#volume) prop to control the volume.
+
+The simplest way is to pass a number between `0` and `1`.
+
+```tsx twoslash {7} title="MyComp.tsx"
+import {Audio, staticFile, AbsoluteFill} from 'remotion';
+
+export const MyComposition = () => {
+ return (
+ <AbsoluteFill>
+ <div>Hello World!</div>
+ <Audio src={staticFile('audio.mp3')} volume={0.5} />
+ </AbsoluteFill>
+ );
+};
+```
+
+## Changing volume over time
+
+You can also change volume over time by passing in a function that takes a frame number and returns the volume.
+
+```tsx twoslash {8}
+import {AbsoluteFill, Audio, interpolate, staticFile, useVideoConfig} from 'remotion';
+
+export const MyComposition = () => {
+ const {fps} = useVideoConfig();
+
+ return (
+ <AbsoluteFill>
+ <Audio src={staticFile('audio.mp3')} volume={(f) => interpolate(f, [0, 1 * fps], [0, 1], {extrapolateLeft: 'clamp'})} />
+ </AbsoluteFill>
+ );
+};
+```
+
+In this example we are using the [`interpolate()`](/docs/interpolate) function to fade the audio in over 1 second.
+
+Note that because values below 0 are not allowed, we need to set the [`extrapolateLeft: 'clamp'`](/docs/interpolate#extrapolateleft) option to ensure no negative values.
+
+Inside the callback function, the value of `f` starts always `0` when the audio begins to play.
+It is not the same as the value of [`useCurrentFrame()`](/docs/use-current-frame).
+
+Prefer using a callback function if the volume is changing. This will enable Remotion to draw a volume curve in the [Studio](/docs/studio) and is more performant.
+
+## Volume on iOS Safari
+
+Note that Mobile Safari [does not support the `volume` property](https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW11). Currently, the volume will always be 1. We plan on in the future support to provide a workaround using the Web Audio API (see below).
+
+## Increasing the volume to above 1<AvailableFrom v="4.0.279" />
+
+It is possible to set volumes above 1, but some things need your attention.
+
+Remotion will use the Web Audio API to amplify the audio.
+
+For remote audio that does not support [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS-enabled), you need to also add `crossOrigin="anonymous"` to your media tags, otherwise the audio will be fully muted.
diff --git a/packages/docs/docs/get-audio-data.mdx b/packages/docs/docs/get-audio-data.mdx
index 7027caa624..78ab13f0db 100644
--- a/packages/docs/docs/get-audio-data.mdx
+++ b/packages/docs/docs/get-audio-data.mdx
@@ -147,7 +147,7 @@ Use the [`useAudioData()`](/docs/use-audio-data) helper hook to not have to do s
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/media-utils/src/get-audio-data.ts)
- [Using audio](/docs/using-audio)
-- [Audio visualization](/docs/audio-visualization)
+- [Audio visualization](/docs/audio/visualization)
- [`<Audio/>`](/docs/audio)
- [`visualizeAudio()`](/docs/visualize-audio)
- [`useAudioData()`](/docs/use-audio-data)
diff --git a/packages/docs/docs/media-utils/create-smooth-svg-path.mdx b/packages/docs/docs/media-utils/create-smooth-svg-path.mdx
index 11f91c1b82..3349697a0c 100644
--- a/packages/docs/docs/media-utils/create-smooth-svg-path.mdx
+++ b/packages/docs/docs/media-utils/create-smooth-svg-path.mdx
@@ -30,4 +30,4 @@ See a practical example [here](http://localhost:3001/docs/media-utils/visualize-
## See also
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/media-utils/src/create-smooth-svg-path.ts)
-- [Audio visualization](/docs/audio-visualization)
+- [Audio visualization](/docs/audio/visualization)
diff --git a/packages/docs/docs/media-utils/visualize-audio-waveform.mdx b/packages/docs/docs/media-utils/visualize-audio-waveform.mdx
index 0cad5dea3a..62666f8e00 100644
--- a/packages/docs/docs/media-utils/visualize-audio-waveform.mdx
+++ b/packages/docs/docs/media-utils/visualize-audio-waveform.mdx
@@ -194,7 +194,7 @@ const waveform = visualizeAudioWaveform({
## See also
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/media-utils/src/visualize-audio-waveform.ts)
-- [Audio visualization](/docs/audio-visualization)
+- [Audio visualization](/docs/audio/visualization)
- [`useAudioData()`](/docs/use-audio-data)
- [`getAudioData()`](/docs/get-audio-data)
- [`<Audio/>`](/docs/audio)
diff --git a/packages/docs/docs/offthreadvideo.mdx b/packages/docs/docs/offthreadvideo.mdx
index abbab31cde..bcb8412cf6 100644
--- a/packages/docs/docs/offthreadvideo.mdx
+++ b/packages/docs/docs/offthreadvideo.mdx
@@ -81,7 +81,7 @@ If set to `false` (_default_), frames will be extracted as bitmap (BMP), which i
### `volume?`
-Allows you to control the volume for the whole track or change it on a per-frame basis. Refer to the [using audio](/docs/using-audio#controlling-volume) guide to learn how to use it.
+Allows you to control the volume for the whole track or change it on a per-frame basis. Refer to the [using audio](/docs/audio/volume) guide to learn how to use it.
```tsx twoslash title="Example using static volume"
import {AbsoluteFill, OffthreadVideo, staticFile} from 'remotion';
diff --git a/packages/docs/docs/resources.mdx b/packages/docs/docs/resources.mdx
index f313190b70..687e966679 100644
--- a/packages/docs/docs/resources.mdx
+++ b/packages/docs/docs/resources.mdx
@@ -85,7 +85,7 @@ This list tries to compile all templates, libraries, building blocks and example
- D3.js example ([Source code](https://github.com/remotion-dev/d3-example), [Preview](https://d3-example-remotion.vercel.app/))
- Greenscreen Effect ([Docs](/docs/video-manipulation))
- Noise visualization ([Docs](/docs/noise-visualization))
-- Audio visualization ([Docs](/docs/audio-visualization))
+- Audio visualization ([Docs](/docs/audio/visualization))
- 3D Text ([Source code](https://github.com/remotion-dev/3d-text), [Preview](https://3d-text-remotion.vercel.app/))
- Wavy TikTok Effect ([Source code](https://github.com/JonnyBurger/wavy-meme))
- Apple "Spring loaded" animation ([Source code](https://github.com/JonnyBurger/spring-loaded))
@@ -164,6 +164,7 @@ See the [Showcase](/showcase) for videos made with Remotion.
- [HeySam, the AI Sales Engineer](https://www.heysam.ai/)
- [Frameloop AI](https://www.frameloop.ai/)
- [aicut - Faceless Videos](https://www.aicut.pro/)
+
## See also
- [Remotion GitHub topic](https://github.com/topics/remotion)
diff --git a/packages/docs/docs/use-audio-data.mdx b/packages/docs/docs/use-audio-data.mdx
index 46d14f5dd1..cafce2f52b 100644
--- a/packages/docs/docs/use-audio-data.mdx
+++ b/packages/docs/docs/use-audio-data.mdx
@@ -2,7 +2,7 @@
image: /generated/articles-docs-use-audio-data.png
title: useAudioData()
id: use-audio-data
-crumb: "@remotion/media-utils"
+crumb: '@remotion/media-utils'
---
_Part of the `@remotion/media-utils` package of helper functions._
@@ -19,18 +19,22 @@ Using this function, you can elegantly render a component based on audio propert
Remote audio files need to support [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).
<details>
-<summary>More info</summary>
-<ul>
-<li>
-Remotion's origin is usually <code>http://localhost:3000</code>, but it may be different if rendering on Lambda or the port is busy.
-</li>
-<li>
-You can use <a href="/docs/get-audio-duration-in-seconds"><code>getAudioDurationInSeconds()</code></a> without the audio needing CORS.
-</li>
-<li>
-You can <a href="/docs/chromium-flags#--disable-web-security">disable CORS</a> during renders.
-</li>
-</ul>
+ <summary>More info</summary>
+ <ul>
+ <li>
+ Remotion's origin is usually <code>http://localhost:3000</code>, but it may be different if rendering on Lambda or the port is busy.
+ </li>
+ <li>
+ You can use{' '}
+ <a href="/docs/get-audio-duration-in-seconds">
+ <code>getAudioDurationInSeconds()</code>
+ </a>{' '}
+ without the audio needing CORS.
+ </li>
+ <li>
+ You can <a href="/docs/chromium-flags#--disable-web-security">disable CORS</a> during renders.
+ </li>
+ </ul>
</details>
:::
@@ -48,11 +52,11 @@ A string pointing to an audio asset.
```tsx twoslash
// ---cut---
-import { useAudioData } from "@remotion/media-utils";
-import { staticFile } from "remotion";
+import {useAudioData} from '@remotion/media-utils';
+import {staticFile} from 'remotion';
export const MyComponent: React.FC = () => {
- const audioData = useAudioData(staticFile("music.mp3"));
+ const audioData = useAudioData(staticFile('music.mp3'));
if (!audioData) {
return null;
@@ -75,4 +79,4 @@ If you want to catch the error in the component, you need to make your own inlin
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/media-utils/src/use-audio-data.ts)
- [`getAudioData()`](/docs/get-audio-data)
- [`visualizeAudio()`](/docs/visualize-audio)
-- [Audio visualization](/docs/audio-visualization)
+- [Audio visualization](/docs/audio/visualization)
diff --git a/packages/docs/docs/use-windowed-audio-data.mdx b/packages/docs/docs/use-windowed-audio-data.mdx
index a4859f8001..5afb751899 100644
--- a/packages/docs/docs/use-windowed-audio-data.mdx
+++ b/packages/docs/docs/use-windowed-audio-data.mdx
@@ -22,8 +22,7 @@ Remote audio files need to support [CORS](https://developer.mozilla.org/en-US/do
<summary>More info</summary>
<ul>
<li>
- Remotion's origin is usually <code>http://localhost:3000</code>, but it
- may be different if rendering on Lambda or the port is busy.
+ Remotion's origin is usually <code>http://localhost:3000</code>, but it may be different if rendering on Lambda or the port is busy.
</li>
<li>
You can use{' '}
@@ -33,9 +32,7 @@ Remote audio files need to support [CORS](https://developer.mozilla.org/en-US/do
without the audio needing CORS.
</li>
<li>
- You can{' '}
- <a href="/docs/chromium-flags#--disable-web-security">disable CORS</a>{' '}
- during renders.
+ You can <a href="/docs/chromium-flags#--disable-web-security">disable CORS</a> during renders.
</li>
</ul>
</details>
@@ -125,4 +122,4 @@ You should pass it through to [`visualizeAudio()`](/docs/visualize-audio).
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/media-utils/src/use-audio-data.ts)
- [`getAudioData()`](/docs/get-audio-data)
- [`visualizeAudio()`](/docs/visualize-audio)
-- [Audio visualization](/docs/audio-visualization)
+- [Audio visualization](/docs/audio/visualization)
diff --git a/packages/docs/docs/using-audio.mdx b/packages/docs/docs/using-audio.mdx
index 5bc34266df..d0b4c27acf 100644
--- a/packages/docs/docs/using-audio.mdx
+++ b/packages/docs/docs/using-audio.mdx
@@ -9,292 +9,14 @@ crumb: 'Techniques'
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
-## Import audio
+Remotion provides powerful capabilities for working with audio in your compositions.
-[Put an audio file into the `public/` folder](/docs/assets) and use [`staticFile()`](/docs/staticfile) to reference it.
-Add an [`<Audio/>`](/docs/audio) tag to your component to add sound to it.
+import {TableOfContents} from './audio/TableOfContents';
-```tsx twoslash
-import {AbsoluteFill, Audio, staticFile} from 'remotion';
-
-export const MyComposition = () => {
- return (
- <AbsoluteFill>
- <Audio src={staticFile('audio.mp3')} />
- </AbsoluteFill>
- );
-};
-```
-
-You can also add remote audio by passing a URL:
-
-```tsx twoslash
-import {AbsoluteFill, Audio} from 'remotion';
-
-export const MyComposition = () => {
- return (
- <AbsoluteFill>
- <Audio src="https://example.com/audio.mp3" />
- </AbsoluteFill>
- );
-};
-```
-
-By default, the audio will play from the start, at full volume and full length.
-You can mix multiple tracks together by adding more audio tags.
-
-## Cutting or trimming the audio
-
-The `<Audio />` tag supports the `startFrom` and `endAt` props. In the following example, we assume that the [`fps`](/docs/composition#fps) of the composition is `30`.
-
-```tsx twoslash {6}
-import {AbsoluteFill, Audio, staticFile} from 'remotion';
-
-export const MyComposition = () => {
- return (
- <AbsoluteFill>
- <Audio src={staticFile('audio.mp3')} startFrom={60} endAt={120} />
- </AbsoluteFill>
- );
-};
-```
-
-By passing `startFrom={60}`, the playback starts immediately, but with the first 2 seconds of the audio trimmed away.
-By passing `endAt={120}`, any audio after the 4 second mark in the file will be trimmed away.
-
-The audio will play the range from `00:02:00` to `00:04:00`, meaning the audio will play for 2 seconds.
-
-## Delaying audio
-
-Use a `<Sequence>` with a positive `from` value to delay the audio from playing.
-In the following example, the audio will start playing (from the beginning) after 100 frames.
-
-```tsx twoslash {6-8}
-import {AbsoluteFill, Audio, Sequence, staticFile} from 'remotion';
-
-export const MyComposition = () => {
- return (
- <AbsoluteFill>
- <Sequence from={100}>
- <Audio src={staticFile('audio.mp3')} />
- </Sequence>
- </AbsoluteFill>
- );
-};
-```
-
-## Controlling volume
-
-You can use the [`volume`](/docs/audio#volume) prop to control the volume.
-
-The simplest way is to pass a number between 0 and 1. `1` is the maximum volume and `0` mutes the audio.
-
-```tsx twoslash {8}
-import {Audio} from 'remotion';
-import audio from './audio.mp3';
-
-export const MyComposition = () => {
- return (
- <div>
- <div>Hello World!</div>
- <Audio src={audio} volume={0.5} />
- </div>
- );
-};
-```
-
-You can also change volume over time by passing in a function that takes a frame number and returns the volume.
-
-```tsx twoslash {8-10}
-import {AbsoluteFill, Audio, interpolate, staticFile} from 'remotion';
-
-export const MyComposition = () => {
- return (
- <AbsoluteFill>
- <Audio src={staticFile('audio.mp3')} volume={(f) => interpolate(f, [0, 30], [0, 1], {extrapolateLeft: 'clamp'})} />
- </AbsoluteFill>
- );
-};
-```
-
-In this example we are using the [interpolate()](/docs/interpolate) function to fade the audio in over 30 frames. Note that because values below 0 are not allowed, we need to set the `extrapolateLeft: 'clamp'` option to ensure no negative values.
-
-Inside the callback function, the first frame at which audio is being played is numbered `0`, regardless of the value of `useCurrentFrame()`.
-
-Prefer using a callback function if the volume is changing. This will enable Remotion to draw a volume curve in the timeline and is more performant.
-
-:::note
-When using the [`<Player>`](/docs/player), note that Mobile Safari [does not support the `volume` property](https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW11). The audio mix may not play as intended.
-:::
-
-## `muted` property
-
-You may pass in the `muted` and it may change over time. When `muted` is true, audio will be omitted at that time. In the following example, we are muting the track between frame 40 and 60.
-
-```tsx twoslash {8}
-import {AbsoluteFill, Audio, staticFile, useCurrentFrame} from 'remotion';
-
-export const MyComposition = () => {
- const frame = useCurrentFrame();
-
- return (
- <AbsoluteFill>
- <Audio src={staticFile('audio.mp3')} muted={frame >= 40 && frame <= 60} />
- </AbsoluteFill>
- );
-};
-```
-
-## Use audio from `<Video />` tags
-
-Audio from [`<Video />`](/docs/video) and [`<OffthreadVideo />`](/docs/offthreadvideo) tags are also included in the output. You may use the [`startFrom`, `endAt`](/docs/video/#startfrom), [`volume`](/docs/video/#volume) and [`muted`](/docs/video/#muted) props in the same way.
-
-## Controlling playback speed
-
-<AvailableFrom v="2.2" />
-
-You can use the `playbackRate` prop to control the speed of the audio. `1` is the default and means regular speed, `0.5` slows down the audio so it's twice as long and `2` speeds up the audio so it's twice as fast.
-
-While Remotion doesn't limit the range of possible playback speeds, in development mode the [`HTMLMediaElement.playbackRate`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playbackRate) API is used which throws errors on extreme values. At the time of writing, Google Chrome throws an exception if the playback rate is below `0.0625` or above `16`.
-
-## Audio visualization
-
-You can obtain audio data and create visualizations based on it. See the page [Audio visualization](/docs/audio-visualization) for more info.
-
-## Rendering audio only
-
-Exporting as `mp3`, `aac` and `wav` is supported:
-
-<Tabs
-defaultValue="cli"
-values={[
-{ label: 'CLI', value: 'cli', },
-{ label: 'renderMedia()', value: 'node', },
-{ label: 'Lambda', value: 'lambda', },
-]
-}>
-<TabItem value="cli">
-
-To render only the audio via CLI, specify an extension when exporting via CLI:
-
-```
-npx remotion render src/index.ts my-comp out/audio.mp3
-```
-
-or use the `--codec` flag to automatically choose a good output file name:
-
-```
-npx remotion render src/index.ts my-comp --codec=mp3
-```
-
- </TabItem>
-
- <TabItem value="node">
-
-To render only the audio via Node.JS, use [`renderMedia()`](/docs/renderer/render-media) and set the [`codec`](/docs/renderer/render-media#codec) to an audio codec.
-
-```tsx twoslash
-import {bundle} from '@remotion/bundler';
-import {getCompositions, renderMedia} from '@remotion/renderer'; // The composition you want to render
-import path from 'path';
-const compositionId = 'HelloWorld';
-
-// You only have to do this once, you can reuse the bundle.
-const entry = './src/index';
-console.log('Creating a Webpack bundle of the video');
-const bundleLocation = await bundle(path.resolve(entry), () => undefined, {
- // If you have a Webpack override, make sure to add it here
- webpackOverride: (config) => config,
-});
-
-// Parametrize the video by passing arbitrary props to your component.
-const inputProps = {
- foo: 'bar',
-};
-
-// Extract all the compositions you have defined in your project
-// from the webpack bundle.
-const comps = await getCompositions(bundleLocation, {
- // You can pass custom input props that you can retrieve using getInputProps()
- // in the composition list. Use this if you want to dynamically set the duration or
- // dimensions of the video.
- inputProps,
-});
-
-// Select the composition you want to render.
-const composition = comps.find((c) => c.id === compositionId);
-
-// Ensure the composition exists
-if (!composition) {
- throw new Error(`No composition with the ID ${compositionId} found.
- Review "${entry}" for the correct ID.`);
-}
-const outputLocation = `out/${compositionId}.mp4`;
-
-// ---cut---
-await renderMedia({
- composition,
- serveUrl: bundleLocation,
- codec: 'mp3',
- outputLocation,
- inputProps,
-});
-```
-
- </TabItem>
- <TabItem value="lambda">
-
-To render only the audio via Lambda, use [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda) and set the [`codec`](/docs/lambda/rendermediaonlambda#codec) to an audio codec and [`imageFormat`](/docs/lambda/rendermediaonlambda#imageformat) to `none`.
-
-```tsx twoslash
-import {renderMediaOnLambda} from '@remotion/lambda';
-// ---cut---
-
-const {bucketName, renderId} = await renderMediaOnLambda({
- region: 'us-east-1',
- functionName: 'remotion-render-bds9aab',
- composition: 'MyVideo',
- framesPerLambda: 20,
- serveUrl: 'https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw',
- inputProps: {},
- codec: 'mp3',
- imageFormat: 'none',
- maxRetries: 1,
- privacy: 'public',
-});
-```
-
-To render via the Lambda CLI, use the [`npx remotion lambda render`](/docs/lambda/cli/render) command and pass the [`--codec`](/docs/lambda/cli/render#--codec) flag:
-
-```
-npx remotion lambda render --codec=mp3 https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw my-comp
-```
-
- </TabItem>
-</Tabs>
-
-## Order of operations<AvailableFrom v="4.0.141"/>
-
-Before Remotion v4.0.141, it was not defined in which order audio operations would be applied and behavior in preview and render could deviate.
-
-Since Remotion v4.0.141, the order of operations is guaranteed to be the following:
-
-1. Trim audio (using [`startFrom`](/docs/audio#startfrom--endat)).
-2. Offset audio (by putting it in a [sequence](/docs/terminology/sequence)).
-3. Stretch audio (by adding a [`playbackRate`](/docs/audio#playbackrate)).
-
-Example for a 30 FPS composition which is 60 frames long:
-
-1. An [`<Audio>`](/docs/audio) tag has a [`startFrom`](/docs/audio#startfrom--endat) value of 45. The first 1.5 seconds of the audio get trimmed off.
-2. The [`<Audio>`](/docs/audio) tag is in a [`<Sequence>`](/docs/sequence) which starts at `30`. The audio only begins playing at the 1.0 second timeline mark at the 1.5 second audio position.
-3. The [`<Audio>`](/docs/audio) has a [`playbackRate`](/docs/audio#playbackrate) of `2`. The audio gets sped up by 2x, but the starting position and start offset is not affected.
-4. The composition is 60 frames long, so the audio must stop at the 3.5 second mark:
- > (comp_duration - offset) \* playback_rate + start_from
- > (60 - 30) \* 2 + 45 => frame 105 or the 3.5 second mark
-5. Result: The section of 1.5sec - 3.5sec gets cut out of the audio and is played in the Remotion timeline between frames 30 and 59 at 2x speed.
+<TableOfContents />
## See also
- [Importing assets](/docs/assets)
-- [Audio visualization](/docs/audio-visualization)
+- [Audio visualization](/docs/audio/visualization)
- [`<Audio />`](/docs/audio) tag
diff --git a/packages/docs/docs/visualize-audio.mdx b/packages/docs/docs/visualize-audio.mdx
index 5c4d7313d2..d2bf9b2a66 100644
--- a/packages/docs/docs/visualize-audio.mdx
+++ b/packages/docs/docs/visualize-audio.mdx
@@ -149,7 +149,7 @@ const amplitudes = frequencyData.map((value) => {
## See also
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/media-utils/src/visualize-audio.ts)
-- [Audio visualization](/docs/audio-visualization)
+- [Audio visualization](/docs/audio/visualization)
- [`useAudioData()`](/docs/use-audio-data)
- [`getAudioData()`](/docs/get-audio-data)
- [`<Audio/>`](/docs/audio)
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index 3acfc0a5d5..51e5dc7214 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -751,11 +751,9 @@ module.exports = {
'assets',
'layers',
'transitioning',
- 'using-audio',
'fonts',
'measuring',
'using-randomness',
- 'audio-visualization',
'noise-visualization',
'animation-math',
],
@@ -776,6 +774,27 @@ module.exports = {
'video-vs-offthreadvideo',
],
},
+ {
+ type: 'category',
+ label: 'Audio',
+ link: {
+ type: 'doc',
+ id: 'using-audio',
+ },
+ items: [
+ 'audio/importing',
+ 'audio/trimming',
+ 'audio/delaying',
+ 'audio/volume',
+ 'audio/muting',
+ 'audio/speed',
+ 'audio/pitch',
+ 'audio/from-video',
+ 'audio/visualization',
+ 'audio/exporting',
+ 'audio/order-of-operations',
+ ],
+ },
{
type: 'category',
label: 'Parameterized videos',
diff --git a/packages/docs/src/components/AvailableFrom.tsx b/packages/docs/src/components/AvailableFrom.tsx
index 13ecb248de..ba825e5799 100644
--- a/packages/docs/src/components/AvailableFrom.tsx
+++ b/packages/docs/src/components/AvailableFrom.tsx
@@ -9,6 +9,7 @@ const link: React.CSSProperties = {
const label: React.CSSProperties = {
fontSize: '0.9em',
+ fontFeatureSettings: "'ss03' on",
border: '1px solid var(--ifm-color-emphasis-300)',
color: 'var(--ifm-color-emphasis-600)',
fontFamily: 'GTPlanar',
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index 0dd7430573..a3a31314af 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -242,15 +242,6 @@ export const articles = [
noAi: false,
slug: 'get-help',
},
- {
- id: 'audio-visualization',
- title: 'Audio visualization',
- relativePath: 'docs/audio-visualization.mdx',
- compId: 'articles-docs-audio-visualization',
- crumb: 'Techniques',
- noAi: false,
- slug: 'audio-visualization',
- },
{
id: 'audio',
title: '<Audio>',
@@ -260,6 +251,105 @@ export const articles = [
noAi: false,
slug: 'audio',
},
+ {
+ id: 'delaying',
+ title: 'Delaying Audio',
+ relativePath: 'docs/audio/delaying.mdx',
+ compId: 'articles-docs-audio-delaying',
+ crumb: 'Audio',
+ noAi: false,
+ slug: 'audio/delaying',
+ },
+ {
+ id: 'exporting',
+ title: 'Exporting Audio',
+ relativePath: 'docs/audio/exporting.mdx',
+ compId: 'articles-docs-audio-exporting',
+ crumb: 'Audio',
+ noAi: false,
+ slug: 'audio/exporting',
+ },
+ {
+ id: 'from-video',
+ title: 'Use Audio from video',
+ relativePath: 'docs/audio/from-video.mdx',
+ compId: 'articles-docs-audio-from-video',
+ crumb: 'Audio',
+ noAi: false,
+ slug: 'audio/from-video',
+ },
+ {
+ id: 'importing',
+ title: 'Importing Audio',
+ relativePath: 'docs/audio/importing.mdx',
+ compId: 'articles-docs-audio-importing',
+ crumb: 'Audio',
+ noAi: false,
+ slug: 'audio/importing',
+ },
+ {
+ id: 'muting',
+ title: 'Muting Audio',
+ relativePath: 'docs/audio/muting.mdx',
+ compId: 'articles-docs-audio-muting',
+ crumb: 'Audio',
+ noAi: false,
+ slug: 'audio/muting',
+ },
+ {
+ id: 'order-of-operations',
+ title: 'Order of Operations',
+ relativePath: 'docs/audio/order-of-operations.mdx',
+ compId: 'articles-docs-audio-order-of-operations',
+ crumb: 'Audio',
+ noAi: false,
+ slug: 'audio/order-of-operations',
+ },
+ {
+ id: 'pitch',
+ title: 'Controlling Pitch',
+ relativePath: 'docs/audio/pitch.mdx',
+ compId: 'articles-docs-audio-pitch',
+ crumb: 'Audio',
+ noAi: false,
+ slug: 'audio/pitch',
+ },
+ {
+ id: 'speed',
+ title: 'Controlling playback speed',
+ relativePath: 'docs/audio/speed.mdx',
+ compId: 'articles-docs-audio-speed',
+ crumb: 'Audio',
+ noAi: false,
+ slug: 'audio/speed',
+ },
+ {
+ id: 'trimming',
+ title: 'Trimming Audio',
+ relativePath: 'docs/audio/trimming.mdx',
+ compId: 'articles-docs-audio-trimming',
+ crumb: 'Audio',
+ noAi: false,
+ slug: 'audio/trimming',
+ },
+ {
+ id: 'visualization',
+ title: 'Audio Visualization',
+ relativePath: 'docs/audio/visualization.mdx',
+ compId: 'articles-docs-audio-visualization',
+ crumb: 'Audio',
+ noAi: false,
+ slug: 'audio/visualization',
+ },
+ {
+ id: 'volume',
+ title: 'Controlling Volume',
+ relativePath: 'docs/audio/volume.mdx',
+ compId: 'articles-docs-audio-volume',
+ crumb: 'Audio',
+ noAi: false,
+ slug: 'audio/volume',
+ },
{
id: 'audio-buffer-to-data-url',
title: 'audioBufferToDataUrl()',
diff --git a/packages/docs/static/generated/articles-docs-audio-delaying.png b/packages/docs/static/generated/articles-docs-audio-delaying.png
new file mode 100644
index 0000000000..75a268fb82
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-audio-delaying.png differ
diff --git a/packages/docs/static/generated/articles-docs-audio-exporting.png b/packages/docs/static/generated/articles-docs-audio-exporting.png
new file mode 100644
index 0000000000..221d26a4c2
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-audio-exporting.png differ
diff --git a/packages/docs/static/generated/articles-docs-audio-from-video.png b/packages/docs/static/generated/articles-docs-audio-from-video.png
new file mode 100644
index 0000000000..464803af15
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-audio-from-video.png differ
diff --git a/packages/docs/static/generated/articles-docs-audio-importing.png b/packages/docs/static/generated/articles-docs-audio-importing.png
new file mode 100644
index 0000000000..69ec24b649
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-audio-importing.png differ
diff --git a/packages/docs/static/generated/articles-docs-audio-muting.png b/packages/docs/static/generated/articles-docs-audio-muting.png
new file mode 100644
index 0000000000..843b403882
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-audio-muting.png differ
diff --git a/packages/docs/static/generated/articles-docs-audio-order-of-operations.png b/packages/docs/static/generated/articles-docs-audio-order-of-operations.png
new file mode 100644
index 0000000000..811e1cfa17
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-audio-order-of-operations.png differ
diff --git a/packages/docs/static/generated/articles-docs-audio-pitch.png b/packages/docs/static/generated/articles-docs-audio-pitch.png
new file mode 100644
index 0000000000..00b4988ecd
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-audio-pitch.png differ
diff --git a/packages/docs/static/generated/articles-docs-audio-speed.png b/packages/docs/static/generated/articles-docs-audio-speed.png
new file mode 100644
index 0000000000..c3faa89dfa
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-audio-speed.png differ
diff --git a/packages/docs/static/generated/articles-docs-audio-trimming.png b/packages/docs/static/generated/articles-docs-audio-trimming.png
new file mode 100644
index 0000000000..b5d741844a
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-audio-trimming.png differ
diff --git a/packages/docs/static/generated/articles-docs-audio-visualization.png b/packages/docs/static/generated/articles-docs-audio-visualization.png
index c23365014d..959949c376 100644
Binary files a/packages/docs/static/generated/articles-docs-audio-visualization.png and b/packages/docs/static/generated/articles-docs-audio-visualization.png differ
diff --git a/packages/docs/static/generated/articles-docs-audio-volume.png b/packages/docs/static/generated/articles-docs-audio-volume.png
new file mode 100644
index 0000000000..c4ca293705
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-audio-volume.png differ
diff --git a/packages/docs/vercel.json b/packages/docs/vercel.json
index 027bed305e..52581dea57 100644
--- a/packages/docs/vercel.json
+++ b/packages/docs/vercel.json
@@ -352,6 +352,11 @@
"destination": "/docs/miscellaneous/chrome-headless-shell",
"permanent": false
},
+ {
+ "source": "/docs/audio-visualization",
+ "destination": "/docs/audio/visualization",
+ "permanent": false
+ },
{
"source": "/recorder",
"destination": "/docs/recorder",
diff --git a/packages/eslint-plugin/src/rules/volume-callback.ts b/packages/eslint-plugin/src/rules/volume-callback.ts
index 717b9ede3c..236a7dcc3e 100644
--- a/packages/eslint-plugin/src/rules/volume-callback.ts
+++ b/packages/eslint-plugin/src/rules/volume-callback.ts
@@ -9,7 +9,7 @@ type Options = [];
type MessageIds = 'VolumeCallback';
const VolumeCallback =
- 'Prefer a callback function for setting the volume: `volume={(f) => interpolate(...)}`. See https://www.remotion.dev/docs/using-audio/#controlling-volume';
+ 'Prefer a callback function for setting the volume: `volume={(f) => interpolate(...)}`. See https://www.remotion.dev/docs/audio/volume';
export default createRule<Options, MessageIds>({
name: 'volume-callback',
diff --git a/packages/renderer/src/options/mute.tsx b/packages/renderer/src/options/mute.tsx
index 71177adada..2ed109941b 100644
--- a/packages/renderer/src/options/mute.tsx
+++ b/packages/renderer/src/options/mute.tsx
@@ -11,7 +11,7 @@ export const mutedOption = {
cliFlag,
description: () => <>The Audio of the video will be omitted.</>,
ssrName: 'muted',
- docLink: 'https://www.remotion.dev/docs/using-audio/#muted-property',
+ docLink: 'https://www.remotion.dev/docs/audio/muting',
type: false as boolean,
getValue: ({commandLine}) => {
// we set in minimist `muted` default as null