Skip to content

🎥 Make videos programmatically with React

update docs

JonnyBurger22d2f6dd698a
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index c350078f0b..e363363e21 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -113,6 +113,7 @@ export * from './AbsoluteFill.js';
export * from './animated-image/index.js';
export {Artifact} from './Artifact.js';
export * from './audio/index.js';
+export type {LoopVolumeCurveBehavior} from './audio/use-audio-frame.js';
export {cancelRender} from './cancel-render.js';
export {
CalculateMetadataFunction,
@@ -172,6 +173,8 @@ export * from './use-video-config.js';
export * from './version.js';
export * from './video-config.js';
export * from './video/index.js';
+export type {OnVideoFrame} from './video/props.js';
+export type {VolumeProp} from './volume-prop.js';
export {watchStaticFile} from './watch-static-file.js';
export const Experimental = {
diff --git a/packages/docs/docs/new-video/index.mdx b/packages/docs/docs/new-video/index.mdx
index dd581f4fb1..991e218d0e 100644
--- a/packages/docs/docs/new-video/index.mdx
+++ b/packages/docs/docs/new-video/index.mdx
@@ -5,10 +5,13 @@ crumb: 'API'
---
:::warning
-**Experimental Tag**: This tag is currently under development and experimental phase, which means that it can still be used but the API is unstable.
+**Very experimental**: This component is in a very early stage and **slower** than OffthreadVideo.
+The current focus is on correctness, not on performance.
+
+We recommend that you use [`<OffthreadVideo/>`](/docs/offthreadvideo) for now.
:::
-This component imports and displays a video, similar to [`<OffthreadVideo/>`](/docs/offthreadvideo) but during rendering, extracts the exact frame from the video using [`extractFrames()`](/docs/webcodecs/extract-frames) and displays it in a `<canvas>` tag, this ensures that the video is rendered with high accuracy and supports a wide range of codecs more reliably, significantly reducing the [flickering issues](/docs/flickering).
+This component imports and displays a video, similar to [`<OffthreadVideo/>`](/docs/offthreadvideo) but during rendering, extracts the exact frame from the video using WebCodecs and displays it in a `<canvas>` tag.
## Example
@@ -77,45 +80,6 @@ export const MyComposition = () => {
Removes a portion of the video at the end (right side). See [`trimBefore`](/docs/video#trimbefore) for an explanation.
-### ~~`startFrom?`~~
-
-:::note Deprecated
-This prop has been renamed to [`trimBefore`](#trimbefore) in 4.0.319. It will continue to work but you cannot use it together with the new prop.
-:::
-
-Will remove a portion of the video at the beginning.
-
-In the following example, we assume that the [`fps`](/docs/composition#fps) of the composition is `30`.
-
-By passing `startFrom={60}`, the playback starts immediately, but with the first 2 seconds of the video trimmed away.
-By passing `endAt={120}`, any video after the 4 second mark in the file will be trimmed away.
-
-The video will play the range from `00:02:00` to `00:04:00`, meaning the video will play for 2 seconds.
-
-For exact behavior, see: [Order of operations](/docs/audio/order-of-operations).
-
-```tsx twoslash
-import {AbsoluteFill, staticFile} from 'remotion';
-import {experimental_NewVideo as NewVideo} from '@remotion/video';
-
-// ---cut---
-export const MyComposition = () => {
- return (
- <AbsoluteFill>
- <NewVideo src={staticFile('video.webm')} startFrom={60} endAt={120} />
- </AbsoluteFill>
- );
-};
-```
-
-### ~~`endAt?`~~
-
-:::note Deprecated
-This prop has been renamed to [`trimAfter`](#trimafter) in 4.0.319. It will continue to work but you cannot use it together with the new prop.
-:::
-
-Removes a portion of the video at the end. See [`startFrom`](/docs/video#startfrom) for an explanation.
-
### `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/audio/volume) guide to learn how to use it.
@@ -279,20 +243,6 @@ Default: `"anonymous"` if `onVideoFrame` is specified, `undefined`, otherwise.
Enable the [Web Audio API](/docs/audio/volume#limitations) for the video tag.
-### ~~`imageFormat` <AvailableFrom v="3.0.22" />~~
-
-_removed in v4.0.0_
-
-Either `jpeg` or `png`. Default `jpeg`.
-With `png`, transparent videos (VP8, VP9, ProRes) can be displayed, however it is around 40% slower, with VP8 videos being [much slower](/docs/slow-method-to-extract-frame).
-
-### ~`allowAmplificationDuringRender?`<AvailableFrom v="3.3.17" />~
-
-Deprecated since v4.0.279: This prop intended to opt into setting the volume to a value higher than one, even though it would only apply during render.
-
-The option does not make sense anymore, because it is now possible to set the volume higher than `1`.
-To prevent synthetic amplification, set a volume not higher than 1.
-
## See also
- [Source code for this component](https://github.com/remotion-dev/remotion/blob/main/packages/video/src/video.tsx)
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index 8e61cbf56c..3e53966129 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -175,15 +175,7 @@ const sidebars: SidebarsConfig = {
'watchstaticfile',
],
},
- {
- type: 'category',
- label: '@remotion/video',
- link: {
- type: 'doc',
- id: 'video/index',
- },
- items: ['video/index'],
- },
+
{
type: 'category',
label: '@remotion/bundler',
@@ -779,6 +771,15 @@ const sidebars: SidebarsConfig = {
},
items: ['licensing/register-usage-point', 'licensing/get-usage'],
},
+ {
+ type: 'category',
+ label: '@remotion/video',
+ link: {
+ type: 'doc',
+ id: 'new-video/index',
+ },
+ items: ['new-video/index'],
+ },
],
mainSidebar: [
{
diff --git a/packages/video/src/new-video-for-rendering.tsx b/packages/video/src/new-video-for-rendering.tsx
index 08a96bc642..2e1330187b 100644
--- a/packages/video/src/new-video-for-rendering.tsx
+++ b/packages/video/src/new-video-for-rendering.tsx
@@ -7,7 +7,6 @@ import React, {
useRef,
useState,
} from 'react';
-import type {RemotionOffthreadVideoProps} from 'remotion';
import {
continueRender,
delayRender,
@@ -15,6 +14,7 @@ import {
random,
useCurrentFrame,
} from 'remotion';
+import type {NewVideoProps} from './props';
const {
useUnsafeVideoConfig,
SequenceContext,
@@ -25,7 +25,7 @@ const {
evaluateVolume,
} = Internals;
-export const NewVideoForRendering: React.FC<RemotionOffthreadVideoProps> = ({
+export const NewVideoForRendering: React.FC<NewVideoProps> = ({
volume: volumeProp,
playbackRate,
src,
diff --git a/packages/video/src/new-video.tsx b/packages/video/src/new-video.tsx
index 9d2131d561..eb87e14e76 100644
--- a/packages/video/src/new-video.tsx
+++ b/packages/video/src/new-video.tsx
@@ -1,7 +1,7 @@
import React, {useCallback} from 'react';
-import type {RemotionOffthreadVideoProps} from 'remotion';
import {getRemotionEnvironment, Internals, Sequence} from 'remotion';
import {NewVideoForRendering} from './new-video-for-rendering';
+import type {NewVideoProps} from './props';
const {
validateMediaTrimProps,
@@ -10,12 +10,10 @@ const {
VideoForPreview,
} = Internals;
-export const NewVideo: React.FC<RemotionOffthreadVideoProps> = (props) => {
+export const NewVideo: React.FC<NewVideoProps> = (props) => {
// Should only destruct `startFrom` and `endAt` from props,
// rest gets drilled down
const {
- startFrom,
- endAt,
trimBefore,
trimAfter,
name,
@@ -36,17 +34,16 @@ export const NewVideo: React.FC<RemotionOffthreadVideoProps> = (props) => {
);
}
- if (props.imageFormat) {
- throw new TypeError(
- `The \`<NewVideo>\` tag does no longer accept \`imageFormat\`. Use the \`transparent\` prop if you want to render a transparent video.`,
- );
- }
-
- validateMediaTrimProps({startFrom, endAt, trimBefore, trimAfter});
+ validateMediaTrimProps({
+ startFrom: undefined,
+ endAt: undefined,
+ trimBefore,
+ trimAfter,
+ });
const {trimBeforeValue, trimAfterValue} = resolveTrimProps({
- startFrom,
- endAt,
+ startFrom: undefined,
+ endAt: undefined,
trimBefore,
trimAfter,
});
@@ -78,8 +75,6 @@ export const NewVideo: React.FC<RemotionOffthreadVideoProps> = (props) => {
}
const {
- transparent,
- toneMapped,
onAutoPlayError,
onVideoFrame,
crossOrigin,
diff --git a/packages/video/src/props.ts b/packages/video/src/props.ts
new file mode 100644
index 0000000000..8a7ad34f59
--- /dev/null
+++ b/packages/video/src/props.ts
@@ -0,0 +1,28 @@
+import type {LoopVolumeCurveBehavior, OnVideoFrame, VolumeProp} from 'remotion';
+
+export type NewVideoProps = {
+ src: string;
+ trimBefore?: number;
+ trimAfter?: number;
+ volume?: VolumeProp;
+ loopVolumeCurveBehavior?: LoopVolumeCurveBehavior;
+ name?: string;
+ toneFrequency?: number;
+ pauseWhenBuffering?: boolean;
+ showInTimeline?: boolean;
+ onAutoPlayError?: null | (() => void);
+ onVideoFrame?: OnVideoFrame;
+ playbackRate?: number;
+ muted?: boolean;
+ delayRenderRetries?: number;
+ delayRenderTimeoutInMilliseconds?: number;
+ crossOrigin?: '' | 'anonymous' | 'use-credentials';
+ style?: React.CSSProperties;
+ onError?: (err: Error) => void;
+ useWebAudioApi?: boolean;
+ acceptableTimeShiftInSeconds?: number;
+ /**
+ * @deprecated For internal use only
+ */
+ stack?: string;
+};