Skip to content

🎥 Make videos programmatically with React

refactor: format all code blocks

Frenco14de4ddc9b93
diff --git a/packages/docs/docs/animating-properties.md b/packages/docs/docs/animating-properties.md
index dae6ceb9f1..c242bfc7c3 100644
--- a/packages/docs/docs/animating-properties.md
+++ b/packages/docs/docs/animating-properties.md
@@ -8,21 +8,23 @@ Let's start with a simple example, let's say we want to create a fade in animati
If we want to fade the text in over 20 frames, we need to gradually change the `opacity` style over time so that it goes from 0 to 1.
-```tsx twoslash {3, 10}
-import { useCurrentFrame } from "remotion"
+```tsx twoslash {3, 11}
+import {useCurrentFrame} from 'remotion'
// ---cut---
export const MyVideo = () => {
- const frame = useCurrentFrame();
+ const frame = useCurrentFrame()
- const opacity = frame >= 20 ? 1 : (frame / 20);
+ const opacity = frame >= 20 ? 1 : (frame / 20)
return (
- <div style={{
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
- opacity: opacity
- }}>
+ <div
+ style={{
+ flex: 1,
+ justifyContent: 'center',
+ alignItems: 'center',
+ opacity: opacity,
+ }}
+ >
Hello World!
</div>
)
@@ -39,21 +41,25 @@ The function takes 4 arguments:
3. The range of values that you want to map the input to
4. Optional settings
-```tsx twoslash {5, 12}
-import {useCurrentFrame, interpolate} from 'remotion';
+```tsx twoslash {5-7, 15}
+import {interpolate, useCurrentFrame} from 'remotion'
export const MyVideo = () => {
- const frame = useCurrentFrame();
+ const frame = useCurrentFrame()
- const opacity = interpolate(frame, [0, 20], [0, 1], {extrapolateRight: 'clamp'});
+ const opacity = interpolate(frame, [0, 20], [0, 1], {
+ extrapolateRight: 'clamp',
+ })
return (
- <div style={{
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
- opacity: opacity
- }}>
+ <div
+ style={{
+ flex: 1,
+ justifyContent: 'center',
+ alignItems: 'center',
+ opacity: opacity,
+ }}
+ >
Hello World!
</div>
)
@@ -66,26 +72,28 @@ In this example, we map the frames 0 to 20 to their opacity values `(0, 0.05, 0.
Spring animations are beautiful way to put things into motion and make them natural. Remotion includes a helper function to make spring animations easy! This time, let's animate the scale of the text.
-```tsx twoslash {6-11, 19}
-import {useCurrentFrame, useVideoConfig, spring} from 'remotion';
+```tsx twoslash {6-11, 21}
+import {spring, useCurrentFrame, useVideoConfig} from 'remotion'
export const MyVideo = () => {
- const frame = useCurrentFrame();
- const {fps} = useVideoConfig();
+ const frame = useCurrentFrame()
+ const {fps} = useVideoConfig()
const scale = spring({
fps,
from: 0,
to: 1,
- frame
- });
+ frame,
+ })
return (
- <div style={{
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
- }}>
+ <div
+ style={{
+ flex: 1,
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}
+ >
<div style={{transform: `scale(${scale})`}}>Hello World!</div>
</div>
)
diff --git a/packages/docs/docs/audio-visualization.md b/packages/docs/docs/audio-visualization.md
index 5701735b5c..58c0081cf4 100644
--- a/packages/docs/docs/audio-visualization.md
+++ b/packages/docs/docs/audio-visualization.md
@@ -26,17 +26,17 @@ Using the [`visualizeAudio()`](/docs/visualize-audio) API, you can get an audio
Refer to the documentation of the above mentioned functions to learn more.
```tsx twoslash
-import {useCurrentFrame, useVideoConfig, Audio} from 'remotion';
-import {useAudioData, visualizeAudio} from '@remotion/media-utils';
-import music from './music.mp3';
+import {Audio, useCurrentFrame, useVideoConfig} from 'remotion'
+import {useAudioData, visualizeAudio} from '@remotion/media-utils'
+import music from './music.mp3'
export const MyComponent: React.FC = () => {
- const frame = useCurrentFrame();
- const {width, height, fps} = useVideoConfig();
- const audioData = useAudioData(music);
+ const frame = useCurrentFrame()
+ const {width, height, fps} = useVideoConfig()
+ const audioData = useAudioData(music)
if (!audioData) {
- return null;
+ return null
}
const visualization = visualizeAudio({
@@ -44,17 +44,17 @@ export const MyComponent: React.FC = () => {
frame,
audioData,
numberOfSamples: 16,
- }); // [0.22, 0.1, 0.01, 0.01, 0.01, 0.02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
+ }) // [0.22, 0.1, 0.01, 0.01, 0.01, 0.02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
// Render a bar chart for each frequency, the higher the amplitude,
// the longer the bar
return (
<div>
- <Audio src={music}/>
- {visualization.map(v => {
+ <Audio src={music} />
+ {visualization.map((v) => {
return (
<div style={{width: 1000 * v, height: 15, backgroundColor: 'blue'}} />
- );
+ )
})}
</div>
)
diff --git a/packages/docs/docs/audio.md b/packages/docs/docs/audio.md
index 44b092b632..ad21e39343 100644
--- a/packages/docs/docs/audio.md
+++ b/packages/docs/docs/audio.md
@@ -18,7 +18,7 @@ The component also accepts a `volume` props which allows you to control the volu
`<Audio>` has two more helper props: `startFrom` and `endAt` for defining the start frame and end frame. Both are optional and do not get forwarded to the native `<audio>` element but tell Remotion which portion of the audio should be included.
```tsx twoslash
-import {Audio} from 'remotion';
+import {Audio} from 'remotion'
import audio from './audio.mp3'
export const MyVideo = () => {
diff --git a/packages/docs/docs/bundle.md b/packages/docs/docs/bundle.md
index a0189a09f0..1c7b5c9a72 100644
--- a/packages/docs/docs/bundle.md
+++ b/packages/docs/docs/bundle.md
@@ -12,9 +12,9 @@ const bundle: (
entryPoint: string,
onProgressUpdate?: (progress: number) => void,
options?: {
- webpackOverride?: WebpackOverrideFn;
- outDir?: string;
- enableCaching?: boolean;
+ webpackOverride?: WebpackOverrideFn
+ outDir?: string
+ enableCaching?: boolean
}
) => Promise<string>
```
@@ -46,11 +46,11 @@ _optional_
A function to override the webpack config reducer-style. Takes a function which gives you the current webpack config which you can transform and return a modified version of it. For example:
```ts twoslash
-import {WebpackOverrideFn} from "remotion";
+import {WebpackOverrideFn} from 'remotion'
// ---cut---
const webpackOverride: WebpackOverrideFn = (webpackConfig) => {
return {
- ...webpackConfig
+ ...webpackConfig,
// Override properties
}
}
diff --git a/packages/docs/docs/composition.md b/packages/docs/docs/composition.md
index 633762f24a..d76419e79e 100644
--- a/packages/docs/docs/composition.md
+++ b/packages/docs/docs/composition.md
@@ -46,8 +46,8 @@ export const MyComp = () => <></>
// @filename: index.tsx
// ---cut---
-import {Composition} from 'remotion';
-import {MyComp} from './MyComp';
+import {Composition} from 'remotion'
+import {MyComp} from './MyComp'
export const MyVideo = () => {
return (
@@ -61,7 +61,7 @@ export const MyVideo = () => {
durationInFrames={3 * 30}
/>
</>
- );
+ )
}
```
@@ -80,7 +80,7 @@ export const MyVideo = () => {
durationInFrames={3 * 30}
/>
</>
- );
+ )
}
```
diff --git a/packages/docs/docs/config.mdx b/packages/docs/docs/config.mdx
index 6f2616d3a5..47a22db432 100644
--- a/packages/docs/docs/config.mdx
+++ b/packages/docs/docs/config.mdx
@@ -10,11 +10,11 @@ These options will apply to CLI commands such as `npm start` and `npm run build`
You can control several behaviors of Remotion here.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
-Config.Rendering.setConcurrency(8);
-Config.Output.setPixelFormat('yuv444p');
-Config.Output.setCodec('h265');
+Config.Rendering.setConcurrency(8)
+Config.Output.setPixelFormat('yuv444p')
+Config.Output.setCodec('h265')
```
## Bundling
@@ -26,15 +26,15 @@ _Available from Version 1.1._
Allows you to insert your custom Webpack config. [See the page about custom Webpack configs](/docs/webpack) for more information.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
// Return a new Webpack configuration
return {
...currentConfiguration,
// new configuration
- };
-});
+ }
+})
```
### setCachingEnabled()
@@ -44,9 +44,9 @@ _Available from Version 2.0._
Enable or disable webpack caching. Default is `true` which will make the Webpack step in the first run a bit slower but will massively speed up subsequent runs. We recommend to keep this option enabled in all cases and encourage to report issues on Github if you encounter some.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Bundling.setCachingEnabled(false);
+Config.Bundling.setCachingEnabled(false)
```
The [command line flag](/docs/cli#--bundle-cache) `--bundle-cache` will take precedence over this option.
@@ -58,9 +58,9 @@ By default, Remotion will try to find a free port.
If you specify a port, but it's not available, Remotion will throw an error.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Bundling.setPort(3003);
+Config.Bundling.setPort(3003)
```
The [command line flag](/docs/cli#--port) `--port` will take precedence over this option.
@@ -80,9 +80,9 @@ Acceptable values:
- `verbose`: All of the above, plus browser logs and other debug info.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Log.setLevel('verbose');
+Config.Log.setLevel('verbose')
```
The [command line flag](/docs/cli#--log) `--log` will take precedence over this option.
@@ -96,9 +96,9 @@ _Available from Version 2.1.10._
Set how many tracks are being displayed in the timeline at most. This does not affect your video, just the amount of tracks shown when previewing. Default `15`.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Preview.setMaxTimelineTracks(20);
+Config.Preview.setMaxTimelineTracks(20)
```
## Puppeteer
@@ -110,9 +110,9 @@ _Available from Version 1.5._
Set a custom Chrome or Chromium executable path. By default Remotion will try to find an existing version of Chrome on your system and if not found, it will download one. This flag is useful if you don't have Chrome installed in a standard location and you want to prevent downloading an additional browser or need [support for the H264 codec](/docs/video#codec-support).
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Puppeteer.setBrowserExecutable('/usr/bin/google-chrome-stable');
+Config.Puppeteer.setBrowserExecutable('/usr/bin/google-chrome-stable')
```
The [command line flag](/docs/cli#--browser-executable) `--browser-executable` will take precedence over this option.
@@ -125,7 +125,7 @@ Sets how many Puppeteer instances will work on rendering your video in parallel.
Default: `null`, meaning **half of the threads** available on your CPU.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
Config.Rendering.setConcurrency(8)
```
@@ -147,7 +147,7 @@ Determines which in which image format to render the frames. Either:
- `none` - don't render images, just calculate audio information (available from v2.0)
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
Config.Rendering.setImageFormat('png')
```
@@ -161,17 +161,17 @@ _Available from Version 2.0._
Pass a number to render a still frame or a tuple to render a subset of a video. The frame sequence is zero-indexed.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Rendering.setFrameRange(90); // To render only the 91st frame
+Config.Rendering.setFrameRange(90) // To render only the 91st frame
```
or
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Rendering.setFrameRange([0, 20]); // Render a video only containing the first 21 frames
+Config.Rendering.setFrameRange([0, 20]) // Render a video only containing the first 21 frames
```
The [command line flag](/docs/cli#--frames) `--frames` will take precedence over this option.
@@ -181,9 +181,9 @@ The [command line flag](/docs/cli#--frames) `--frames` will take precedence over
The JPEG quality of each frame. Must be a number between 0 and 100. Will not work if you render PNG frames. [Default: 80](https://github.com/chromium/chromium/blob/99314be8152e688bafbbf9a615536bdbb289ea87/headless/lib/browser/protocol/headless_handler.cc#L32).
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Rendering.setQuality(90);
+Config.Rendering.setQuality(90)
```
The [command line flag](/docs/cli#--quality) `--quality` will take precedence over this option.
@@ -193,7 +193,7 @@ The [command line flag](/docs/cli#--quality) `--quality` will take precedence ov
Set a custom location for a [`.env`](https://www.npmjs.com/package/dotenv) file. You can specify an absolute path or a relative path in which case it gets resolved based on the current working directory.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
Config.Rendering.setDotEnvLocation('.my-env')
```
@@ -207,7 +207,7 @@ The [command line flag](/docs/cli#--env-file) `--env-file` will take precedence
Set this to `false` to prevent overwriting Remotion outputs when they already exists.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
Config.Output.setOverwriteOutput(false)
```
@@ -224,7 +224,7 @@ Controls the pixel format in FFMPEG. [Read more about it here.](https://trac.ffm
Default value: `yuv420p`
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
Config.Output.setPixelFormat('yuv420p')
```
@@ -248,9 +248,9 @@ Choose one of the supported codecs: `h264` _(default)_, `h265`, `vp8`, `vp9`.
- `mkv` will export using H264 codec, MKV container format and WAV audio codec. _(available from v2.1.12)_
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Output.setCodec('h265');
+Config.Output.setCodec('h265')
```
The [command line flag](/docs/cli#--codec) `--codec` will take precedence over this option.
@@ -267,9 +267,9 @@ See [here](https://video.stackexchange.com/a/14715) for explanation of possible
Default: `hq`
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Output.setProResProfile('4444');
+Config.Output.setProResProfile('4444')
```
The [command line flag](/docs/cli#--prores-profile) `--prores-profile` will take precedence over this option.
@@ -283,9 +283,9 @@ _Available from Version 1.4._
Set to true if you want to output an image sequence instead of a video.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Output.setImageSequence(true);
+Config.Output.setImageSequence(true)
```
The [command line flag](/docs/cli#--sequence) `--sequence` will take precedence over this option.
@@ -297,9 +297,9 @@ _Deprecated_. Use `setCodec()` and `setImageSequence()` instead.
Either `'mp4'` or `'png-sequence'`.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Output.setOutputFormat('mp4');
+Config.Output.setOutputFormat('mp4')
```
The [command line flags](/docs/cli) `--sequence` and `--codec` will take precedence over this option.
@@ -326,9 +326,9 @@ The range is exponential, so increasing the CRF value +6 results in roughly half
Choose the highest CRF value that still provides an acceptable quality. If the output looks good, then try a higher value. If it looks bad, choose a lower value.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
// ---cut---
-Config.Output.setCrf(16);
+Config.Output.setCrf(16)
```
The [command line flag](/docs/cli#--crf) `--crf` will take precedence over this option.
diff --git a/packages/docs/docs/data-fetching.md b/packages/docs/docs/data-fetching.md
index dcfd6fc03a..a3ed6e17d0 100644
--- a/packages/docs/docs/data-fetching.md
+++ b/packages/docs/docs/data-fetching.md
@@ -10,24 +10,24 @@ One of the most groundbreaking things about Remotion is that you can fetch data
There are two functions, [`delayRender`](/docs/delay-render) and [`continueRender`](/docs/continue-render), which you can use to tell Remotion to not yet render the frame. If you want to asynchronously render a frame, you should call `delayRender()` as soon as possible, before the window `onload` event is fired. The function returns a handle that you need to give Remotion the green light to render later using `continueRender()`.
```tsx twoslash
-import {useEffect, useState} from 'react';
-import {continueRender, delayRender} from 'remotion';
+import {useEffect, useState} from 'react'
+import {continueRender, delayRender} from 'remotion'
export const MyVideo = () => {
- const [data, setData] = useState(null);
- const [handle] = useState(() => delayRender());
+ const [data, setData] = useState(null)
+ const [handle] = useState(() => delayRender())
const fetchData = async () => {
- const response = await fetch('http://example.com/api');
- const json = await response.json();
- setData(json);
+ const response = await fetch('http://example.com/api')
+ const json = await response.json()
+ setData(json)
- continueRender(handle);
+ continueRender(handle)
}
useEffect(() => {
- fetchData();
- }, []);
+ fetchData()
+ }, [])
return (
<div>
@@ -35,9 +35,8 @@ export const MyVideo = () => {
<div>This video has data from an API! {JSON.stringify(data)}</div>
) : null}
</div>
- );
+ )
}
-
```
## Caching
diff --git a/packages/docs/docs/delay-render.md b/packages/docs/docs/delay-render.md
index 2c504b8266..d22a0747b0 100644
--- a/packages/docs/docs/delay-render.md
+++ b/packages/docs/docs/delay-render.md
@@ -23,34 +23,32 @@ This method is useful if you for example want to call an API to fetch data befor
## Example
```tsx twoslash
-import {useEffect, useState} from 'react';
-import {continueRender, delayRender} from 'remotion';
+import {useEffect, useState} from 'react'
+import {continueRender, delayRender} from 'remotion'
export const MyVideo = () => {
- const [data, setData] = useState(null);
- const [handle] = useState(() => delayRender());
+ const [data, setData] = useState(null)
+ const [handle] = useState(() => delayRender())
const fetchData = async () => {
- const response = await fetch('http://example.com/api');
- const json = await response.json();
- setData(json);
+ const response = await fetch('http://example.com/api')
+ const json = await response.json()
+ setData(json)
- continueRender(handle);
+ continueRender(handle)
}
useEffect(() => {
- fetchData();
- }, []);
-
+ fetchData()
+ }, [])
return (
<div>
{data ? (
<div>This video has data from an API! {JSON.stringify(data)}</div>
) : null}
</div>
- );
+ )
}
-
```
## See also
diff --git a/packages/docs/docs/dynamic-import.md b/packages/docs/docs/dynamic-import.md
index 6fec280e91..2a6c902232 100644
--- a/packages/docs/docs/dynamic-import.md
+++ b/packages/docs/docs/dynamic-import.md
@@ -26,13 +26,13 @@ my-video/
Note that the following pattern doesn't work:
```tsx twoslash
-import {Img, useCurrentFrame} from 'remotion';
+import {Img, useCurrentFrame} from 'remotion'
export const DynamicImports: React.FC = () => {
- const frame = useCurrentFrame();
+ const frame = useCurrentFrame()
const img = './assets/image' + frame + '.png'
- return <Img src={require(img)} />;
-};
+ return <Img src={require(img)} />
+}
```
```bash
@@ -42,12 +42,12 @@ Error: Cannot find module './image0.png'
However the following example **does** work:
```tsx twoslash
-import {Img, useCurrentFrame} from 'remotion';
+import {Img, useCurrentFrame} from 'remotion'
export const DynamicImports: React.FC = () => {
- const frame = useCurrentFrame();
- return <Img src={require('./assets/image' + frame + '.png')} />;
-};
+ const frame = useCurrentFrame()
+ return <Img src={require('./assets/image' + frame + '.png')} />
+}
```
Webpack needs to figure out which assets it should bundle and cannot do it in the first example. However, it is smart enough to do so if you place your expression inside the `require()` or `import()` statement. In this case, Webpack will automatically bundle all `.png` files in the `assets/image` folder even if the asset is never used. Therefore you have to be careful to not bundle too many assets.
@@ -59,11 +59,11 @@ Please read [the Webpack documentation page](https://webpack.js.org/api/module-m
Let's imagine a scenario where the asset that should be imported is completely unknown and will be read at runtime, for example through an [input prop](/docs/get-input-props):
```tsx twoslash
-import {Img, getInputProps} from 'remotion';
+import {getInputProps, Img} from 'remotion'
const DynamicAsset: React.FC = () => {
const inputProps = getInputProps() // {"imageSrc": "./assets/img0.png"}
- return <Img src={require(inputProps.imageSrc)}/>
+ return <Img src={require(inputProps.imageSrc)} />
}
```
@@ -71,12 +71,12 @@ This cannot work because Webpack has no ideas which assets it has to bundle. The
Like above, you can force Webpack to bundle the whole assets folder by putting an expression inside the `require()` statement:
```tsx twoslash
-import {Img, getInputProps} from 'remotion';
+import {getInputProps, Img} from 'remotion'
const DynamicAsset: React.FC = () => {
const inputProps = getInputProps() // {"imageSrc": "img0.png"}
// Works!
- return <Img src={require('./assets/' + inputProps.imageSrc)}/>
+ return <Img src={require('./assets/' + inputProps.imageSrc)} />
}
```
@@ -91,10 +91,10 @@ You can use the following workaround that relies on the fact that Remotion creat
3. Rely on the fact that the asset is available via the static HTTP server. Since you only want this during rendering, use the `process.env.NODE_ENV === 'production'` statement to differentiate between development and rendering.
```tsx twoslash
-import {Img, getInputProps} from 'remotion';
+import {getInputProps, Img} from 'remotion'
export const DynamicAsset: React.FC = () => {
- const inputProps = getInputProps(); // {"imageSrc": "assets/img0.png"}
+ const inputProps = getInputProps() // {"imageSrc": "assets/img0.png"}
return (
<Img
src={
@@ -103,7 +103,7 @@ export const DynamicAsset: React.FC = () => {
: require('./assets/default-asset.png')
}
/>
- );
+ )
}
```
@@ -117,10 +117,10 @@ npx serve --cors ./src
```
```tsx twoslash
-import {Img, getInputProps} from 'remotion';
+import {getInputProps, Img} from 'remotion'
const HttpAsset: React.FC = () => {
- const inputProps = getInputProps(); // {"imageSrc": "assets/img0.png"}
+ const inputProps = getInputProps() // {"imageSrc": "assets/img0.png"}
return <Img src={`http://localhost:5000/${inputProps.imageSrc}`} />
}
```
diff --git a/packages/docs/docs/dynamic-metadata.md b/packages/docs/docs/dynamic-metadata.md
index 3df6c20b50..1e1e1b2083 100644
--- a/packages/docs/docs/dynamic-metadata.md
+++ b/packages/docs/docs/dynamic-metadata.md
@@ -27,7 +27,7 @@ For example if you have passed `--props='{"hello": "world"}'` as a command line
```tsx twoslash
// It's better to fake type here than to import any
-const getInputProps = () => ({hello: "world"} as const)
+const getInputProps = () => ({hello: 'world'} as const)
// ---cut---
const {hello} = getInputProps()
console.log(hello) // "world"
@@ -38,7 +38,7 @@ You can use this technique to dynamically change the frame rate, dimensions or d
```tsx twoslash
// @include: example-MyComponent
// ---cut---
-import {getInputProps, Composition} from 'remotion';
+import {Composition, getInputProps} from 'remotion'
const inputProps = getInputProps()
@@ -72,23 +72,23 @@ In this example, we fetch the duration of "Big Buck Bunny" and use it to make ou
```tsx twoslash
// @include: example-VideoTesting
-import {useState, useEffect} from "react";
-import {Composition, delayRender, continueRender} from "remotion";
+import {useEffect, useState} from 'react'
+import {Composition, continueRender, delayRender} from 'remotion'
// ---cut---
export const Index: React.FC = () => {
- const [handle] = useState(() => delayRender());
- const [duration, setDuration] = useState(1);
+ const [handle] = useState(() => delayRender())
+ const [duration, setDuration] = useState(1)
useEffect(() => {
- const video = document.createElement('video');
+ const video = document.createElement('video')
video.src =
- 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
+ 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4'
video.onloadedmetadata = () => {
- setDuration(Math.round(video.duration * 30));
- continueRender(handle);
- };
- }, [handle]);
+ setDuration(Math.round(video.duration * 30))
+ continueRender(handle)
+ }
+ }, [handle])
return (
<>
@@ -110,7 +110,7 @@ export const Index: React.FC = () => {
Both `getCompositions()` and `renderFrames()` functions accept an `inputProps` object as a parameter.
```tsx twoslash
-import {getCompositions} from "@remotion/renderer"
+import {getCompositions} from '@remotion/renderer'
const bundled: string = ''
// ---cut---
getCompositions(bundled, {
@@ -121,7 +121,7 @@ getCompositions(bundled, {
```
```tsx twoslash
-import {renderFrames as rf} from "@remotion/renderer"
+import {renderFrames as rf} from '@remotion/renderer'
const renderFrames = (options: Partial<Parameters<typeof rf>[0]>) => {}
// ---cut---
renderFrames({
diff --git a/packages/docs/docs/easing.md b/packages/docs/docs/easing.md
index a626945668..909730fb25 100644
--- a/packages/docs/docs/easing.md
+++ b/packages/docs/docs/easing.md
@@ -53,15 +53,19 @@ import {useCurrentFrame, AbsoluteFill} from 'remotion'
import {interpolate, Easing} from 'remotion';
const MyVideo: React.FC = () => {
- const frame = useCurrentFrame();
+ const frame = useCurrentFrame()
const interpolated = interpolate(frame, [0, 100], [0, 1], {
easing: Easing.bezier(0.8, 0.22, 0.96, 0.65),
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp',
- });
-
+ })
return (
- <AbsoluteFill style={{transform: `scale(${interpolated})`, backgroundColor: 'red'}} />
+ <AbsoluteFill
+ style={{
+ transform: `scale(${interpolated})`,
+ backgroundColor: 'red',
+ }}
+ />
)
}
```
diff --git a/packages/docs/docs/get-audio-data.md b/packages/docs/docs/get-audio-data.md
index dd65090835..dbda8f4a01 100644
--- a/packages/docs/docs/get-audio-data.md
+++ b/packages/docs/docs/get-audio-data.md
@@ -29,12 +29,12 @@ A string pointing to an audio asset.
```ts twoslash
// @module: ESNext
// @target: ESNext
-import {Audio} from "remotion";
+import {Audio} from "remotion"
// ---cut---
-import {getAudioData} from '@remotion/media-utils';
-import music from './music.mp3';
+import {getAudioData} from '@remotion/media-utils'
+import music from './music.mp3'
-await getAudioData(music); /* {
+await getAudioData(music) /* {
channelWaveforms: [Float32Array(4410000), Float32Array(4410000)],
sampleRate: 44100,
durationInSeconds: 100.0000,
@@ -42,7 +42,7 @@ await getAudioData(music); /* {
resultId: "0.432878981",
isRemote: false
} */
-await getAudioData('https://example.com/remote-audio.aac'); /* {
+await getAudioData('https://example.com/remote-audio.aac') /* {
channelWaveforms: [Float32Array(4800000)],
sampleRate: 48000,
durationInSeconds: 100.0000,
diff --git a/packages/docs/docs/get-audio-duration.md b/packages/docs/docs/get-audio-duration.md
index fd8e3367c0..8e0b35e7ff 100644
--- a/packages/docs/docs/get-audio-duration.md
+++ b/packages/docs/docs/get-audio-duration.md
@@ -24,9 +24,9 @@ A string pointing to an audio asset
// @target: ESNext
import {Audio} from 'remotion'
// ---cut---
-import {getAudioDuration} from '@remotion/media-utils';
-import music from './music.mp3';
+import {getAudioDuration} from '@remotion/media-utils'
+import music from './music.mp3'
-await getAudioDuration(music); // 127.452
-await getAudioDuration('https://example.com/remote-audio.aac'); // 50.24
+await getAudioDuration(music) // 127.452
+await getAudioDuration('https://example.com/remote-audio.aac') // 50.24
```
diff --git a/packages/docs/docs/get-compositions.md b/packages/docs/docs/get-compositions.md
index cab2fb6488..b90cff59b7 100644
--- a/packages/docs/docs/get-compositions.md
+++ b/packages/docs/docs/get-compositions.md
@@ -8,10 +8,13 @@ _Part of the `@remotion/renderer` package._
Gets the compositions defined in a Remotion project based on a webpack bundle. Spins up a browser with Puppeteer and evaluates the Remotion root.
```ts
-const getCompositions: (bundle: string, options: {
- inputProps?: object | null;
- browserInstance?: puppeteer.Browser;
-}) => Promise<TComposition[]>
+const getCompositions: (
+ bundle: string,
+ options: {
+ inputProps?: object | null
+ browserInstance?: puppeteer.Browser
+ }
+) => Promise<TComposition[]>
```
## Arguments
@@ -45,18 +48,18 @@ Returns a promise that resolves to an array of available compositions. Example v
```ts twoslash
[
{
- id: "HelloWorld",
+ id: 'HelloWorld',
width: 1920,
height: 1080,
fps: 30,
},
{
- id: "Title",
+ id: 'Title',
width: 1080,
height: 1080,
fps: 30,
},
-];
+]
```
## See also
diff --git a/packages/docs/docs/get-input-props.md b/packages/docs/docs/get-input-props.md
index 6b2d4f38ab..af3e853d1f 100644
--- a/packages/docs/docs/get-input-props.md
+++ b/packages/docs/docs/get-input-props.md
@@ -24,7 +24,7 @@ npx remotion render --props='{"hello": "world"}' src/index.tsx my-composition ou
You can then access the props in JavaScript:
```tsx twoslash
-const getInputProps = () => ({hello: "world"} as const)
+const getInputProps = () => ({hello: 'world'} as const)
// ---cut---
const {hello} = getInputProps() // "world"
```
diff --git a/packages/docs/docs/get-video-metadata.md b/packages/docs/docs/get-video-metadata.md
index a50de49e94..fdeb554c94 100644
--- a/packages/docs/docs/get-video-metadata.md
+++ b/packages/docs/docs/get-video-metadata.md
@@ -30,17 +30,17 @@ A string pointing to an asset.
// @target: ESNext
import {Audio} from 'remotion'
// ---cut---
-import {getVideoMetadata} from '@remotion/media-utils';
-import video from '../video.mp4';
+import {getVideoMetadata} from '@remotion/media-utils'
+import video from '../video.mp4'
-await getVideoMetadata(video); /* {
+await getVideoMetadata(video) /* {
durationInSeconds: 100.00,
width: 1280,
height: 720,
aspectRatio: 1.77777778,
isRemote: false
} */
-await getVideoMetadata('https://example.com/remote-audio.webm'); /* {
+await getVideoMetadata('https://example.com/remote-audio.webm') /* {
durationInSeconds: 40.213,
width: 1920,
height: 1080,
diff --git a/packages/docs/docs/get-waveform-portion.md b/packages/docs/docs/get-waveform-portion.md
index 180ae2f8d5..a03fe5e72e 100644
--- a/packages/docs/docs/get-waveform-portion.md
+++ b/packages/docs/docs/get-waveform-portion.md
@@ -32,10 +32,10 @@ An object with the following arguments:
// @target: ESNext
import {Audio} from 'remotion'
// ---cut---
-import {getAudioData, getWaveformPortion} from '@remotion/media-utils';
-import music from './music.mp3';
+import {getAudioData, getWaveformPortion} from '@remotion/media-utils'
+import music from './music.mp3'
-const audioData = await getAudioData(music); /* {
+const audioData = await getAudioData(music) /* {
channelWaveforms: [Float32Array(4410000), Float32Array(4410000)],
sampleRate: 44100,
durationInSeconds: 100.0000,
diff --git a/packages/docs/docs/gif.md b/packages/docs/docs/gif.md
index 5d756170a5..4f657d68a6 100644
--- a/packages/docs/docs/gif.md
+++ b/packages/docs/docs/gif.md
@@ -51,12 +51,12 @@ Allows to pass in custom CSS styles.
## Example
```tsx twoslash
-import {useVideoConfig} from "remotion";
+import {useVideoConfig} from 'remotion'
// ---cut---
-import {Gif} from '@remotion/gif';
+import {Gif} from '@remotion/gif'
export const MyComponent: React.FC = () => {
- const {width, height} = useVideoConfig();
+ const {width, height} = useVideoConfig()
return (
<Gif
diff --git a/packages/docs/docs/iframe.md b/packages/docs/docs/iframe.md
index 7cdfca52a9..ee876315ce 100644
--- a/packages/docs/docs/iframe.md
+++ b/packages/docs/docs/iframe.md
@@ -9,14 +9,11 @@ The difference is that if you use the component from Remotion, that Remotion wil
## Example
```tsx twoslash
-import {IFrame} from 'remotion';
+import {IFrame} from 'remotion'
export const MyComp: React.FC = () => {
- return (
- <IFrame src="https://remotion.dev" />
- )
+ return <IFrame src="https://remotion.dev" />
}
-
```
## See also
diff --git a/packages/docs/docs/img.md b/packages/docs/docs/img.md
index f07dce4211..774ced850c 100644
--- a/packages/docs/docs/img.md
+++ b/packages/docs/docs/img.md
@@ -9,15 +9,12 @@ The difference is that if you use the component from Remotion, that Remotion wil
## Example
```tsx twoslash
-import {Img} from 'remotion';
+import {Img} from 'remotion'
import hi from './hi.png'
export const MyComp: React.FC = () => {
- return (
- <Img src={hi} />
- )
+ return <Img src={hi} />
}
-
```
## See also
diff --git a/packages/docs/docs/importing-assets.md b/packages/docs/docs/importing-assets.md
index 157bb8d77c..64de8c4f4d 100644
--- a/packages/docs/docs/importing-assets.md
+++ b/packages/docs/docs/importing-assets.md
@@ -15,13 +15,11 @@ Remotion allows you to include several types of files in your project:
Require images using an `import` statement and pass them to the [`<Img/>`](/docs/img) tag.
```tsx twoslash
-import {Img} from 'remotion';
+import {Img} from 'remotion'
import logo from './logo.png'
export const MyComp: React.FC = () => {
- return (
- <Img src={logo} />
- )
+ return <Img src={logo} />
}
```
@@ -30,7 +28,7 @@ export const MyComp: React.FC = () => {
If you have a series of images, for example exported from another program like After Effects or Rotato, you can use a dynamic `require` statement to import the images as they are needed.
```tsx twoslash
-import {useCurrentFrame} from 'remotion';
+import {useCurrentFrame} from 'remotion'
/*
Assuming your file structure is:
@@ -42,12 +40,10 @@ import {useCurrentFrame} from 'remotion';
*/
const MyComp: React.FC = () => {
- const frame = useCurrentFrame();
- const src = require('./assets/frame' + frame + '.png');
+ const frame = useCurrentFrame()
+ const src = require('./assets/frame' + frame + '.png')
- return (
- <img src={src} />
- )
+ return <img src={src} />
}
```
@@ -60,13 +56,11 @@ Avoid writing a require statement that requires a file that doesn't exist. If yo
Import your files using an import statement. Use the [`<Video />`/docs/video) component to keep the timeline and your video in sync.
```tsx twoslash
-import {Video} from 'remotion';
+import {Video} from 'remotion'
import vid from './vid.webm'
export const MyComp: React.FC = () => {
- return (
- <Video src={vid} />
- );
+ return <Video src={vid} />
}
```
@@ -77,13 +71,11 @@ Be aware that if you are rendering using Chromium (as opposed to Chrome), the co
Import your audio using an `import` statement and pass it to the [`<Audio/ >`](/docs/audio) component.
```tsx twoslash
-import {Audio} from 'remotion';
+import {Audio} from 'remotion'
import tune from './tune.mp3'
export const MyComp: React.FC = () => {
- return (
- <Audio src={tune} />
- );
+ return <Audio src={tune} />
}
```
diff --git a/packages/docs/docs/interpolate-colors.md b/packages/docs/docs/interpolate-colors.md
index c3d2a26aef..b786807338 100644
--- a/packages/docs/docs/interpolate-colors.md
+++ b/packages/docs/docs/interpolate-colors.md
@@ -26,19 +26,19 @@ In this example, we are interpolating colors from red to yellow. At frame 0 (the
Using the following snippet, we can calculate the current color for any frame:
```tsx twoslash
-import {useCurrentFrame, interpolateColors} from 'remotion';
+import {interpolateColors, useCurrentFrame} from 'remotion'
-const frame = useCurrentFrame(); // 10
+const frame = useCurrentFrame() / 10
const color = interpolateColors(frame,
[0, 20],
- ['red', 'yellow']
-); // rgba(255, 128, 0, 1)
+ ['red', 'yellow'],
+) // rgba(255, 128, 0, 1)
const color2 = interpolateColors(frame,
[0, 20],
- ['#ff0000', '#ffff00']
-); // rgba(255, 128, 0, 1)
+ ['#ff0000', '#ffff00'],
+) // rgba(255, 128, 0, 1)
```
## Example: interpolate `rgb` or `rgba` colors
@@ -50,19 +50,19 @@ Using the following snippet, we can calculate the current color for any frame:
```tsx twoslash
import {useCurrentFrame, interpolateColors} from 'remotion'
-const frame = useCurrentFrame(); // 10
+const frame = useCurrentFrame() // 10
// RGB colors
const color = interpolateColors(frame,
[0, 20],
- ['rgb(255, 0, 0)', 'rgb(255, 255, 0)']
-); // rgba(255, 128, 0, 1)
+ ['rgb(255, 0, 0)', 'rgb(255, 255, 0)'],
+) // rgba(255, 128, 0, 1)
// RGBA colors
const color2 = interpolateColors(frame,
[0, 20],
- ['rgba(255, 0, 0, 1)', 'rgba(255, 255, 0, 0)']
-); // rgba(255, 128, 0, 0.5)
+ ['rgba(255, 0, 0, 1)', 'rgba(255, 255, 0, 0)'],
+) // rgba(255, 128, 0, 0.5)
```
## Example: interpolate `hsl` or `hsla` colors
@@ -74,18 +74,18 @@ Using the following snippet, we can calculate the current color for any frame:
```ts twoslash
import {useCurrentFrame, interpolateColors} from 'remotion'
-const frame = useCurrentFrame(); // 10
+const frame = useCurrentFrame() // 10
//hsl example
const color = interpolateColors(frame,
[0, 20],
- ['hsl(0, 100%, 50%)', 'hsl(60, 100%, 50%)']
-); // rgba(255, 128, 0, 1)
+ ['hsl(0, 100%, 50%)', 'hsl(60, 100%, 50%)'],
+) // rgba(255, 128, 0, 1)
//hsla example
const color2 = interpolateColors(frame,
[0, 20],
- ['hsla(0, 100%, 50%, 1)', 'hsla(60, 100%, 50%, 1)']
-); // rgba(255, 128, 0, 1)
+ ['hsla(0, 100%, 50%, 1)', 'hsla(60, 100%, 50%, 1)'],
+) // rgba(255, 128, 0, 1)
```
## Example: interpolate color names
@@ -95,12 +95,12 @@ Interpolating CSS color names is also supported.
```ts twoslash
import {useCurrentFrame, interpolateColors} from 'remotion'
-const frame = useCurrentFrame(); // 10
+const frame = useCurrentFrame() // 10
const color = interpolateColors(frame,
[0, 20],
- ['red', 'yellow']
-); // rgba(255, 128, 0, 1)
+ ['red', 'yellow'],
+) // rgba(255, 128, 0, 1)
```
## See also
diff --git a/packages/docs/docs/interpolate.mdx b/packages/docs/docs/interpolate.mdx
index b8c9aa7738..b92dcfac27 100644
--- a/packages/docs/docs/interpolate.mdx
+++ b/packages/docs/docs/interpolate.mdx
@@ -23,13 +23,13 @@ At frame 20, we want the opacity to be 1.
Using the following snippet, we can calculate the current opacity for any frame:
```ts twoslash
-import {useCurrentFrame, interpolate} from 'remotion'
+import {interpolate, useCurrentFrame} from 'remotion'
-const frame = useCurrentFrame(); // 10
+const frame = useCurrentFrame() // 10
const opacity = interpolate(frame,
[0, 20],
- [0, 1]
-); // 0.5
+ [0, 1],
+) // 0.5
```
## Example: Fade in and out
@@ -41,15 +41,15 @@ At the end, the opacity should be 0.
We can interpolate over multiple points in one go and use [`useVideoConfig()`](/docs/use-video-config) to determine the duration of the composition.
```ts twoslash
-import {useCurrentFrame, interpolate, useVideoConfig} from 'remotion'
+import {interpolate, useCurrentFrame, useVideoConfig} from 'remotion'
-const frame = useCurrentFrame();
-const {durationInFrames} = useVideoConfig();
+const frame = useCurrentFrame()
+const {durationInFrames} = useVideoConfig()
const opacity = interpolate(
frame,
[0, 20, durationInFrames - 20, durationInFrames],
// v--v---v----------------------v
- [0, 1, 1, 0]
+ [0, 1, 1, 0],
)
```
@@ -102,7 +102,7 @@ Consider the following interpolation which is supposed to animate the scale over
```tsx twoslash
import {interpolate, useCurrentFrame} from 'remotion'
-const frame = useCurrentFrame();
+const frame = useCurrentFrame()
// ---cut---
const scale = interpolate(frame, [0, 20], [0, 1])
```
@@ -112,11 +112,9 @@ To prevent this, this we can use the `extrapolateLeft` and `extrapolateRight` op
```tsx twoslash
import {interpolate, useCurrentFrame} from 'remotion'
-const frame = useCurrentFrame();
+const frame = useCurrentFrame()
// ---cut---
-const scale = interpolate(frame, [0, 20], [0, 1], {
- extrapolateRight: 'clamp'
-});
+const scale = interpolate(frame, [0, 20], [0, 1], {extrapolateRight: 'clamp'})
```
## Reference
@@ -164,10 +162,10 @@ Function which allows you to customize the input, for example to apply a certain
By default, the input is left unmodified, resulting in a pure linear interpolation. [Read the documentation for the built-in easing functions](/docs/easing).
```ts twoslash
-import {useCurrentFrame} from 'remotion';
-const frame = useCurrentFrame();
+import {useCurrentFrame} from 'remotion'
+const frame = useCurrentFrame()
// ---cut---
-import {interpolate, Easing} from 'remotion';
+import {interpolate, Easing} from 'remotion'
interpolate(frame, [0, 100], [0, 1], {
easing: Easing.bezier(0.8, 0.22, 0.96, 0.65),
diff --git a/packages/docs/docs/legacy-babel-loader.md b/packages/docs/docs/legacy-babel-loader.md
index d2cb51439e..457d9c33d1 100644
--- a/packages/docs/docs/legacy-babel-loader.md
+++ b/packages/docs/docs/legacy-babel-loader.md
@@ -20,11 +20,11 @@ npm i @remotion/babel-loader
```ts twoslash title="remotion.config.ts"
import {Config} from 'remotion'
// ---cut---
-import {replaceLoadersWithBabel} from '@remotion/babel-loader';
+import {replaceLoadersWithBabel} from '@remotion/babel-loader'
Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
- return replaceLoadersWithBabel(currentConfiguration);
-});
+ return replaceLoadersWithBabel(currentConfiguration)
+})
```
## See also
diff --git a/packages/docs/docs/measure-spring.md b/packages/docs/docs/measure-spring.md
index b650a4d8ac..527cb466fb 100644
--- a/packages/docs/docs/measure-spring.md
+++ b/packages/docs/docs/measure-spring.md
@@ -8,7 +8,7 @@ _Available from v2.0.8_
Based on a [spring()](/docs/spring) configuration and the frame rate, return how long it takes for a spring animation to settle.
```tsx twoslash
-import {measureSpring, SpringConfig} from 'remotion';
+import {measureSpring, SpringConfig} from 'remotion'
const config: Partial<SpringConfig> = {
damping: 200,
@@ -17,9 +17,9 @@ const config: Partial<SpringConfig> = {
measureSpring({
fps: 30,
config: {
- damping: 200
- }
-}); // => 23
+ damping: 200,
+ },
+}) // => 23
```
:::info
diff --git a/packages/docs/docs/overwriting-webpack-config.md b/packages/docs/docs/overwriting-webpack-config.md
index aabad731d2..7e222a0429 100644
--- a/packages/docs/docs/overwriting-webpack-config.md
+++ b/packages/docs/docs/overwriting-webpack-config.md
@@ -18,7 +18,7 @@ In your `remotion.config.ts` file, you can call `Config.Bundler.overrideWebpackC
Overriding the Webpack config uses the reducer pattern - pass in a function that takes as it's argument a Webpack configuration and return a new Webpack configuration.
```ts twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
return {
@@ -30,8 +30,8 @@ Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
// Add more loaders here
],
},
- };
-});
+ }
+})
```
:::info
@@ -45,7 +45,7 @@ Using the reducer pattern will help with type safety, give you auto-complete, en
The following `remotion.config.ts` file shows how to enable support for MDX. Installation of `mdx-loader babel-loader @babel/preset-env @babel/preset-react` is required.
```ts twoslash
-import { Config } from "remotion";
+import {Config} from 'remotion'
// ---cut---
Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
return {
@@ -78,8 +78,8 @@ Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
},
],
},
- };
-});
+ }
+})
```
:::info
@@ -117,7 +117,7 @@ yarn add postcss-loader postcss postcss-preset-env tailwindcss autoprefixer
2. Add the following to your [`remotion.config.ts`](/docs/config) file:
```ts twoslash
-import {Config} from "remotion";
+import {Config} from 'remotion'
// ---cut---
Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
return {
@@ -129,24 +129,24 @@ Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
? currentConfiguration.module.rules
: []
).filter((rule) => {
- if (rule === "...") {
- return false;
+ if (rule === '...') {
+ return false
}
- if (rule.test?.toString().includes(".css")) {
- return false;
+ if (rule.test?.toString().includes('.css')) {
+ return false
}
- return true;
+ return true
}),
{
test: /\.css$/i,
use: [
- "style-loader",
- "css-loader",
+ 'style-loader',
+ 'css-loader',
{
- loader: "postcss-loader",
+ loader: 'postcss-loader',
options: {
postcssOptions: {
- plugins: ["postcss-preset-env", "tailwindcss"],
+ plugins: ['postcss-preset-env', 'tailwindcss'],
},
},
},
@@ -154,8 +154,8 @@ Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
},
],
},
- };
-});
+ }
+})
```
3. Create a file `src/style.css` with the following content:
@@ -207,7 +207,7 @@ yarn add sass sass-loader
2. Add the following to your [`remotion.config.ts`](/docs/config) file:
```ts twoslash
-import {Config} from "remotion";
+import {Config} from 'remotion'
// ---cut---
Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
return {
@@ -221,24 +221,15 @@ Config.Bundling.overrideWebpackConfig((currentConfiguration) => {
{
test: /\.s[ac]ss$/i,
use: [
- {
- loader: 'style-loader',
- },
- {
- loader: 'css-loader',
- },
- {
- loader: 'sass-loader',
- options: {
- sourceMap: true,
- },
- },
+ {loader: 'style-loader'},
+ {loader: 'css-loader'},
+ {loader: 'sass-loader', options: {sourceMap: true}},
],
},
],
},
- };
-});
+ }
+})
```
3. Restart the preview server.
diff --git a/packages/docs/docs/parametrized-rendering.md b/packages/docs/docs/parametrized-rendering.md
index 82d39bc3e9..a65dc01940 100644
--- a/packages/docs/docs/parametrized-rendering.md
+++ b/packages/docs/docs/parametrized-rendering.md
@@ -52,7 +52,7 @@ export const Root = () => {
component={MyComponent}
defaultProps={{
propOne: 'Hi',
- propTwo: 10
+ propTwo: 10,
}}
/>
</>
@@ -91,11 +91,11 @@ When server-rendering using `renderFrames`, you can pass props using the `inputP
```tsx twoslash {9-11}
// @module: esnext
// @target: es2017
-const video = {fps: 30, durationInFrames: 30, width: 1080, height: 1080};
-const bundled = '/path/to/bundle';
-const framesDir = '/path/to/frames';
+const video = {fps: 30, durationInFrames: 30, width: 1080, height: 1080}
+const bundled = '/path/to/bundle'
+const framesDir = '/path/to/frames'
// ---cut---
-import {renderFrames} from '@remotion/renderer';
+import {renderFrames} from '@remotion/renderer'
await renderFrames({
config: video,
@@ -105,11 +105,11 @@ await renderFrames({
parallelism: null,
outputDir: framesDir,
inputProps: {
- titleText: 'Hello World'
+ titleText: 'Hello World',
},
compositionId: 'HelloWorld',
- imageFormat: 'jpeg'
-});
+ imageFormat: 'jpeg',
+})
```
### Passing input props in GitHub Actions
diff --git a/packages/docs/docs/player.md b/packages/docs/docs/player.md
index 9e75ee5f4c..348db1ed92 100644
--- a/packages/docs/docs/player.md
+++ b/packages/docs/docs/player.md
@@ -128,16 +128,15 @@ A regular `style` prop for a HTMLDivElement. You can pass a different height and
You may attach a ref to the player and control it in an imperative manner.
```tsx twoslash {15}
-// @filename: MyComposition.tsx
-import React from 'react';
+// @allowUmdGlobalAccess
-export const MyComposition: React.FC = () => null;
+// @filename: MyComposition.tsx
+export const MyComposition: React.FC = () => null
// @filename: index.tsx
-import React from 'react';
// ---cut---
-import {useEffect, useRef} from 'react';
-import {Player, PlayerRef} from '@remotion/player';
+import {useEffect, useRef} from 'react'
+import {Player, PlayerRef} from '@remotion/player'
import {MyComposition} from './MyComposition'
const MyComp: React.FC = () => {
@@ -145,9 +144,9 @@ const MyComp: React.FC = () => {
useEffect(() => {
if (playerRef.current) {
- console.log(playerRef.current.getCurrentFrame());
+ console.log(playerRef.current.getCurrentFrame())
}
- }, []);
+ }, [])
return (
<Player
@@ -159,7 +158,7 @@ const MyComp: React.FC = () => {
component={MyComposition}
// Many other optional props are available.
/>
- );
+ )
}
```
@@ -240,30 +239,30 @@ Stop listening to an event. See the [Events](#events) section to see the functio
Using a [player ref](#playerref), you can bind event listeners to get notified of certain events of the player.
```tsx twoslash
-import {useRef, useEffect} from 'react';
-import {PlayerRef} from '@remotion/player';
+import {useRef, useEffect} from 'react'
+import {PlayerRef} from '@remotion/player'
// ---cut---
const playerRef = useRef<PlayerRef>(null);
useEffect(() => {
if (!playerRef.current) {
- return;
+ return
}
playerRef.current.addEventListener('play', () => {
- console.log('playing');
- });
+ console.log('playing')
+ })
playerRef.current.addEventListener('pause', () => {
- console.log('pausing');
- });
+ console.log('pausing')
+ })
playerRef.current.addEventListener('seeked', (e) => {
- console.log('seeked to ' + e.detail.frame);
- });
+ console.log('seeked to ' + e.detail.frame)
+ })
playerRef.current.addEventListener('ended', (e) => {
- console.log('ended');
- });
+ console.log('ended')
+ })
playerRef.current.addEventListener('error', (e) => {
- console.log('error', e.detail.error);
- });
+ console.log('error', e.detail.error)
+ })
}, []);
```
@@ -272,13 +271,13 @@ useEffect(() => {
Fired when the time position changes. You may get the current frame by reading it from `e.detail.frame`.
```tsx twoslash
-import {useRef, useEffect} from 'react';
-import {PlayerRef} from '@remotion/player';
-const playerRef = useRef<PlayerRef>(null);
+import {useRef, useEffect} from 'react'
+import {PlayerRef} from '@remotion/player'
+const playerRef = useRef<PlayerRef>(null)
// ---cut---
playerRef.current?.addEventListener('seeked', (e) => {
- console.log('seeked to ' + e.detail.frame); // seeked to 120
-});
+ console.log('seeked to ' + e.detail.frame) // seeked to 120
+})
```
This event fires on every single frame update. If you link it to a state update, you may want to throttle the updates to avoid expensive rendering operations.
@@ -302,13 +301,13 @@ Fires when an error or uncaught exception has happened in the video.
You may get the error by reading the `e.detail.error` value:
```tsx twoslash
-import {useRef, useEffect} from 'react';
-import {PlayerRef} from '@remotion/player';
-const ref = useRef<PlayerRef>(null);
+import {useRef, useEffect} from 'react'
+import {PlayerRef} from '@remotion/player'
+const ref = useRef<PlayerRef>(null)
// ---cut---
ref.current?.addEventListener('error', (e) => {
- console.log('error ', e.detail.error); // error [Error: undefined is not a function]
-});
+ console.log('error ', e.detail.error) // error [Error: undefined is not a function]
+})
```
## Handling errors
diff --git a/packages/docs/docs/random.md b/packages/docs/docs/random.md
index 8f05f3d8c0..bdbea5c65f 100644
--- a/packages/docs/docs/random.md
+++ b/packages/docs/docs/random.md
@@ -6,17 +6,17 @@ title: random()
The `random()` API will give your deterministic pseudorandom values. Unlike the `Math.random()` function, Remotions function takes in a seed which can be a `number` or a `string`. If the seed is the same, the output is always the same.
```ts twoslash
-import {random} from 'remotion';
+import {random} from 'remotion'
-const rand = random(1); // 0.07301638228818774
-const rand2 = random(1); // still 0.07301638228818774
+const rand = random(1) // 0.07301638228818774
+const rand2 = random(1) // still 0.07301638228818774
const randomCoordinates = new Array(10).fill(true).map((a, i) => {
return {
x: random(`random-x-${i}`),
y: random(`random--${i}`),
- };
-}); // will always be [{x: 0.2887063352391124, y: 0.18660089606419206}, ...]
+ }
+}) // will always be [{x: 0.2887063352391124, y: 0.18660089606419206}, ...]
// @ts-expect-error
random() // Error: random() argument must be a number or a string
diff --git a/packages/docs/docs/register-root.md b/packages/docs/docs/register-root.md
index d0da2e52d6..414b23f2d3 100644
--- a/packages/docs/docs/register-root.md
+++ b/packages/docs/docs/register-root.md
@@ -13,14 +13,14 @@ The list of compositions can be updated without reloading the page, but calling
```tsx twoslash title="index.ts"
// @filename: ./Video.tsx
-export const RemotionVideo = () => <></>;
+export const RemotionVideo = () => <></>
// @filename: index.tsx
// ---cut---
-import {registerRoot} from 'remotion';
-import {RemotionVideo} from './Video';
+import {registerRoot} from 'remotion'
+import {RemotionVideo} from './Video'
-registerRoot(RemotionVideo);
+registerRoot(RemotionVideo)
```
```tsx twoslash title="Video.tsx"
@@ -33,15 +33,15 @@ export default () => <></>
// @filename: index.tsx
const Composition: React.FC<{
- id:string,
- fps: number,
- height: number,
- width: number
- component: () => JSX.Element
+ id: string
+ fps: number
+ height: number
+ width: number
+ component: () => JSX.Element
}> = () => <></>
// ---cut---
-import MyComponent from './MyComponent';
-import MyOtherComponent from './MyOtherComponent';
+import MyComponent from './MyComponent'
+import MyOtherComponent from './MyOtherComponent'
export const RemotionVideo = () => {
return (
diff --git a/packages/docs/docs/render-frames.md b/packages/docs/docs/render-frames.md
index a26a092cc8..2c4022e3ff 100644
--- a/packages/docs/docs/render-frames.md
+++ b/packages/docs/docs/render-frames.md
@@ -51,7 +51,7 @@ A callback that fires after the setup process (validation, browser launch) has f
```ts twoslash
const onStart = () => {
- console.log('Starting rendering...');
+ console.log('Starting rendering...')
}
```
diff --git a/packages/docs/docs/sequence.mdx b/packages/docs/docs/sequence.mdx
index dfcff6c08e..751e95841f 100644
--- a/packages/docs/docs/sequence.mdx
+++ b/packages/docs/docs/sequence.mdx
@@ -41,9 +41,7 @@ All the examples below are based on the following animation of a blue square:
// @include: example-BlueSquare
// ---cut---
const MyVideo = () => {
- return (
- <BlueSquare />
- );
+ return <BlueSquare />
}
```
@@ -56,14 +54,14 @@ If you would like to delay the content by say 30 frames, you can wrap it in <br/
```tsx twoslash
// @include: example-BlueSquare
-import {Sequence} from "remotion";
+import {Sequence} from 'remotion'
// ---cut---
const MyVideo = () => {
return (
<Sequence from={30} durationInFrames={Infinity}>
<BlueSquare />
</Sequence>
- );
+ )
}
```
@@ -92,7 +90,7 @@ You need to wrap the videos in two sequences. To the inner one we pass a negativ
```tsx twoslash
// @include: example-BlueSquare
-import {Sequence} from "remotion";
+import {Sequence} from 'remotion'
// ---cut---
const TrimAndDelayExample: React.FC = () => {
return (
@@ -101,8 +99,8 @@ const TrimAndDelayExample: React.FC = () => {
<BlueSquare />
</Sequence>
</Sequence>
- );
-};
+ )
+}
```
## See also
diff --git a/packages/docs/docs/sequences.md b/packages/docs/docs/sequences.md
index adeffddb1a..9739236147 100644
--- a/packages/docs/docs/sequences.md
+++ b/packages/docs/docs/sequences.md
@@ -5,11 +5,11 @@ sidebar_label: Reuse components
---
```twoslash include example
-import {useCurrentFrame, interpolate} from 'remotion';
+import {interpolate, useCurrentFrame} from 'remotion'
-const Title: React.FC<{title: string;}> = ({title}) => {
- const frame = useCurrentFrame();
- const opacity = interpolate(frame, [0, 20], [0, 1], {extrapolateRight: 'clamp'});
+const Title: React.FC<{title: string}> = ({title}) => {
+ const frame = useCurrentFrame()
+ const opacity = interpolate(frame, [0, 20], [0, 1], {extrapolateRight: 'clamp'})
return (
<div style={{opacity}}>{title}</div>
@@ -28,7 +28,7 @@ In order to make a title reusable, we first factor it out into it's own componen
export const MyVideo = () => {
return (
<div style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
- <Title title="Hello World"/>
+ <Title title="Hello World" />
</div>
)
}
@@ -39,16 +39,23 @@ Now we can use the `<Sequence>` component to limit the duration of the first tit
```tsx twoslash
// @include: example-Title
// ---cut---
-import {Sequence} from 'remotion';
+import {Sequence} from 'remotion'
export const MyVideo = () => {
return (
- <div style={{flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'white'}}>
+ <div
+ style={{
+ flex: 1,
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: 'white',
+ }}
+ >
<Sequence from={0} durationInFrames={40}>
- <Title title="Hello"/>
+ <Title title="Hello" />
</Sequence>
<Sequence from={40} durationInFrames={Infinity}>
- <Title title="World"/>
+ <Title title="World" />
</Sequence>
</div>
)
diff --git a/packages/docs/docs/spring.md b/packages/docs/docs/spring.md
index e044bc58cc..dd85a25f9b 100644
--- a/packages/docs/docs/spring.md
+++ b/packages/docs/docs/spring.md
@@ -8,7 +8,7 @@ Delightful and smooth animation primitive. Calculates a position based on physic
Example:
```tsx twoslash
-import {useCurrentFrame, useVideoConfig, spring} from "remotion";
+import {spring, useCurrentFrame, useVideoConfig} from 'remotion'
// ---cut---
const frame = useCurrentFrame()
const videoConfig = useVideoConfig()
@@ -19,8 +19,8 @@ const value = spring({
to: 1,
fps: videoConfig.fps,
config: {
- stiffness: 100
- }
+ stiffness: 100,
+ },
})
```
diff --git a/packages/docs/docs/ssr.md b/packages/docs/docs/ssr.md
index d91d3272b7..04618a155c 100644
--- a/packages/docs/docs/ssr.md
+++ b/packages/docs/docs/ssr.md
@@ -16,22 +16,22 @@ The NPM package `@remotion/renderer` provides you with an API for rendering the
Follow this commented example to see how to render a video:
```tsx twoslash
-import fs from 'fs';
-import os from 'os';
-import path from 'path';
-import {bundle} from '@remotion/bundler';
+import fs from 'fs'
+import os from 'os'
+import path from 'path'
+import {bundle} from '@remotion/bundler'
import {
getCompositions,
renderFrames,
stitchFramesToVideo,
-} from '@remotion/renderer';
+} from '@remotion/renderer'
const start = async () => {
// The composition you want to render
- const compositionId = 'HelloWorld';
+ const compositionId = 'HelloWorld'
// Create a webpack bundle of the entry file.
- const bundled = await bundle(require.resolve('./src/index'));
+ const bundled = await bundle(require.resolve('./src/index'))
// Extract all the compositions you have defined in your project
// from the webpack bundle.
@@ -40,12 +40,12 @@ const start = async () => {
// in the composition list. Use this if you want to dynamically set the duration or
// dimensions of the video.
inputProps: {
- custom: 'data'
- }
- });
+ custom: 'data',
+ },
+ })
// Select the composition you want to render.
- const composition = comps.find((c) => c.id === compositionId);
+ const composition = comps.find((c) => c.id === compositionId)
// Ensure the composition exists
if (!composition) {
@@ -55,7 +55,7 @@ const start = async () => {
// We create a temporary directory for storing the frames
const framesDir = await fs.promises.mkdtemp(
path.join(os.tmpdir(), 'remotion-')
- );
+ )
// We create JPEGs for all frames
const {assetsInfo} = await renderFrames({
@@ -68,7 +68,7 @@ const start = async () => {
onFrameUpdate: (f) => {
// Log a message whenever 10 frames have rendered.
if (f % 10 === 0) {
- console.log(`Rendered frame ${f}`);
+ console.log(`Rendered frame ${f}`)
}
},
// How many CPU threads to use. `null` will use a sane default (half of the available threads)
@@ -82,7 +82,7 @@ const start = async () => {
compositionId,
// Can be either 'jpeg' or 'png'. JPEG is faster, but has no transparency.
imageFormat: 'jpeg'
- });
+ })
// Add this step if you want to make an MP4 out of the rendered frames.
await stitchFramesToVideo({
@@ -106,10 +106,10 @@ const start = async () => {
assetsInfo,
// Hook into the FFMPEG progress
onProgress: (frame) => undefined
- });
-};
+ })
+}
-start();
+start()
```
:::warning
diff --git a/packages/docs/docs/stitch-frames-to-video.md b/packages/docs/docs/stitch-frames-to-video.md
index 5f8798b13c..d7cc8d2cb6 100644
--- a/packages/docs/docs/stitch-frames-to-video.md
+++ b/packages/docs/docs/stitch-frames-to-video.md
@@ -9,20 +9,20 @@ Takes a series of images and audio information generated by [`renderFrames()`](/
```ts
const stitchFramesToVideo: (options: {
- dir: string;
- fps: number;
- width: number;
- height: number;
- outputLocation: string;
- force: boolean;
- assetsInfo: RenderAssetInfo;
- imageFormat?: 'png' | 'jpeg' | 'none';
- pixelFormat?: PixelFormat;
- codec?: Codec;
- crf?: number;
- onProgress?: (progress: number) => void;
- onDownload?: (src: number) => void;
- verbose?: boolean;
+ dir: string
+ fps: number
+ width: number
+ height: number
+ outputLocation: string
+ force: boolean
+ assetsInfo: RenderAssetInfo
+ imageFormat?: 'png' | 'jpeg' | 'none'
+ pixelFormat?: PixelFormat
+ codec?: Codec
+ crf?: number
+ onProgress?: (progress: number) => void
+ onDownload?: (src: number) => void
+ verbose?: boolean
}) => Promise<void>
```
diff --git a/packages/docs/docs/the-fundamentals.md b/packages/docs/docs/the-fundamentals.md
index eb1b360d1b..5f0a75de93 100644
--- a/packages/docs/docs/the-fundamentals.md
+++ b/packages/docs/docs/the-fundamentals.md
@@ -37,17 +37,17 @@ A video has 4 properties:
These properties are variable and you can reuse a component multiple times with different properties. This is why you better not hard-code these properties, but instead derive them from the `useVideoConfig` hook:
```tsx twoslash
-import { useVideoConfig } from "remotion";
+import {useVideoConfig} from 'remotion'
export const MyVideo = () => {
- const { fps, durationInFrames, width, height } = useVideoConfig();
+ const {fps, durationInFrames, width, height} = useVideoConfig()
return (
- <div style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
+ <div style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
This video is {durationInFrames / fps} seconds long.
</div>
- );
-};
+ )
+}
```
A video's first frame is `0` and it's last frame is `durationInFrames - 1`.
@@ -57,7 +57,7 @@ A video's first frame is `0` and it's last frame is `durationInFrames - 1`.
Compositions are components with the above mentioned metadata. You can define compositions in `src/Video.tsx` to make them show up in the left sidebar.
```tsx twoslash
-import { Composition } from "remotion"
+import {Composition} from 'remotion'
// @include: example-MyVideo
// ---cut---
@@ -73,8 +73,8 @@ export const RemotionVideo: React.FC = () => {
height={1080}
/>
</>
- );
-};
+ )
+}
```
Remember that if you like, you can register multiple compositions that rely on the same component. For example, if you like to make a square video for social media feeds, and a portrait video for Stories, you can reuse the component and try to make it 'responsive'.
diff --git a/packages/docs/docs/three-canvas.md b/packages/docs/docs/three-canvas.md
index f3338367ab..202379ce0c 100644
--- a/packages/docs/docs/three-canvas.md
+++ b/packages/docs/docs/three-canvas.md
@@ -16,20 +16,22 @@ A browser bug [would normally cause the layout to be broken](https://github.com/
A spinning, color changing, scaling cube. This example can also be found in the `examples` folder of the Remotion repo.
```tsx twoslash
-import { interpolate, useCurrentFrame, useVideoConfig } from 'remotion';
-import { ThreeCanvas } from '@remotion/three';
+import {interpolate, useCurrentFrame, useVideoConfig} from 'remotion'
+import {ThreeCanvas} from '@remotion/three'
const ThreeBasic: React.FC = () => {
- const frame = useCurrentFrame();
- const { width, height } = useVideoConfig();
+ const frame = useCurrentFrame()
+ const {width, height} = useVideoConfig()
return (
<ThreeCanvas
orthographic={false}
width={width}
height={height}
- style={{ backgroundColor: 'white' }}
- camera={{ fov: 75, position: [0, 0, 470] }}
+ style={{
+ backgroundColor: 'white',
+ }}
+ camera={{fov: 75, position: [0, 0, 470]}}
>
<ambientLight intensity={0.15} />
<pointLight args={[undefined, 0.4]} position={[200, 200, 0]} />
@@ -48,8 +50,8 @@ const ThreeBasic: React.FC = () => {
/>
</mesh>
</ThreeCanvas>
- );
-};
+ )
+}
-export default ThreeBasic;
+export default ThreeBasic
```
diff --git a/packages/docs/docs/transparent-videos.mdx b/packages/docs/docs/transparent-videos.mdx
index 685f59d938..53ee46b7cd 100644
--- a/packages/docs/docs/transparent-videos.mdx
+++ b/packages/docs/docs/transparent-videos.mdx
@@ -35,11 +35,11 @@ In order to create a transparent video, you need at least version 1.4 of Remotio
If you want to set these options and persist them, add this to your `remotion.config.ts` file (create it if you don't yet have one);
```tsx twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
-Config.Rendering.setImageFormat('png');
-Config.Output.setPixelFormat('yuva420p');
-Config.Output.setCodec('vp8');
+Config.Rendering.setImageFormat('png')
+Config.Output.setPixelFormat('yuva420p')
+Config.Output.setCodec('vp8')
```
You can also set the settings on the command line:
@@ -56,12 +56,12 @@ ProRes is supported by Final Cut Pro, Adobe Premiere and Davinci Resolve.
Supported since v2.1.7, you can set the codec to `prores` and choose a ProRes profile with alpha support: Either: `4444` or `4444-hq`. The pixel format must be `yuva444p10le`.
```tsx twoslash
-import {Config} from 'remotion';
+import {Config} from 'remotion'
-Config.Rendering.setImageFormat('png');
-Config.Output.setPixelFormat("yuva444p10le");
-Config.Output.setCodec('prores');
-Config.Output.setProResProfile('4444');
+Config.Rendering.setImageFormat('png')
+Config.Output.setPixelFormat('yuva444p10le')
+Config.Output.setCodec('prores')
+Config.Output.setProResProfile('4444')
```
You can also set the settings on the command line:
@@ -81,7 +81,7 @@ Given the poor browser support, consider making two versions of a video, one wit
It's a good practice to set a default when defining the composition:
```tsx twoslash {7-9}
-import { Composition } from "remotion";
+import {Composition} from 'remotion'
// @include: example-MyVideo
// ---cut---
<Composition
diff --git a/packages/docs/docs/use-audio-data.md b/packages/docs/docs/use-audio-data.md
index f055b93e3f..9c8cba9549 100644
--- a/packages/docs/docs/use-audio-data.md
+++ b/packages/docs/docs/use-audio-data.md
@@ -32,15 +32,13 @@ import {useAudioData} from '@remotion/media-utils';
import music from './music.mp3';
export const MyComponent: React.FC = () => {
- const audioData = useAudioData(music);
+ const audioData = useAudioData(music)
if (!audioData) {
- return null;
+ return null
}
- return (
- <div>This file has a {audioData.sampleRate} sampleRate.</div>
- );
+ return <div>This file has a {audioData.sampleRate} sampleRate.</div>
}
```
diff --git a/packages/docs/docs/use-current-frame.md b/packages/docs/docs/use-current-frame.md
index ea2b2ecd59..8474460ce2 100644
--- a/packages/docs/docs/use-current-frame.md
+++ b/packages/docs/docs/use-current-frame.md
@@ -10,24 +10,20 @@ If the component you are writing is wrapped in a `<Sequence>`, `useCurrentFrame`
Say the timeline marker is positioned at frame 25. In the example below, `useCurrentFrame` will return `20`, except within the Subtitle component, where it will return `15` because it is within a sequence that starts at frame 10.
```tsx twoslash
-import {useCurrentFrame, Sequence} from 'remotion';
+import {Sequence, useCurrentFrame} from 'remotion'
const Title = () => {
- const frame = useCurrentFrame(); // 25
- return (
- <div>{frame}</div>
- )
+ const frame = useCurrentFrame() // 25
+ return <div>{frame}</div>
}
const Subtitle = () => {
- const frame = useCurrentFrame(); // 15
- return (
- <div>{frame}</div>
- )
+ const frame = useCurrentFrame() // 15
+ return <div>{frame}</div>
}
const MyVideo = () => {
- const frame = useCurrentFrame(); // 25
+ const frame = useCurrentFrame() // 25
return (
<div>
@@ -36,7 +32,7 @@ const MyVideo = () => {
<Subtitle />
</Sequence>
</div>
- );
+ )
}
```
diff --git a/packages/docs/docs/use-video-texture.md b/packages/docs/docs/use-video-texture.md
index e5bbc816c4..716abee40a 100644
--- a/packages/docs/docs/use-video-texture.md
+++ b/packages/docs/docs/use-video-texture.md
@@ -8,19 +8,20 @@ Allows you to use a video in React Three Fiber that is synchronized with Remotio
To use a video in a Three.JS context, you first have to render it and assign it a ref. If you only want to use it in a React Three Fiber Scene, you can make it invisible by adding a `{position: "absolute", opacity: 0}` style.
```tsx twoslash
-import {useRef} from 'react';
-import {Video} from 'remotion';
-import src from './vid.mp4';
+import {useRef} from 'react'
+import {Video} from 'remotion'
+import src from './vid.mp4'
const MyVideo = () => {
- const videoRef = useRef<HTMLVideoElement | null>(null);
+ const videoRef = useRef<HTMLVideoElement | null>(null)
+
return (
<Video
ref={videoRef}
src={src}
- style={{position: "absolute", opacity: 0}}
+ style={{position: 'absolute', opacity: 0}}
/>
- );
+ )
}
```
@@ -29,7 +30,7 @@ To convert the video to a video texture, place the `useVideoTexture()` hook in t
```tsx twoslash
const videoRef: React.MutableRefObject<HTMLVideoElement | null> = React.useRef(null)
// ---cut---
-import {useVideoTexture} from '@remotion/three';
+import {useVideoTexture} from '@remotion/three'
// ...
@@ -39,7 +40,7 @@ const texture = useVideoTexture(videoRef)
The return type of it is a `THREE.VideoTexture | null` which you can assign as a `map` to for example `meshBasicMaterial`. We recommend to only render the material when the texture is not `null` to prevent bugs.
```tsx twoslash
-import {useVideoTexture} from '@remotion/three';
+import {useVideoTexture} from '@remotion/three'
const videoRef: React.MutableRefObject<HTMLVideoElement | null> = React.useRef(null)
const videoTexture = useVideoTexture(videoRef)
// ---cut---
diff --git a/packages/docs/docs/using-audio.md b/packages/docs/docs/using-audio.md
index c765098caa..98afc4233f 100644
--- a/packages/docs/docs/using-audio.md
+++ b/packages/docs/docs/using-audio.md
@@ -16,7 +16,7 @@ import audio from './audio.mp3'
You may add an [`<Audio/>`](/docs/audio) tag to your composition to add sound to it.
```tsx twoslash {7}
-import {Audio} from 'remotion';
+import {Audio} from 'remotion'
import audio from './audio.mp3'
export const MyComposition: React.FC = () => {
@@ -41,7 +41,7 @@ You can use the [`<Sequence />`](/docs/sequence) API to cut and trim audio.
As a convienience, the `<Audio />` tag supports the `startFrom` and `endAt` props.
```tsx twoslash {9-10}
-import {Audio} from 'remotion';
+import {Audio} from 'remotion'
import audio from './audio.mp3'
export const MyVideo = () => {
@@ -64,7 +64,7 @@ Use a `<Sequence>` with a positive `from` attribute to delay the audio from play
In the following example, the audio will start playing (from the beginning) after 100 frames.
```tsx twoslash {8}
-import {Audio, Sequence} from 'remotion';
+import {Audio, Sequence} from 'remotion'
import audio from './audio.mp3'
export const MyVideo = () => {
@@ -85,7 +85,7 @@ You can use the `volume` prop to control the volume.
**The simplest way is to pass a number between 0 and 1**. `1` is the maximum volume, values over 1 are allowed but will not increase the volume further. Volumes under 0 are not allowed.
```tsx twoslash {7}
-import {Audio} from 'remotion';
+import {Audio} from 'remotion'
import audio from './audio.mp3'
export const MyVideo = () => {
@@ -100,17 +100,20 @@ export const MyVideo = () => {
You can also **change volume over time**, in this example we are using the [interpolate()](/docs/interpolate) function. Note that because values below 0 are not allowed, we need to set the `extrapolateLeft: 'clamp'` option to ensure no negative values.
-```tsx twoslash {9}
-import {Audio, interpolate, useCurrentFrame} from 'remotion';
+```tsx twoslash {11}
+import {Audio, interpolate, useCurrentFrame} from 'remotion'
import audio from './audio.mp3'
export const MyVideo = () => {
- const frame = useCurrentFrame();
+ const frame = useCurrentFrame()
return (
<div>
<div>Hello World!</div>
- <Audio src={audio} volume={interpolate(frame, [0, 30], [0,1], {extrapolateLeft: 'clamp'})} />
+ <Audio
+ src={audio}
+ volume={interpolate(frame, [0, 30], [0, 1], {extrapolateLeft: 'clamp'})}
+ />
</div>
)
}
@@ -118,15 +121,18 @@ export const MyVideo = () => {
You may also pass a **callback function** that returns the volume based an arbitrary frame number. This has the benefit that Remotion is able to **draw a volume curve in the timeline**!
-```tsx twoslash {7}
-import {Audio, interpolate} from 'remotion';
+```tsx twoslash {9}
+import {Audio, interpolate} from 'remotion'
import audio from './audio.mp3'
export const MyVideo = () => {
return (
<div>
<div>Hello World!</div>
- <Audio src={audio} volume={f => interpolate(f, [0, 30], [0,1], {extrapolateLeft: 'clamp'})} />
+ <Audio
+ src={audio}
+ volume={(f) => interpolate(f, [0, 30], [0, 1], {extrapolateLeft: 'clamp'})}
+ />
</div>
)
}
@@ -139,11 +145,11 @@ Note that if you pass in a callback function, the first frame on which audio is
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 {9}
-import {Audio, interpolate, useCurrentFrame} from 'remotion';
+import {Audio, useCurrentFrame} from 'remotion'
import audio from './audio.mp3'
export const MyVideo = () => {
- const frame = useCurrentFrame();
+ const frame = useCurrentFrame()
return (
<div>
diff --git a/packages/docs/docs/using-fonts.md b/packages/docs/docs/using-fonts.md
index 8ee964c72e..4c736f18b9 100644
--- a/packages/docs/docs/using-fonts.md
+++ b/packages/docs/docs/using-fonts.md
@@ -15,9 +15,7 @@ You can use fonts by loading them in a CSS file using @font-face. Web fonts ofte
import './font.css'
const MyComp: React.FC = () => {
- return (
- <div style={{fontFamily: 'Bangers'}}>Hello</div>
- )
+ return <div style={{fontFamily: 'Bangers'}}>Hello</div>
}
```
@@ -40,9 +38,7 @@ Google Web Fonts by default appends `?display=swap` to their URLs. Make sure to
import './font.css'
const MyComp: React.FC = () => {
- return (
- <div style={{fontFamily: 'Bangers'}}>Hello</div>
- )
+ return <div style={{fontFamily: 'Bangers'}}>Hello</div>
}
```
diff --git a/packages/docs/docs/using-randomness.md b/packages/docs/docs/using-randomness.md
index b73d064fd8..ce3e26efb4 100644
--- a/packages/docs/docs/using-randomness.md
+++ b/packages/docs/docs/using-randomness.md
@@ -6,7 +6,7 @@ title: Using randomness
The following thing is an anti-pattern in Remotion:
```tsx twoslash
-import { useState } from "react";
+import {useState} from 'react'
// ---cut---
const MyComp: React.FC = () => {
const [randomValues] = useState(() =>
@@ -14,11 +14,11 @@ const MyComp: React.FC = () => {
return {
x: Math.random(),
y: Math.random(),
- };
+ }
})
- );
+ )
// Do something with coordinates
- return <></>;
+ return <></>
}
```
@@ -28,19 +28,16 @@ While this will work during preview, it will break while rendering. The reason i
Use the [`random()`](/docs/random) API from Remotion to get deterministic pseudorandom values. Pass in a seed (number or string) and as long as the seed is the same, the return value will be the same.
-```tsx twoslash {6, 7}
-import { useState } from "react";
-// ---cut---
-import {random} from 'remotion';
-
+```tsx twoslash {5-6}
+import {random} from 'remotion'
const MyComp: React.FC = () => {
// No need to use useState
const randomValues = new Array(10).fill(true).map((a, i) => {
return {
x: random(`x-${i}`),
y: random(`y-${i}`),
- };
- });
+ }
+ })
return <></>
}
diff --git a/packages/docs/docs/video.md b/packages/docs/docs/video.md
index 660d1e1bd5..8d0d164f69 100644
--- a/packages/docs/docs/video.md
+++ b/packages/docs/docs/video.md
@@ -14,8 +14,8 @@ Use an import or require to load an video file and pass it as the `src` prop. Al
`<Video>` has two more helper props: `startFrom` and `endAt` to define when the video should start and end. Both are optional and do not get forwarded to the native `<video>` element but tell Remotion which portion of the video to use.
```tsx twoslash
-import {Video} from 'remotion';
-import video from './video.webm';
+import {Video} from 'remotion'
+import video from './video.webm'
export const MyVideo = () => {
return (
diff --git a/packages/docs/docs/visualize-audio.md b/packages/docs/docs/visualize-audio.md
index 784beb4791..4c231a93ef 100644
--- a/packages/docs/docs/visualize-audio.md
+++ b/packages/docs/docs/visualize-audio.md
@@ -34,17 +34,17 @@ Usually the values on left side of the array can become much larger than the val
In this example, we render a bar chart visualizing the audio spectrum of an audio file we imported using [`useAudioData()`](use-audio-data) and `visualizeAudio()`.
```tsx twoslash
-import {Audio, useCurrentFrame, useVideoConfig} from 'remotion';
-import {useAudioData, visualizeAudio} from '@remotion/media-utils';
-import music from './music.mp3';
+import {Audio, useCurrentFrame, useVideoConfig} from 'remotion'
+import {useAudioData, visualizeAudio} from '@remotion/media-utils'
+import music from './music.mp3'
export const MyComponent: React.FC = () => {
- const frame = useCurrentFrame();
- const {width, height, fps} = useVideoConfig();
- const audioData = useAudioData(music);
+ const frame = useCurrentFrame()
+ const {width, height, fps} = useVideoConfig()
+ const audioData = useAudioData(music)
if (!audioData) {
- return null;
+ return null
}
const visualization = visualizeAudio({
@@ -52,22 +52,21 @@ export const MyComponent: React.FC = () => {
frame,
audioData,
numberOfSamples: 16,
- }); // [0.22, 0.1, 0.01, 0.01, 0.01, 0.02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
+ }) // [0.22, 0.1, 0.01, 0.01, 0.01, 0.02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
// Render a bar chart for each frequency, the higher the amplitude,
// the longer the bar
return (
<div>
- <Audio src={music}/>
- {visualization.map(v => {
+ <Audio src={music} />
+ {visualization.map((v) => {
return (
<div style={{width: 1000 * v, height: 15, backgroundColor: 'blue'}} />
- );
+ )
})}
</div>
)
}
-
```
## See also