🎥 Make videos programmatically with React
Update playback rate docs and example sources
Jonny Burgera6644e93cba1
diff --git a/packages/docs/components/shapes/shapes-info.tsx b/packages/docs/components/shapes/shapes-info.tsxindex af9f0a9509..df975ccac7 100644--- a/packages/docs/components/shapes/shapes-info.tsx+++ b/packages/docs/components/shapes/shapes-info.tsx@@ -554,6 +554,10 @@ export const ShapeOptions: React.FC<{<code>trimBefore</code></a><AvailableFrom v="4.0.482" inline />,{' '}+ <a href="/docs/sequence#playbackrate">+ <code>playbackRate</code>+ </a>+ ,{' '}<a href="/docs/sequence#name"><code>name</code></a>diff --git a/packages/docs/docs/absolute-fill.mdx b/packages/docs/docs/absolute-fill.mdxindex 134b599c7d..9f53695169 100644--- a/packages/docs/docs/absolute-fill.mdx+++ b/packages/docs/docs/absolute-fill.mdx@@ -49,7 +49,7 @@ The layers that get rendered last appear on top - this is because of how HTML wo### Inherited props<AvailableFrom v="4.0.501" />-`<AbsoluteFill>` inherits [`from`](/docs/sequence#from), [`durationInFrames`](/docs/sequence#durationinframes), [`trimBefore`](/docs/sequence#trimbefore), [`freeze`](/docs/sequence#freeze), [`hidden`](/docs/sequence#hidden), [`name`](/docs/sequence#name) and [`showInTimeline`](/docs/sequence#showintimeline) from [`<Sequence>`](/docs/sequence).+`<AbsoluteFill>` inherits [`from`](/docs/sequence#from), [`durationInFrames`](/docs/sequence#durationinframes), [`trimBefore`](/docs/sequence#trimbefore), [`playbackRate`](/docs/sequence#playbackrate), [`freeze`](/docs/sequence#freeze), [`hidden`](/docs/sequence#hidden), [`name`](/docs/sequence#name) and [`showInTimeline`](/docs/sequence#showintimeline) from [`<Sequence>`](/docs/sequence).It is registered as a layer in the [Remotion Studio](/docs/studio) timeline.diff --git a/packages/docs/docs/canvasimage.mdx b/packages/docs/docs/canvasimage.mdxindex c30406023f..cb486b2823 100644--- a/packages/docs/docs/canvasimage.mdx+++ b/packages/docs/docs/canvasimage.mdx@@ -132,7 +132,7 @@ Passed directly to the `timeoutInMilliseconds` option of `delayRender()`.### Inherited props-`<CanvasImage>` inherits [`from`](/docs/sequence#from), [`durationInFrames`](/docs/sequence#durationinframes), [`trimBefore`](/docs/sequence#trimbefore)<AvailableFrom v="4.0.482" inline />, [`name`](/docs/sequence#name), [`showInTimeline`](/docs/sequence#showintimeline) and [`hidden`](/docs/sequence#hidden) from [`<Sequence>`](/docs/sequence).+`<CanvasImage>` inherits [`from`](/docs/sequence#from), [`durationInFrames`](/docs/sequence#durationinframes), [`trimBefore`](/docs/sequence#trimbefore)<AvailableFrom v="4.0.482" inline />, [`playbackRate`](/docs/sequence#playbackrate), [`name`](/docs/sequence#name), [`showInTimeline`](/docs/sequence#showintimeline) and [`hidden`](/docs/sequence#hidden) from [`<Sequence>`](/docs/sequence).## Adding a refdiff --git a/packages/docs/docs/img.mdx b/packages/docs/docs/img.mdxindex 9e7a5c918f..e50c4303a2 100644--- a/packages/docs/docs/img.mdx+++ b/packages/docs/docs/img.mdx@@ -158,7 +158,7 @@ Prefer the [`maxRetries`](#maxretries) prop over this.### Inherited props<AvailableFrom v="4.0.465" />-`<Img>` inherits [`from`](/docs/sequence#from), [`durationInFrames`](/docs/sequence#durationinframes), [`trimBefore`](/docs/sequence#trimbefore)<AvailableFrom v="4.0.482" inline />, [`name`](/docs/sequence#name), [`showInTimeline`](/docs/sequence#showintimeline) and [`hidden`](/docs/sequence#hidden) from [`<Sequence>`](/docs/sequence).+`<Img>` inherits [`from`](/docs/sequence#from), [`durationInFrames`](/docs/sequence#durationinframes), [`trimBefore`](/docs/sequence#trimbefore)<AvailableFrom v="4.0.482" inline />, [`playbackRate`](/docs/sequence#playbackrate), [`name`](/docs/sequence#name), [`showInTimeline`](/docs/sequence#showintimeline) and [`hidden`](/docs/sequence#hidden) from [`<Sequence>`](/docs/sequence).:::noteYou can still wrap `<Img>` in an outer [`<Sequence>`](/docs/sequence). Timing [cascades](/docs/sequence#cascading) like nested sequences.diff --git a/packages/docs/docs/interactive.mdx b/packages/docs/docs/interactive.mdxindex 9c8629a0e2..d0b2ece848 100644--- a/packages/docs/docs/interactive.mdx+++ b/packages/docs/docs/interactive.mdx@@ -74,8 +74,6 @@ Controls inherited from [`<Sequence>`](/docs/sequence):`durationInFrames`, `from`, `trimBefore`, `playbackRate`, `freeze`, `hidden`, `name` and `showInTimeline`.-`playbackRate` is included from <AvailableFrom v="4.0.528" inline /> and cannot be keyframed.-Use it for components that render a `<Sequence>` internally.```tsx twoslash title="schema.ts"diff --git a/packages/docs/docs/interactivity-schema.mdx b/packages/docs/docs/interactivity-schema.mdxindex 9b115ea107..08bdd2ca49 100644--- a/packages/docs/docs/interactivity-schema.mdx+++ b/packages/docs/docs/interactivity-schema.mdx@@ -37,7 +37,7 @@ Keys may use dot notation. For example, a key named `style.opacity` reads from a### `Interactive.baseSchema`-Timeline props inherited from [`<Sequence>`](/docs/sequence): [`durationInFrames`](/docs/sequence#durationinframes), [`from`](/docs/sequence#from), [`trimBefore`](/docs/sequence#trimbefore), [`freeze`](/docs/sequence#freeze), [`hidden`](/docs/sequence#hidden), [`name`](/docs/sequence#name) and [`showInTimeline`](/docs/sequence#showintimeline).+Timeline props inherited from [`<Sequence>`](/docs/sequence): [`durationInFrames`](/docs/sequence#durationinframes), [`from`](/docs/sequence#from), [`trimBefore`](/docs/sequence#trimbefore), [`playbackRate`](/docs/sequence#playbackrate), [`freeze`](/docs/sequence#freeze), [`hidden`](/docs/sequence#hidden), [`name`](/docs/sequence#name) and [`showInTimeline`](/docs/sequence#showintimeline).### `Interactive.captionsSchema`<AvailableFrom v="4.0.500" />diff --git a/packages/docs/docs/loop.mdx b/packages/docs/docs/loop.mdxindex 581fc97914..7fc484eac0 100644--- a/packages/docs/docs/loop.mdx+++ b/packages/docs/docs/loop.mdx@@ -41,7 +41,7 @@ The Loop component is a high order component and accepts, besides it's children,How many frames one iteration of the loop should be long.-### `playbackRate?`<AvailableFrom v="4.0.528" />+### `playbackRate?`Changes the speed of the children within each iteration. Defaults to `1` and must remain constant across frames. Each iteration still lasts `durationInFrames` frames in the parent timeline. See [`playbackRate`](/docs/sequence#playbackrate) on [`<Sequence>`](/docs/sequence).diff --git a/packages/docs/docs/mac-cursors/mac-os-cursor.mdx b/packages/docs/docs/mac-cursors/mac-os-cursor.mdxindex 31082bc845..550ef5f121 100644--- a/packages/docs/docs/mac-cursors/mac-os-cursor.mdx+++ b/packages/docs/docs/mac-cursors/mac-os-cursor.mdx@@ -74,7 +74,7 @@ CSS styles for the cursor image. Use `left` and `top` to position it without cha### Timing and display props-The component also accepts [`InteractiveBaseProps`](/docs/interactive#interactivebaseprops), including `durationInFrames`, `from`, `trimBefore`, `freeze`, `hidden`, `name`, and `showInTimeline`.+The component also accepts [`InteractiveBaseProps`](/docs/interactive#interactivebaseprops), including `durationInFrames`, `from`, `trimBefore`, `playbackRate`, `freeze`, `hidden`, `name`, and `showInTimeline`.## Compatibilitydiff --git a/packages/docs/docs/remotion/html-in-canvas.mdx b/packages/docs/docs/remotion/html-in-canvas.mdxindex 1facc7757d..32dc40bdc1 100644--- a/packages/docs/docs/remotion/html-in-canvas.mdx+++ b/packages/docs/docs/remotion/html-in-canvas.mdx@@ -153,6 +153,10 @@ Inherited from [`<Sequence>`](/docs/sequence#from).Inherited from [`<Sequence>`](/docs/sequence#trimbefore).+### `playbackRate?`++Inherited from [`<Sequence>`](/docs/sequence#playbackrate).+### `ref?`You can add a [React ref](https://react.dev/learn/manipulating-the-dom-with-refs) to `<HtmlInCanvas />`.diff --git a/packages/docs/docs/rive/remotionrivecanvas.mdx b/packages/docs/docs/rive/remotionrivecanvas.mdxindex f1f529db19..9786c04320 100644--- a/packages/docs/docs/rive/remotionrivecanvas.mdx+++ b/packages/docs/docs/rive/remotionrivecanvas.mdx@@ -143,7 +143,7 @@ Crops the canvas from the bottom by a ratio between `0` and `1`. See [`cropBotto## Inherited props<AvailableFrom v="4.0.464" />-`<RemotionRiveCanvas>` inherits [`from`](/docs/sequence#from), [`durationInFrames`](/docs/sequence#durationinframes), [`trimBefore`](/docs/sequence#trimbefore)<AvailableFrom v="4.0.482" inline />, [`name`](/docs/sequence#name), [`showInTimeline`](/docs/sequence#showintimeline) and [`hidden`](/docs/sequence#hidden) from [`<Sequence>`](/docs/sequence).+`<RemotionRiveCanvas>` inherits [`from`](/docs/sequence#from), [`durationInFrames`](/docs/sequence#durationinframes), [`trimBefore`](/docs/sequence#trimbefore)<AvailableFrom v="4.0.482" inline />, [`playbackRate`](/docs/sequence#playbackrate), [`name`](/docs/sequence#name), [`showInTimeline`](/docs/sequence#showintimeline) and [`hidden`](/docs/sequence#hidden) from [`<Sequence>`](/docs/sequence).## Ref<AvailableFrom v="4.0.180" />diff --git a/packages/docs/docs/rough-notation/index.mdx b/packages/docs/docs/rough-notation/index.mdxindex f73c0681aa..a9c1583f64 100644--- a/packages/docs/docs/rough-notation/index.mdx+++ b/packages/docs/docs/rough-notation/index.mdx@@ -65,7 +65,7 @@ Set to `true` to prevent Rough.js from drawing multiple strokes for a line. DefaPreserves vertices when roughening a shape. Default: `false`.-The components are interactive in Remotion Studio. They support editable text and font controls, as well as the following [`<Sequence>`](/docs/sequence) props: `durationInFrames`, `from`, `trimBefore`, `freeze`, `hidden`, `name` and `showInTimeline`.+The components are interactive in Remotion Studio. They support editable text and font controls, as well as the following [`<Sequence>`](/docs/sequence) props: `durationInFrames`, `from`, `trimBefore`, `playbackRate`, `freeze`, `hidden`, `name` and `showInTimeline`.## Licensediff --git a/packages/docs/docs/sequence.mdx b/packages/docs/docs/sequence.mdxindex c1dfafd83f..91e9f7e945 100644--- a/packages/docs/docs/sequence.mdx+++ b/packages/docs/docs/sequence.mdx@@ -216,10 +216,10 @@ export const MyVideo = () => {In the example above, `Child` mounts at composition frame `30` and receives frame `15`.-### `playbackRate?`<AvailableFrom v="4.0.528" />+### `playbackRate?`Changes the speed of the children, including their animations and media. Default: `1`.-Use `2` for double speed or `0.5` for half speed. The value must be positive and finite, and must remain constant across frames. It cannot be keyframed.+Use `2` for double speed or `0.5` for half speed. The value must be positive and finite, and must remain constant across frames.`from` and `durationInFrames` are measured in the parent timeline. Changing `playbackRate` does not change when the sequence mounts or unmounts.`trimBefore` is measured in the children's frames and is applied after the speed change:diff --git a/packages/docs/docs/series.mdx b/packages/docs/docs/series.mdxindex 5aafd5480a..3d07344a9e 100644--- a/packages/docs/docs/series.mdx+++ b/packages/docs/docs/series.mdx@@ -79,7 +79,7 @@ The offset does not apply to sequences that come before, but the sequences thatTrims frames from the beginning without changing where the sequence starts. See [`trimBefore`](/docs/sequence#trimbefore) on [`<Sequence>`](/docs/sequence).-### `playbackRate?`<AvailableFrom v="4.0.528" />+### `playbackRate?`Changes the speed of the children. Defaults to `1` and must remain constant across frames. See [`playbackRate`](/docs/sequence#playbackrate) on [`<Sequence>`](/docs/sequence).The sequence's duration and the next sequence's start remain unchanged. Setting `playbackRate` on `<Series>` speeds up the whole series, including transitions between its sequences.diff --git a/packages/docs/docs/solid.mdx b/packages/docs/docs/solid.mdxindex 14e807cb95..871e8cd600 100644--- a/packages/docs/docs/solid.mdx+++ b/packages/docs/docs/solid.mdx@@ -88,7 +88,7 @@ Crops the canvas from the bottom by a ratio between 0 and 1. See [`cropBottom`](### Inherited props-`<Solid>` inherits [`from`](/docs/sequence#from), [`durationInFrames`](/docs/sequence#durationinframes), [`trimBefore`](/docs/sequence#trimbefore)<AvailableFrom v="4.0.482" inline />, [`name`](/docs/sequence#name), [`showInTimeline`](/docs/sequence#showintimeline) and [`hidden`](/docs/sequence#hidden) from [`<Sequence>`](/docs/sequence).+`<Solid>` inherits [`from`](/docs/sequence#from), [`durationInFrames`](/docs/sequence#durationinframes), [`trimBefore`](/docs/sequence#trimbefore)<AvailableFrom v="4.0.482" inline />, [`playbackRate`](/docs/sequence#playbackrate), [`name`](/docs/sequence#name), [`showInTimeline`](/docs/sequence#showintimeline) and [`hidden`](/docs/sequence#hidden) from [`<Sequence>`](/docs/sequence).## Adding a refdiff --git a/packages/docs/docs/studio/make-component-interactive.mdx b/packages/docs/docs/studio/make-component-interactive.mdxindex a085c4e36c..42da5b42a8 100644--- a/packages/docs/docs/studio/make-component-interactive.mdx+++ b/packages/docs/docs/studio/make-component-interactive.mdx@@ -15,7 +15,7 @@ For code that remains editable after visual changes, follow [Interactivity bestAn [`InteractivitySchema`](/docs/interactivity-schema) describes which props the Studio may edit.-Use [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema) for props inherited from [`<Sequence>`](/docs/sequence), such as [`from`](/docs/sequence#from), [`trimBefore`](/docs/sequence#trimbefore), [`durationInFrames`](/docs/sequence#durationinframes), [`freeze`](/docs/sequence#freeze), [`hidden`](/docs/sequence#hidden), [`name`](/docs/sequence#name) and [`showInTimeline`](/docs/sequence#showintimeline).+Use [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema) for props inherited from [`<Sequence>`](/docs/sequence), such as [`from`](/docs/sequence#from), [`trimBefore`](/docs/sequence#trimbefore), [`playbackRate`](/docs/sequence#playbackrate), [`durationInFrames`](/docs/sequence#durationinframes), [`freeze`](/docs/sequence#freeze), [`hidden`](/docs/sequence#hidden), [`name`](/docs/sequence#name) and [`showInTimeline`](/docs/sequence#showintimeline).As a rule, include `Interactive.baseSchema` in every schema passed to `Interactive.withSchema()` so trimming and visibility controls remain available.diff --git a/packages/docs/docs/transitions/transitionseries.mdx b/packages/docs/docs/transitions/transitionseries.mdxindex ab0e5a2706..6466566e74 100644--- a/packages/docs/docs/transitions/transitionseries.mdx+++ b/packages/docs/docs/transitions/transitionseries.mdx@@ -83,7 +83,7 @@ export const OverlayExample: React.FC = () => {### `<TransitionSeries>`-Inherits the [`from`](/docs/sequence#from), [`name`](/docs/sequence#name), [`className`](/docs/sequence#classname), and [`style`](/docs/sequence#style) props from [`<Sequence>`](/docs/sequence).+Inherits the [`from`](/docs/sequence#from), [`playbackRate`](/docs/sequence#playbackrate), [`name`](/docs/sequence#name), [`className`](/docs/sequence#classname), and [`style`](/docs/sequence#style) props from [`<Sequence>`](/docs/sequence).The `<TransitionSeries>` component can only contain `<TransitionSeries.Sequence>`, `<TransitionSeries.Transition>`, and `<TransitionSeries.Overlay>` components.`layout="none"` is deprecated and throws from Remotion 5.0.0 on.@@ -91,15 +91,13 @@ Transition scenes must stay absolutely positioned. Remove the `layout` prop or k### `<TransitionSeries.Sequence>`-Inherits the [`durationInFrames`](/docs/sequence#durationinframes), [`name`](/docs/sequence#name), [`className`](/docs/sequence#classname), [`style`](/docs/sequence#style), [`showInTimeline`](/docs/sequence#showintimeline), [`freeze`](/docs/sequence#freeze), [`premountFor`](/docs/sequence#premountfor) and [`postmountFor`](/docs/sequence#postmountfor) props from [`<Sequence>`](/docs/sequence).+Inherits the [`durationInFrames`](/docs/sequence#durationinframes), [`playbackRate`](/docs/sequence#playbackrate), [`name`](/docs/sequence#name), [`className`](/docs/sequence#classname), [`style`](/docs/sequence#style), [`showInTimeline`](/docs/sequence#showintimeline), [`freeze`](/docs/sequence#freeze), [`premountFor`](/docs/sequence#premountfor) and [`postmountFor`](/docs/sequence#postmountfor) props from [`<Sequence>`](/docs/sequence).`layout="none"` is deprecated and throws from Remotion 5.0.0 on.Transition scenes must stay absolutely positioned. Remove the `layout` prop or keep the default `absolute-fill`. See the [v5 migration guide](/docs/5-0-migration).The [`trimBefore`](/docs/sequence#trimbefore) prop is supported from <AvailableFrom v="4.0.497" inline />.-The [`playbackRate`](/docs/sequence#playbackrate) prop is supported from <AvailableFrom v="4.0.528" inline /> on both `<TransitionSeries>` and `<TransitionSeries.Sequence>`. It defaults to `1` and must remain constant across frames. A sequence's rate changes its content without changing its duration or transition timing. A rate on `<TransitionSeries>` speeds up the entire series, including its transitions.-As children, put the contents of your scene.### `<TransitionSeries.Transition>`diff --git a/packages/docs/docs/use-video-config.mdx b/packages/docs/docs/use-video-config.mdxindex 9a30efba05..ed8105be86 100644--- a/packages/docs/docs/use-video-config.mdx+++ b/packages/docs/docs/use-video-config.mdx@@ -46,7 +46,7 @@ If inside a [`<Sequence>`](/docs/sequence), the end of the sequence in its localIf not inside a [`<Sequence>`](/docs/sequence), the duration of the composition in frames.-From <AvailableFrom v="4.0.528" inline />, this accounts for [`playbackRate`](/docs/sequence#playbackrate) and [`trimBefore`](/docs/sequence#trimbefore). For example, a sequence visible for `40` parent frames with `playbackRate={2}` and `trimBefore={10}` returns `90`: `40 * 2 + 10`. Its children start at local frame `10` and unmount before local frame `90`.+This accounts for [`playbackRate`](/docs/sequence#playbackrate) and [`trimBefore`](/docs/sequence#trimbefore). For example, a sequence visible for `40` parent frames with `playbackRate={2}` and `trimBefore={10}` returns `90`: `40 * 2 + 10`. Its children start at local frame `10` and unmount before local frame `90`.### `id`diff --git a/packages/docs/elements/contributing.mdx b/packages/docs/elements/contributing.mdxindex c1fc44312a..b7e20f6fdf 100644--- a/packages/docs/elements/contributing.mdx+++ b/packages/docs/elements/contributing.mdx@@ -102,9 +102,9 @@ Wrap the exported component with [`Interactive.withSchema()`](/docs/interactive-Export the schema-enabled component directly and wire up the common props:- Add [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema) to every `Interactive.withSchema()` schema and pass `controls` unchanged to the component's `<Sequence>`.-- Pass `from`, `durationInFrames`, `trimBefore`, `freeze`, `hidden`, `name`, and `showInTimeline` to that Sequence.+- Pass `from`, `durationInFrames`, `trimBefore`, `playbackRate`, `freeze`, `hidden`, `name`, and `showInTimeline` to that Sequence.- Pass `style` and the ref to the rendered outline. When the Sequence uses `layout="none"`, pass [`outlineRef`](/docs/sequence#outlineref) to it. Set the dimensions in the component because Element metadata does not pass them as props.-- Render frame-dependent animation in a child below the Sequence. This makes [`useCurrentFrame()`](/docs/use-current-frame) respect `from`, `trimBefore`, and `freeze`. If the component that returns the Sequence calls it, it reads the parent clock.+- Render frame-dependent animation in a child below the Sequence. This makes [`useCurrentFrame()`](/docs/use-current-frame) respect `from`, `trimBefore`, `playbackRate`, and `freeze`. If the component that returns the Sequence calls it, it reads the parent clock.Export the schema-enabled component directly, without a forwarding wrapper. See the [oscilloscope](/elements/audio/oscilloscope), [waveform progress](/elements/audio/waveform-progress), and [mirrored spectrum](/elements/audio/mirrored-spectrum) Elements.diff --git a/packages/example/src/SequencePlaybackRateLoops.tsx b/packages/example/src/SequencePlaybackRateLoops.tsxindex 43882b8aa0..38bcbb14a3 100644--- a/packages/example/src/SequencePlaybackRateLoops.tsx+++ b/packages/example/src/SequencePlaybackRateLoops.tsx@@ -5,11 +5,10 @@ import {Freeze,Html5Video,Sequence,- staticFile,useCurrentFrame,} from 'remotion';-const src = staticFile('vp8-vorbis.webm');+const src = 'https://remotion.media/video.mp4';const videoStyle: CSSProperties = {width: '100%',height: 180,@@ -142,7 +141,12 @@ export const SequencePlaybackRateLoops = () => {description="Same clocks, trims, and rate through the native video path. Muted for comparison."><NestedClocks>- <Sequence from={17} durationInFrames={420} layout="none">+ <Sequence+ from={17}+ durationInFrames={420}+ layout="none"+ playbackRate={2.5}+ ><Html5Videoname="Native loop · source [197, 268) · 0.75×"src={src}diff --git a/packages/example/src/SequencePlaybackRateTestbed.tsx b/packages/example/src/SequencePlaybackRateTestbed.tsxindex 1dde261693..7ee69b9b09 100644--- a/packages/example/src/SequencePlaybackRateTestbed.tsx+++ b/packages/example/src/SequencePlaybackRateTestbed.tsx@@ -8,7 +8,7 @@ import {useCurrentFrame,} from 'remotion';-const video = staticFile('vp8-vorbis.webm');+const video = 'https://remotion.media/video.mp4';const mediaStyle: CSSProperties = {width: '100%',@@ -84,7 +84,7 @@ export const SequencePlaybackRateTestbed = () => {<Panel title="1. Video + audio inside a 2× sequence"><Sequencename="Sped-up video and audio · 2×"- playbackRate={2}+ playbackRate={3.1}layout="none"><Video@@ -98,6 +98,7 @@ export const SequencePlaybackRateTestbed = () => {name="Audio inherits 2×"src={staticFile('podcast.wav')}volume={0.6}+ toneFrequency={0.47}/><Clock label="Media parent frame" color="#58d9c1" /></Sequence>@@ -118,7 +119,7 @@ export const SequencePlaybackRateTestbed = () => {</AbsoluteFill><Sequencename="Trimmed video parent · 2×"- playbackRate={2}+ playbackRate={0.9}layout="none"><Video