Skip to content

🎥 Make videos programmatically with React

Docs: Move video docs into videos section (#8928)

Jonny Burger0ecd221ca2ce
diff --git a/packages/docs/blog/2022-07-14-remotion-3-1.mdx b/packages/docs/blog/2022-07-14-remotion-3-1.mdx
index be1f1edae6..01972ea325 100644
--- a/packages/docs/blog/2022-07-14-remotion-3-1.mdx
+++ b/packages/docs/blog/2022-07-14-remotion-3-1.mdx
@@ -111,7 +111,7 @@ Until now - if you pass a duration to a spring, we will detect the trajectory of
[This component](/docs/offthreadvideo) is an alternative to the [`<Html5Video>`](/docs/html5-video) component that extracts frames using FFMPEG and renders them inside an [`<Img>`](/docs/img) tag.
-We made the `<OffthreadVideo>` component in order to counteract problems with seeking and throttling that users were reporting with the `<Video>` tag. The new way improves reliability but has it's tradeoffs - read [`<OffthreadVideo> vs <Html5Video>`](/docs/video-tags) or check out our [visual explanation on Instagram](https://www.instagram.com/p/CftaiHpMM-L/)!
+We made the `<OffthreadVideo>` component in order to counteract problems with seeking and throttling that users were reporting with the `<Html5Video>` tag. The new way improves reliability but has it's tradeoffs - read [`<OffthreadVideo> vs <Html5Video>`](/docs/video-tags) or check out our [visual explanation on Instagram](https://www.instagram.com/p/CftaiHpMM-L/)!
<a href="https://www.instagram.com/p/CftaiHpMM-L/">
<img src="/img/offthreadvideo-all.png" />
diff --git a/packages/docs/blog/2022-11-17-remotion-3-3.mdx b/packages/docs/blog/2022-11-17-remotion-3-3.mdx
index 4575cf84d2..b42661a909 100644
--- a/packages/docs/blog/2022-11-17-remotion-3-3.mdx
+++ b/packages/docs/blog/2022-11-17-remotion-3-3.mdx
@@ -393,7 +393,7 @@ We have added new guides that document interesting workflows for Remotion:
- [Noise visualizations](/docs/noise-visualization#noise-dot-grid-demo)
- [Customizing Lambda output destinations](/docs/lambda/custom-destination)
- [Adding and subtracting animations](/docs/animation-math)
-- [Change the speed of a video over time](/docs/miscellaneous/snippets/accelerated-video)
+- [Change the speed of a video over time](/docs/videos/accelerated-video)
We try to avoid jargon, but we have also created a [Remotion Terminology](/docs/terminology) page to define some commonly used terms. When using these terms, we will from now link to the terminology page for you to read about it.
diff --git a/packages/docs/docs/dynamic-metadata.mdx b/packages/docs/docs/dynamic-metadata.mdx
index 282db868c7..3003d608ad 100644
--- a/packages/docs/docs/dynamic-metadata.mdx
+++ b/packages/docs/docs/dynamic-metadata.mdx
@@ -325,4 +325,4 @@ export const Index: React.FC = () => {
- [How props get resolved](/docs/props-resolution)
- [Data fetching](/docs/data-fetching)
-- [How do I make the composition the same duration as my video?](/docs/miscellaneous/snippets/align-duration)
+- [How do I make the composition the same duration as my video?](/docs/videos/align-duration)
diff --git a/packages/docs/docs/gpu.mdx b/packages/docs/docs/gpu.mdx
index 76bd4cf631..d9e84ef8fc 100644
--- a/packages/docs/docs/gpu.mdx
+++ b/packages/docs/docs/gpu.mdx
@@ -31,7 +31,7 @@ Contrary to popular belief, the following content is not accelerated by the GPU:
- `<Html5Video>`
- `<OffthreadVideo>`
-- [Canvas pixel manipulation](/docs/video-manipulation)
+- [Canvas pixel manipulation](/docs/videos/video-manipulation)
Furthermore, the encoding of the video is not accelerated by the GPU at this point.
diff --git a/packages/docs/docs/greenscreen.mdx b/packages/docs/docs/greenscreen.mdx
index c75be0c376..487f4823cd 100644
--- a/packages/docs/docs/greenscreen.mdx
+++ b/packages/docs/docs/greenscreen.mdx
@@ -1,6 +1,5 @@
---
image: /generated/articles-docs-greenscreen.png
-id: greenscreen
title: Greenscreen
sidebar_label: Greenscreen
crumb: 'How To'
@@ -46,4 +45,4 @@ export const Greenscreen: React.FC = () => {
- [`colorKey()`](/docs/effects/color-key)
- [`@remotion/effects`](/docs/effects/api)
-- [Manipulating pixels](/docs/video-manipulation)
+- [Manipulating pixels](/docs/videos/video-manipulation)
diff --git a/packages/docs/docs/hls.mdx b/packages/docs/docs/hls.mdx
index 2492ed8a05..b42e26bc34 100644
--- a/packages/docs/docs/hls.mdx
+++ b/packages/docs/docs/hls.mdx
@@ -2,7 +2,6 @@
image: /generated/articles-docs-hls.png
title: 'HLS support (HTTP Live Streaming)'
sidebar_label: 'HLS'
-id: hls
crumb: 'Video'
---
diff --git a/packages/docs/docs/html5-video.mdx b/packages/docs/docs/html5-video.mdx
index 6b428a544a..d67c612a84 100644
--- a/packages/docs/docs/html5-video.mdx
+++ b/packages/docs/docs/html5-video.mdx
@@ -296,7 +296,7 @@ Read more here about [autoplay restrictions](/docs/player/autoplay).
### `onVideoFrame?`<AvailableFrom v="4.0.472" />
A callback function that gets called when a frame is extracted from the video.
-Useful for [video manipulation](/docs/video-manipulation).
+Useful for [video manipulation](/docs/videos/video-manipulation).
The first argument is a [`CanvasImageSource`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource), more specifically a `HTMLVideoElement`.
When the browser reports a presented frame using [`HTMLVideoElement.requestVideoFrameCallback()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement/requestVideoFrameCallback), the callback also receives the `DOMHighResTimeStamp` and [`VideoFrameCallbackMetadata`](https://developer.mozilla.org/en-US/docs/Web/API/VideoFrameCallbackMetadata) as the second and third argument.
@@ -346,4 +346,4 @@ To decide which tag to use, see: [Comparison of video tags](/docs/video-tags)
- [`<Html5Audio />`](/docs/html5-audio)
- [`<OffthreadVideo />`](/docs/offthreadvideo)
- [Comparison of video tags](/docs/video-tags)
-- [`Change the speed of a video over time`](/docs/miscellaneous/snippets/accelerated-video)
+- [`Change the speed of a video over time`](/docs/videos/accelerated-video)
diff --git a/packages/docs/docs/media/video.mdx b/packages/docs/docs/media/video.mdx
index 500f541cdf..a896c1b40d 100644
--- a/packages/docs/docs/media/video.mdx
+++ b/packages/docs/docs/media/video.mdx
@@ -321,7 +321,7 @@ Customize the [number of retries](/docs/delay-render#retrying) of the [`delayRen
### `onVideoFrame?`
A callback function that gets called when a frame is extracted from the video.
-Useful for [video manipulation](/docs/video-manipulation).
+Useful for [video manipulation](/docs/videos/video-manipulation).
The callback is called with a [`CanvasImageSource`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource) object, more specifically, either an `ImageBitmap` or a `VideoFrame`.
### `audioStreamIndex?`
diff --git a/packages/docs/docs/miscellaneous/automatic-duration.mdx b/packages/docs/docs/miscellaneous/automatic-duration.mdx
index d95e1dfc12..9f080900b8 100644
--- a/packages/docs/docs/miscellaneous/automatic-duration.mdx
+++ b/packages/docs/docs/miscellaneous/automatic-duration.mdx
@@ -40,7 +40,7 @@ It is currently **not supported** to derive the duration of a composition be fro
};
```
- A practical usecase of this is [to change the speed of a video over time](/docs/miscellaneous/snippets/accelerated-video).
+ A practical usecase of this is [to change the speed of a video over time](/docs/videos/accelerated-video).
- **Remotion is only aware of the current frame:**
Remotion does not see the component statically like we do as developers, instead it only renders it at a certain point in time. To reliably determine when a component stops rendering markup, Remotion would have to loop through all frames until the markup stops which could be an expensive operation.
diff --git a/packages/docs/docs/miscellaneous/snippets/different-segments-at-different-speeds.mdx b/packages/docs/docs/miscellaneous/snippets/different-segments-at-different-speeds.mdx
deleted file mode 100644
index cab95b7ca0..0000000000
--- a/packages/docs/docs/miscellaneous/snippets/different-segments-at-different-speeds.mdx
+++ /dev/null
@@ -1,88 +0,0 @@
----
-image: /generated/articles-docs-miscellaneous-snippets-different-segments-at-different-speeds.png
-title: 'Different segments at different speeds'
-crumb: 'Snippets'
----
-
-If you have a video and want to show different sections of the video at different speeds, use the following snippet.
-
-```tsx twoslash title="SegmentSpeeds.tsx"
-import {OffthreadVideo, Sequence, staticFile, useCurrentFrame} from 'remotion';
-
-const segments = [
- {
- duration: 100,
- speed: 0.5,
- },
- {
- duration: 100,
- speed: 1,
- },
- {
- duration: 200,
- speed: 2,
- },
- {
- duration: 400,
- speed: 4,
- },
-];
-
-type AccumulatedSegment = {
- start: number;
- passedVideoTime: number;
- end: number;
- speed: number;
-};
-
-export const accumulateSegments = () => {
- const accumulatedSegments: AccumulatedSegment[] = [];
- let accumulatedDuration = 0;
- let accumulatedPassedVideoTime = 0;
-
- for (const segment of segments) {
- const duration = segment.duration / segment.speed;
- accumulatedSegments.push({
- end: accumulatedDuration + duration,
- speed: segment.speed,
- start: accumulatedDuration,
- passedVideoTime: accumulatedPassedVideoTime,
- });
-
- accumulatedPassedVideoTime += segment.duration;
- accumulatedDuration += duration;
- }
-
- return accumulatedSegments;
-};
-
-export const SpeedSegments = () => {
- const frame = useCurrentFrame();
- const accumulated = accumulateSegments();
-
- const currentSegment = accumulated.find((segment) => frame > segment.start && frame <= segment.end);
-
- if (!currentSegment) {
- return;
- }
-
- return (
- <Sequence from={currentSegment.start}>
- <OffthreadVideo
- pauseWhenBuffering
- trimBefore={currentSegment.passedVideoTime}
- // Remotion will automatically add a time fragment to the end of the video URL
- // based on `trimBefore`. Opt out of this by adding one yourself.
- // https://www.remotion.dev/docs/media-fragments
- src={`${staticFile('bigbuckbunny.mp4')}#t=0,`}
- playbackRate={currentSegment.speed}
- />
- </Sequence>
- );
-};
-```
-
-## See also
-
-- [Change the speed of a video over time](/docs/miscellaneous/snippets/accelerated-video)
-- [Jump Cutting](/docs/miscellaneous/snippets/jumpcuts)
diff --git a/packages/docs/docs/offthreadvideo.mdx b/packages/docs/docs/offthreadvideo.mdx
index 92a0cfa60c..a1131a337c 100644
--- a/packages/docs/docs/offthreadvideo.mdx
+++ b/packages/docs/docs/offthreadvideo.mdx
@@ -292,7 +292,7 @@ Read more here about [autoplay restrictions](/docs/player/autoplay).
### `onVideoFrame?`<AvailableFrom v="4.0.190" />
A callback function that gets called when a frame is extracted from the video.
-Useful for [video manipulation](/docs/video-manipulation).
+Useful for [video manipulation](/docs/videos/video-manipulation).
The callback is called with a [`CanvasImageSource`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource) object.
During preview, this is a `HTMLVideoElement` object, during rendering, it is an `HTMLImageElement`.
diff --git a/packages/docs/docs/resources.mdx b/packages/docs/docs/resources.mdx
index b3546c5954..015d8b5464 100644
--- a/packages/docs/docs/resources.mdx
+++ b/packages/docs/docs/resources.mdx
@@ -90,7 +90,7 @@ This list tries to compile all templates, libraries, building blocks and example
- Animate .glb models ([Source code](https://github.com/remotion-dev/glb-example), [Preview](https://glb-example.vercel.app/))
- Typewriter effect ([Source code](https://github.com/remotion-dev/typewriter), [Preview](https://typewriter-remotion.vercel.app/))
- 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))
+- Greenscreen Effect ([Docs](/docs/videos/video-manipulation))
- Noise visualization ([Docs](/docs/noise-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/))
diff --git a/packages/docs/docs/video-tags.mdx b/packages/docs/docs/video-tags.mdx
index 93ef14f364..30d4062924 100644
--- a/packages/docs/docs/video-tags.mdx
+++ b/packages/docs/docs/video-tags.mdx
@@ -1,6 +1,5 @@
---
image: /generated/articles-docs-video-tags.png
-id: video-tags
title: Comparison of video tags
crumb: '<Video>, <OffthreadVideo>, <Html5Video>'
---
diff --git a/packages/docs/docs/miscellaneous/snippets/accelerated-video.mdx b/packages/docs/docs/videos/accelerated-video.mdx
similarity index 83%
rename from packages/docs/docs/miscellaneous/snippets/accelerated-video.mdx
rename to packages/docs/docs/videos/accelerated-video.mdx
index 063018dca8..b7a2e83533 100644
--- a/packages/docs/docs/miscellaneous/snippets/accelerated-video.mdx
+++ b/packages/docs/docs/videos/accelerated-video.mdx
@@ -1,5 +1,5 @@
---
-image: /generated/articles-docs-miscellaneous-snippets-accelerated-video.png
+image: /generated/articles-docs-videos-accelerated-video.png
title: 'Change the speed of a video over time'
sidebar_label: Changing speed over time
crumb: 'Snippets'
@@ -9,7 +9,7 @@ crumb: 'Snippets'
This does not work with [`<Video>`](/docs/media/video) from [`@remotion/media`](/docs/media) yet.
:::
-import {AcceleratedVideoExample} from '../../../components/AcceleratedVideoPlayerExample.tsx';
+import {AcceleratedVideoExample} from '../../components/AcceleratedVideoPlayerExample.tsx';
To speed up a video over time - for example to start with regular speed and then increasingly make it faster - we need to write some code to ensure we stay within Remotion's rules.
@@ -55,7 +55,7 @@ export const AcceleratedVideo: React.FC = () => {
```
:::note
-We are [disabling the media fragment hints](/docs/media-fragments) being appended to the video URL by adding `#disable` to the end of the URL.
+We are [disabling the media fragment hints](/docs/videos/media-fragments) being appended to the video URL by adding `#disable` to the end of the URL.
:::
Note that the timeline in the Remotion Studio might move as you play the video because we reposition the sequence over time. This is okay as long as we calculate the frame in an idempotent way.
@@ -67,5 +67,5 @@ Note that the timeline in the Remotion Studio might move as you play the video b
## See also
- [`<OffthreadVideo>`](/docs/offthreadvideo)
-- [Different segments at different speeds](/docs/miscellaneous/snippets/different-segments-at-different-speeds)
-- [Jump Cutting](/docs/miscellaneous/snippets/jumpcuts)
+- [Different segments at different speeds](/docs/videos/different-segments-at-different-speeds)
+- [Jump Cutting](/docs/videos/jumpcuts)
diff --git a/packages/docs/docs/miscellaneous/snippets/align-duration.mdx b/packages/docs/docs/videos/align-duration.mdx
similarity index 97%
rename from packages/docs/docs/miscellaneous/snippets/align-duration.mdx
rename to packages/docs/docs/videos/align-duration.mdx
index 51f59969c1..9bedb1113d 100644
--- a/packages/docs/docs/miscellaneous/snippets/align-duration.mdx
+++ b/packages/docs/docs/videos/align-duration.mdx
@@ -1,5 +1,5 @@
---
-image: /generated/articles-docs-miscellaneous-snippets-align-duration.png
+image: /generated/articles-docs-videos-align-duration.png
title: How do I make the composition the same duration as my video?
sidebar_label: Make timeline duration the same
crumb: 'FAQ'
diff --git a/packages/docs/docs/videos/different-segments-at-different-speeds.mdx b/packages/docs/docs/videos/different-segments-at-different-speeds.mdx
new file mode 100644
index 0000000000..1b438698b9
--- /dev/null
+++ b/packages/docs/docs/videos/different-segments-at-different-speeds.mdx
@@ -0,0 +1,97 @@
+---
+image: /generated/articles-docs-videos-different-segments-at-different-speeds.png
+title: 'Different segments at different speeds'
+crumb: 'Snippets'
+---
+
+If you have a video and want to show different sections of the video at different speeds, use the following snippet.
+
+```tsx twoslash title="SegmentSpeeds.tsx"
+import {Video} from '@remotion/media';
+import React from 'react';
+import {AbsoluteFill, Series, useVideoConfig} from 'remotion';
+
+const src = 'https://remotion.media/video.mp4';
+
+const segments = [
+ {
+ duration: 60,
+ speed: 0.5,
+ },
+ {
+ duration: 60,
+ speed: 1,
+ },
+ {
+ duration: 120,
+ speed: 2,
+ },
+ {
+ duration: 60,
+ speed: 4,
+ },
+];
+
+type AccumulatedSegment = {
+ start: number;
+ passedVideoTime: number;
+ end: number;
+ speed: number;
+};
+
+export const accumulateSegments = () => {
+ const accumulatedSegments: AccumulatedSegment[] = [];
+ let accumulatedDuration = 0;
+ let accumulatedPassedVideoTime = 0;
+
+ for (const segment of segments) {
+ const duration = segment.duration / segment.speed;
+ accumulatedSegments.push({
+ end: accumulatedDuration + duration,
+ speed: segment.speed,
+ start: accumulatedDuration,
+ passedVideoTime: accumulatedPassedVideoTime,
+ });
+
+ accumulatedPassedVideoTime += segment.duration;
+ accumulatedDuration += duration;
+ }
+
+ return accumulatedSegments;
+};
+
+const accumulatedSegments = accumulateSegments();
+
+export const DIFFERENT_SEGMENTS_AT_DIFFERENT_SPEEDS_DURATION = Math.ceil(
+ accumulatedSegments[accumulatedSegments.length - 1].end,
+);
+
+export const SpeedSegments: React.FC = () => {
+ const {fps} = useVideoConfig();
+
+ return (
+ <AbsoluteFill style={{backgroundColor: 'black'}}>
+ <Series>
+ {accumulatedSegments.map((segment) => (
+ <Series.Sequence
+ key={segment.start}
+ durationInFrames={segment.end - segment.start}
+ premountFor={Math.round(1.5 * fps)}
+ >
+ <Video
+ src={src}
+ trimBefore={segment.passedVideoTime}
+ playbackRate={segment.speed}
+ />
+ </Series.Sequence>
+ ))}
+ </Series>
+ </AbsoluteFill>
+ );
+};
+```
+
+## See also
+
+- [Change the speed of a video over time](/docs/videos/accelerated-video)
+- [Jump Cutting](/docs/videos/jumpcuts)
diff --git a/packages/docs/docs/videos/index.mdx b/packages/docs/docs/videos/index.mdx
index 46549cbe78..c458716682 100644
--- a/packages/docs/docs/videos/index.mdx
+++ b/packages/docs/docs/videos/index.mdx
@@ -145,7 +145,7 @@ export const MyComp: React.FC = () => {
};
```
-This only works if the speed is constant. See also: [Changing the speed of a video over time](/docs/miscellaneous/snippets/accelerated-video).
+This only works if the speed is constant. See also: [Changing the speed of a video over time](/docs/videos/accelerated-video).
## Looping
diff --git a/packages/docs/docs/miscellaneous/snippets/jumpcuts.mdx b/packages/docs/docs/videos/jumpcuts.mdx
similarity index 89%
rename from packages/docs/docs/miscellaneous/snippets/jumpcuts.mdx
rename to packages/docs/docs/videos/jumpcuts.mdx
index f4e146d2c8..2c488d6cbb 100644
--- a/packages/docs/docs/miscellaneous/snippets/jumpcuts.mdx
+++ b/packages/docs/docs/videos/jumpcuts.mdx
@@ -1,5 +1,5 @@
---
-image: /generated/articles-docs-miscellaneous-snippets-jumpcuts.png
+image: /generated/articles-docs-videos-jumpcuts.png
title: 'Jump Cutting'
sidebar_label: Jump Cuts
crumb: 'Snippets'
@@ -73,5 +73,5 @@ During rendering, video frames are selected exactly, so premounting is only need
- [Playing videos in sequence](/docs/videos/sequence)
- [Premounting](/docs/player/premounting)
-- [Different segments at different speeds](/docs/miscellaneous/snippets/different-segments-at-different-speeds)
-- [Change the speed of a video over time](/docs/miscellaneous/snippets/accelerated-video)
+- [Different segments at different speeds](/docs/videos/different-segments-at-different-speeds)
+- [Change the speed of a video over time](/docs/videos/accelerated-video)
diff --git a/packages/docs/docs/media-fragments.mdx b/packages/docs/docs/videos/media-fragments.mdx
similarity index 93%
rename from packages/docs/docs/media-fragments.mdx
rename to packages/docs/docs/videos/media-fragments.mdx
index 7ff9dfa841..49801140a9 100644
--- a/packages/docs/docs/media-fragments.mdx
+++ b/packages/docs/docs/videos/media-fragments.mdx
@@ -1,8 +1,7 @@
---
-image: /generated/articles-docs-media-fragments.png
+image: /generated/articles-docs-videos-media-fragments.png
crumb: 'Video behavior'
title: '#t= Media Fragments'
-slug: media-fragments
---
For [`<OffthreadVideo>`](/docs/offthreadvideo) and [`<Html5Video>`](/docs/html5-video), Remotion by default adds [Media fragment](https://www.w3.org/TR/media-frags/) hashes to video URLs.
@@ -68,7 +67,7 @@ There are valid scenarios where we recommend disabling the media fragment hints:
- Changing the `trimBefore` and `trimAfter` values of a `<Html5Video>` or `<OffthreadVideo>` dynamically
- Changing the `playbackRate` of a `<OffthreadVideo>` or `<Html5Video>` over time.
-Normally you would not do this, but there are exceptions, like: [Changing the speed of a video over time](/docs/miscellaneous/snippets/accelerated-video)
+Normally you would not do this, but there are exceptions, like: [Changing the speed of a video over time](/docs/videos/accelerated-video)
## Recommendation
diff --git a/packages/docs/docs/video-manipulation.mdx b/packages/docs/docs/videos/video-manipulation.mdx
similarity index 90%
rename from packages/docs/docs/video-manipulation.mdx
rename to packages/docs/docs/videos/video-manipulation.mdx
index 95671a1f62..791a8762ef 100644
--- a/packages/docs/docs/video-manipulation.mdx
+++ b/packages/docs/docs/videos/video-manipulation.mdx
@@ -1,12 +1,11 @@
---
-image: /generated/articles-docs-video-manipulation.png
-id: video-manipulation
+image: /generated/articles-docs-videos-video-manipulation.png
title: Video manipulation
sidebar_label: Manipulating pixels
crumb: 'How To'
---
-import {VideoCanvasExamples} from '../components/GreenscreenExamples/index';
+import {VideoCanvasExamples} from '../../components/GreenscreenExamples/index';
You can draw frames of a [`<Video>` from `@remotion/media`](/docs/media/video), [`<OffthreadVideo>`](/docs/offthreadvideo) or a [`<Html5Video>`](/docs/html5-video) onto a `<canvas>` element using the [`drawImage()`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage) API.
@@ -77,4 +76,4 @@ You can also apply effects to canvas-based components such as [`<Video>`](/docs/
Before v4.0.190, the `onVideoFrame` prop of [`<OffthreadVideo>`](/docs/offthreadvideo) and [`<Html5Video>`](/docs/html5-video) was not supported.
You could only manipulate a `<Html5Video>` using the `requestVideoFrameCallback` API.
-Click [here](https://github.com/remotion-dev/remotion/blob/b966d0e99cfb91478ca697675f822284da1f9055/packages/docs/docs/video-manipulation.mdx) to see the old version of this page.
+Click [here](https://github.com/remotion-dev/remotion/blob/b966d0e99cfb91478ca697675f822284da1f9055/packages/docs/docs/videos/video-manipulation.mdx) to see the old version of this page.
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index cb1ae2c60d..54e486bf43 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -1057,16 +1057,17 @@ const sidebars: SidebarsConfig = {
label: 'Adding video',
items: [
'videos/index',
- 'miscellaneous/snippets/align-duration',
+ 'videos/align-duration',
'videos/sequence',
'videos/transparency',
- 'video-manipulation',
+ 'videos/video-manipulation',
'greenscreen',
- 'miscellaneous/snippets/accelerated-video',
- 'miscellaneous/snippets/jumpcuts',
- 'miscellaneous/snippets/freeze-portions',
+ 'videos/accelerated-video',
+ 'videos/jumpcuts',
+ 'videos/different-segments-at-different-speeds',
'video-tags',
'hls',
+ 'videos/media-fragments',
'videos/as-threejs-texture',
],
},
@@ -1466,7 +1467,7 @@ const sidebars: SidebarsConfig = {
type: 'category',
label: 'Snippets',
items: [
- 'miscellaneous/snippets/different-segments-at-different-speeds',
+ 'miscellaneous/snippets/freeze-portions',
'miscellaneous/snippets/player-in-iframe',
'miscellaneous/snippets/combine-compositions',
],
@@ -1506,7 +1507,6 @@ const sidebars: SidebarsConfig = {
'miscellaneous/emojis',
'miscellaneous/cross-origin-isolation',
'cors-issues',
- 'media-fragments',
'react-native',
'detect-remotion',
],
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index 6f25777e07..57e6267877 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -3932,15 +3932,6 @@ export const articles = [
noAi: false,
slug: 'measuring',
},
- {
- id: 'media-fragments',
- title: '#t= Media Fragments',
- relativePath: 'docs/media-fragments.mdx',
- compId: 'articles-docs-media-fragments',
- crumb: 'Video behavior',
- noAi: false,
- slug: 'media-fragments',
- },
{
id: 'download-and-parse-media',
title: 'downloadAndParseMedia()',
@@ -4535,24 +4526,6 @@ export const articles = [
noAi: false,
slug: 'miscellaneous/render-on-edge',
},
- {
- id: 'miscellaneous/snippets/accelerated-video',
- title: 'Change the speed of a video over time',
- relativePath: 'docs/miscellaneous/snippets/accelerated-video.mdx',
- compId: 'articles-docs-miscellaneous-snippets-accelerated-video',
- crumb: 'Snippets',
- noAi: false,
- slug: 'miscellaneous/snippets/accelerated-video',
- },
- {
- id: 'miscellaneous/snippets/align-duration',
- title: 'How do I make the composition the same duration as my video?',
- relativePath: 'docs/miscellaneous/snippets/align-duration.mdx',
- compId: 'articles-docs-miscellaneous-snippets-align-duration',
- crumb: 'FAQ',
- noAi: false,
- slug: 'miscellaneous/snippets/align-duration',
- },
{
id: 'miscellaneous/snippets/combine-compositions',
title: 'How do I combine compositions?',
@@ -4562,17 +4535,6 @@ export const articles = [
noAi: false,
slug: 'miscellaneous/snippets/combine-compositions',
},
- {
- id: 'miscellaneous/snippets/different-segments-at-different-speeds',
- title: 'Different segments at different speeds',
- relativePath:
- 'docs/miscellaneous/snippets/different-segments-at-different-speeds.mdx',
- compId:
- 'articles-docs-miscellaneous-snippets-different-segments-at-different-speeds',
- crumb: 'Snippets',
- noAi: false,
- slug: 'miscellaneous/snippets/different-segments-at-different-speeds',
- },
{
id: 'miscellaneous/snippets/freeze-portions',
title: 'Freeze portions of a sequence',
@@ -4582,15 +4544,6 @@ export const articles = [
noAi: false,
slug: 'miscellaneous/snippets/freeze-portions',
},
- {
- id: 'miscellaneous/snippets/jumpcuts',
- title: 'Jump Cutting',
- relativePath: 'docs/miscellaneous/snippets/jumpcuts.mdx',
- compId: 'articles-docs-miscellaneous-snippets-jumpcuts',
- crumb: 'Snippets',
- noAi: false,
- slug: 'miscellaneous/snippets/jumpcuts',
- },
{
id: 'miscellaneous/snippets/player-in-iframe',
title: 'Embedding a <Player> into an <iframe>',
@@ -7933,15 +7886,6 @@ export const articles = [
noAi: false,
slug: 'version',
},
- {
- id: 'video-manipulation',
- title: 'Video manipulation',
- relativePath: 'docs/video-manipulation.mdx',
- compId: 'articles-docs-video-manipulation',
- crumb: 'How To',
- noAi: false,
- slug: 'video-manipulation',
- },
{
id: 'video-tags',
title: 'Comparison of video tags',
@@ -7960,6 +7904,24 @@ export const articles = [
noAi: false,
slug: 'video-uploads',
},
+ {
+ id: 'videos/accelerated-video',
+ title: 'Change the speed of a video over time',
+ relativePath: 'docs/videos/accelerated-video.mdx',
+ compId: 'articles-docs-videos-accelerated-video',
+ crumb: 'Snippets',
+ noAi: false,
+ slug: 'videos/accelerated-video',
+ },
+ {
+ id: 'videos/align-duration',
+ title: 'How do I make the composition the same duration as my video?',
+ relativePath: 'docs/videos/align-duration.mdx',
+ compId: 'articles-docs-videos-align-duration',
+ crumb: 'FAQ',
+ noAi: false,
+ slug: 'videos/align-duration',
+ },
{
id: 'videos/as-threejs-texture',
title: 'Using a video as a texture in Three.js',
@@ -7969,6 +7931,15 @@ export const articles = [
noAi: false,
slug: 'videos/as-threejs-texture',
},
+ {
+ id: 'videos/different-segments-at-different-speeds',
+ title: 'Different segments at different speeds',
+ relativePath: 'docs/videos/different-segments-at-different-speeds.mdx',
+ compId: 'articles-docs-videos-different-segments-at-different-speeds',
+ crumb: 'Snippets',
+ noAi: false,
+ slug: 'videos/different-segments-at-different-speeds',
+ },
{
id: 'videos/index',
title: 'Embedding videos into Remotion',
@@ -7978,6 +7949,24 @@ export const articles = [
noAi: false,
slug: 'videos/index',
},
+ {
+ id: 'videos/jumpcuts',
+ title: 'Jump Cutting',
+ relativePath: 'docs/videos/jumpcuts.mdx',
+ compId: 'articles-docs-videos-jumpcuts',
+ crumb: 'Snippets',
+ noAi: false,
+ slug: 'videos/jumpcuts',
+ },
+ {
+ id: 'videos/media-fragments',
+ title: '#t= Media Fragments',
+ relativePath: 'docs/videos/media-fragments.mdx',
+ compId: 'articles-docs-videos-media-fragments',
+ crumb: 'Video behavior',
+ noAi: false,
+ slug: 'videos/media-fragments',
+ },
{
id: 'videos/sequence',
title: 'Playing videos in sequence',
@@ -7996,6 +7985,15 @@ export const articles = [
noAi: false,
slug: 'videos/transparency',
},
+ {
+ id: 'videos/video-manipulation',
+ title: 'Video manipulation',
+ relativePath: 'docs/videos/video-manipulation.mdx',
+ compId: 'articles-docs-videos-video-manipulation',
+ crumb: 'How To',
+ noAi: false,
+ slug: 'videos/video-manipulation',
+ },
{
id: 'visual-editing',
title: 'Edit default props visually',
diff --git a/packages/docs/static/generated/articles-docs-hls.png b/packages/docs/static/generated/articles-docs-hls.png
index 4646fa0cda..26ea77aaf2 100644
Binary files a/packages/docs/static/generated/articles-docs-hls.png and b/packages/docs/static/generated/articles-docs-hls.png differ
diff --git a/packages/docs/static/generated/articles-docs-media-fragments.png b/packages/docs/static/generated/articles-docs-media-fragments.png
deleted file mode 100644
index 609cffc8d7..0000000000
Binary files a/packages/docs/static/generated/articles-docs-media-fragments.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-miscellaneous-snippets-accelerated-video.png b/packages/docs/static/generated/articles-docs-miscellaneous-snippets-accelerated-video.png
deleted file mode 100644
index 8e72a4c1ec..0000000000
Binary files a/packages/docs/static/generated/articles-docs-miscellaneous-snippets-accelerated-video.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-miscellaneous-snippets-align-duration.png b/packages/docs/static/generated/articles-docs-miscellaneous-snippets-align-duration.png
deleted file mode 100644
index dcccff0462..0000000000
Binary files a/packages/docs/static/generated/articles-docs-miscellaneous-snippets-align-duration.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-miscellaneous-snippets-different-segments-at-different-speeds.png b/packages/docs/static/generated/articles-docs-miscellaneous-snippets-different-segments-at-different-speeds.png
deleted file mode 100644
index f8bd6ca50a..0000000000
Binary files a/packages/docs/static/generated/articles-docs-miscellaneous-snippets-different-segments-at-different-speeds.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-miscellaneous-snippets-freeze-portions.png b/packages/docs/static/generated/articles-docs-miscellaneous-snippets-freeze-portions.png
index f1f5430a7c..bbfe531a9f 100644
Binary files a/packages/docs/static/generated/articles-docs-miscellaneous-snippets-freeze-portions.png and b/packages/docs/static/generated/articles-docs-miscellaneous-snippets-freeze-portions.png differ
diff --git a/packages/docs/static/generated/articles-docs-miscellaneous-snippets-jumpcuts.png b/packages/docs/static/generated/articles-docs-miscellaneous-snippets-jumpcuts.png
deleted file mode 100644
index 0e7332236d..0000000000
Binary files a/packages/docs/static/generated/articles-docs-miscellaneous-snippets-jumpcuts.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-shapes-callout.png b/packages/docs/static/generated/articles-docs-shapes-callout.png
new file mode 100644
index 0000000000..bb75f3deb9
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-shapes-callout.png differ
diff --git a/packages/docs/static/generated/articles-docs-shapes-make-callout.png b/packages/docs/static/generated/articles-docs-shapes-make-callout.png
new file mode 100644
index 0000000000..6067473966
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-shapes-make-callout.png differ
diff --git a/packages/docs/static/generated/articles-docs-video-manipulation.png b/packages/docs/static/generated/articles-docs-video-manipulation.png
deleted file mode 100644
index 95729aaf2b..0000000000
Binary files a/packages/docs/static/generated/articles-docs-video-manipulation.png and /dev/null differ
diff --git a/packages/docs/static/generated/articles-docs-video-tags.png b/packages/docs/static/generated/articles-docs-video-tags.png
index 8ef39e956b..4da4839edd 100644
Binary files a/packages/docs/static/generated/articles-docs-video-tags.png and b/packages/docs/static/generated/articles-docs-video-tags.png differ
diff --git a/packages/docs/static/generated/articles-docs-videos-accelerated-video.png b/packages/docs/static/generated/articles-docs-videos-accelerated-video.png
new file mode 100644
index 0000000000..350ec2befd
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-videos-accelerated-video.png differ
diff --git a/packages/docs/static/generated/articles-docs-videos-align-duration.png b/packages/docs/static/generated/articles-docs-videos-align-duration.png
new file mode 100644
index 0000000000..5d91021ec6
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-videos-align-duration.png differ
diff --git a/packages/docs/static/generated/articles-docs-videos-different-segments-at-different-speeds.png b/packages/docs/static/generated/articles-docs-videos-different-segments-at-different-speeds.png
new file mode 100644
index 0000000000..c148b07507
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-videos-different-segments-at-different-speeds.png differ
diff --git a/packages/docs/static/generated/articles-docs-videos-jumpcuts.png b/packages/docs/static/generated/articles-docs-videos-jumpcuts.png
new file mode 100644
index 0000000000..7152024bc2
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-videos-jumpcuts.png differ
diff --git a/packages/docs/static/generated/articles-docs-videos-media-fragments.png b/packages/docs/static/generated/articles-docs-videos-media-fragments.png
new file mode 100644
index 0000000000..1272860706
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-videos-media-fragments.png differ
diff --git a/packages/docs/static/generated/articles-docs-videos-video-manipulation.png b/packages/docs/static/generated/articles-docs-videos-video-manipulation.png
new file mode 100644
index 0000000000..244b54958b
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-videos-video-manipulation.png differ
diff --git a/packages/docs/vercel.ts b/packages/docs/vercel.ts
index 2ac4203308..13bc3d9caf 100644
--- a/packages/docs/vercel.ts
+++ b/packages/docs/vercel.ts
@@ -127,6 +127,48 @@ export const config: VercelConfig = {
routes.redirect('/docs/miscellaneous/snippets/hls', '/docs/hls', {
permanent: true,
}),
+ routes.redirect(
+ '/docs/miscellaneous/snippets/align-duration',
+ '/docs/videos/align-duration',
+ {permanent: true},
+ ),
+ routes.redirect(
+ '/docs/miscellaneous/snippets/accelerated-video',
+ '/docs/videos/accelerated-video',
+ {permanent: true},
+ ),
+ routes.redirect(
+ '/docs/miscellaneous/snippets/jumpcuts',
+ '/docs/videos/jumpcuts',
+ {permanent: true},
+ ),
+ routes.redirect(
+ '/docs/miscellaneous/snippets/different-segments-at-different-speeds',
+ '/docs/videos/different-segments-at-different-speeds',
+ {permanent: true},
+ ),
+ routes.redirect(
+ '/docs/videos/freeze-portions',
+ '/docs/miscellaneous/snippets/freeze-portions',
+ {permanent: true},
+ ),
+ routes.redirect(
+ '/docs/video-manipulation',
+ '/docs/videos/video-manipulation',
+ {permanent: true},
+ ),
+ routes.redirect('/docs/videos/greenscreen', '/docs/greenscreen', {
+ permanent: true,
+ }),
+ routes.redirect('/docs/videos/video-tags', '/docs/video-tags', {
+ permanent: true,
+ }),
+ routes.redirect('/docs/videos/hls', '/docs/hls', {
+ permanent: true,
+ }),
+ routes.redirect('/docs/media-fragments', '/docs/videos/media-fragments', {
+ permanent: true,
+ }),
routes.redirect('/docs/player/api', '/docs/player/player', {
permanent: true,
}),
@@ -281,9 +323,11 @@ export const config: VercelConfig = {
'/docs/animation-math',
{permanent: false},
),
- routes.redirect('/docs/video-vs-offthreadvideo', '/docs/video-tags', {
- permanent: false,
- }),
+ routes.redirect(
+ '/docs/video-vs-offthreadvideo',
+ '/docs/video-tags',
+ {permanent: false},
+ ),
routes.redirect(
'/bbb.webm',
'https://upload.wikimedia.org/wikipedia/commons/transcoded/c/c0/Big_Buck_Bunny_4K.webm/Big_Buck_Bunny_4K.webm.720p.vp9.webm',
diff --git a/packages/example/src/DifferentSegmentsAtDifferentSpeeds.tsx b/packages/example/src/DifferentSegmentsAtDifferentSpeeds.tsx
new file mode 100644
index 0000000000..2daa8c9b50
--- /dev/null
+++ b/packages/example/src/DifferentSegmentsAtDifferentSpeeds.tsx
@@ -0,0 +1,82 @@
+import {Video} from '@remotion/media';
+import React from 'react';
+import {AbsoluteFill, Series, useVideoConfig} from 'remotion';
+
+const src = 'https://remotion.media/video.mp4';
+
+const segments = [
+ {
+ duration: 60,
+ speed: 0.5,
+ },
+ {
+ duration: 60,
+ speed: 1,
+ },
+ {
+ duration: 120,
+ speed: 2,
+ },
+ {
+ duration: 60,
+ speed: 4,
+ },
+];
+
+type AccumulatedSegment = {
+ start: number;
+ passedVideoTime: number;
+ end: number;
+ speed: number;
+};
+
+const accumulateSegments = () => {
+ const accumulatedSegments: AccumulatedSegment[] = [];
+ let accumulatedDuration = 0;
+ let accumulatedPassedVideoTime = 0;
+
+ for (const segment of segments) {
+ const duration = segment.duration / segment.speed;
+ accumulatedSegments.push({
+ end: accumulatedDuration + duration,
+ speed: segment.speed,
+ start: accumulatedDuration,
+ passedVideoTime: accumulatedPassedVideoTime,
+ });
+ accumulatedPassedVideoTime += segment.duration;
+ accumulatedDuration += duration;
+ }
+
+ return accumulatedSegments;
+};
+
+const accumulatedSegments = accumulateSegments();
+
+export const DIFFERENT_SEGMENTS_AT_DIFFERENT_SPEEDS_DURATION = Math.ceil(
+ accumulatedSegments[accumulatedSegments.length - 1].end,
+);
+
+export const DifferentSegmentsAtDifferentSpeeds: React.FC = () => {
+ const {fps} = useVideoConfig();
+
+ return (
+ <AbsoluteFill style={{backgroundColor: 'black'}}>
+ <Series>
+ {accumulatedSegments.map((segment) => (
+ <Series.Sequence
+ key={segment.start}
+ durationInFrames={segment.end - segment.start}
+ premountFor={Math.round(1.5 * fps)}
+ >
+ <Video
+ src={src}
+ trimBefore={segment.passedVideoTime}
+ playbackRate={segment.speed}
+ debugOverlay
+ />
+ </Series.Sequence>
+ ))}
+ </Series>
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/example/src/JumpCuts.tsx b/packages/example/src/JumpCuts.tsx
index 97ac65c16a..cd3bf6aa38 100644
--- a/packages/example/src/JumpCuts.tsx
+++ b/packages/example/src/JumpCuts.tsx
@@ -72,7 +72,7 @@ export const JumpCuts: React.FC<Props> = ({sections}) => {
trimBefore={cut.trimBefore}
// Remotion will automatically add a time fragment to the end of the video URL
// based on `trimBefore` and `trimAfter`. Opt out of this by adding one yourself.
- // https://www.remotion.dev/docs/media-fragments
+ // https://www.remotion.dev/docs/videos/media-fragments
src={`https://remotion.media/BigBuckBunny.mp4#t=0,`}
// Force Remotion to seek when it jumps even just a tiny bit
acceptableTimeShiftInSeconds={
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index a214694334..0bd41e3e36 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -25,6 +25,10 @@ import CorruptVideo from './CorruptVideo';
import {CssLoaderTest} from './CssLoaderTest';
import {DarkModeTest} from './DarkModeTest';
import {DecoderDemo} from './DecoderDemo';
+import {
+ DIFFERENT_SEGMENTS_AT_DIFFERENT_SPEEDS_DURATION,
+ DifferentSegmentsAtDifferentSpeeds,
+} from './DifferentSegmentsAtDifferentSpeeds';
import {
DiscriminatedUnionSchemaTest,
discriminatedUnionRootSchema,
@@ -1420,6 +1424,14 @@ export const Index: React.FC = () => {
playRanges: PLAY_RANGES_MEDIA_ZIP_DEFAULT,
}}
/>
+ <Composition
+ id="different-segments-at-different-speeds"
+ component={DifferentSegmentsAtDifferentSpeeds}
+ width={640}
+ height={360}
+ fps={30}
+ durationInFrames={DIFFERENT_SEGMENTS_AT_DIFFERENT_SPEEDS_DURATION}
+ />
<Composition
id="fractional-sequence-video"
component={FractionalSequenceVideo}