🎥 Make videos programmatically with React
fix docs
Jonny Burgercdbbecb5d9b7
diff --git a/packages/docs/docs/miscellaneous/snippets/fps-converter.md b/packages/docs/docs/miscellaneous/snippets/fps-converter.mdindex 7cd82f4fab..281bd30d24 100644--- a/packages/docs/docs/miscellaneous/snippets/fps-converter.md+++ b/packages/docs/docs/miscellaneous/snippets/fps-converter.md@@ -41,7 +41,7 @@ export const MyComp = () => {// @filename: "FpsConverter.tsx"import React, { useContext, useMemo } from "react";-import { Internals, TimelineContextValue } from "remotion";+import { Internals, TimelineContextValue, useVideoConfig } from "remotion";export const FpsConverter: React.FC<{originalFps: number;@@ -50,11 +50,15 @@ export const FpsConverter: React.FC<{}> = ({ originalFps, newFps, children }) => {const context = useContext(Internals.Timeline.TimelineContext);const ratio = originalFps / newFps;+ const { id } = useVideoConfig();const value: TimelineContextValue = useMemo(() => {return {...context,- frame: context.frame * ratio,+ // Remotion 4.0+ frame: { [id]: context.frame * ratio },+ // Remotion 3.0+ // frame: context.frame * ratio,};}, [context, ratio]);diff --git a/packages/docs/docs/troubleshooting/video-flicker.md b/packages/docs/docs/troubleshooting/video-flicker.mdindex a9186d9bd0..2f33be4b20 100644--- a/packages/docs/docs/troubleshooting/video-flicker.md+++ b/packages/docs/docs/troubleshooting/video-flicker.md@@ -62,7 +62,7 @@ As the most aggressive strategy, you can pre-mount a video to already trigger de```tsx twoslash title="Premount.tsx"import React, { useContext, useMemo } from "react";-import { Internals, TimelineContextValue } from "remotion";+import { Internals, TimelineContextValue, useVideoConfig } from "remotion";type PremountProps = {for: number;@@ -74,6 +74,7 @@ export const Premount: React.FC<PremountProps> = ({children,}) => {const sequenceContext = useContext(Internals.SequenceContext);+ const { id } = useVideoConfig();if (typeof premountFor === "undefined") {throw new Error(`The <Premount /> component requires a 'for' prop, but none was passed.`@@ -114,7 +115,10 @@ export const Premount: React.FC<PremountProps> = ({? false: context.imperativePlaying.current,},- frame: Math.max(0, currentFrame - premountFor) + contextOffset,+ // Remotion v4+ frame: { [id]: Math.max(0, currentFrame - premountFor) + contextOffset },+ // Remotion v3+ // frame: Math.max(0, currentFrame - premountFor) + contextOffset,};}, [context, premountFor, sequenceContext]);@@ -130,7 +134,7 @@ The following usage would make the video mount 60 frames before it appears in th```tsx twoslash title="MyComponent.tsx"import React, { useContext, useMemo } from "react";-import { Internals, TimelineContextValue } from "remotion";+import { Internals, TimelineContextValue, useVideoConfig } from "remotion";type PremountProps = {for: number;@@ -141,6 +145,7 @@ export const Premount: React.FC<PremountProps> = ({for: premountFor,children,}) => {+ const { id } = useVideoConfig();const sequenceContext = useContext(Internals.SequenceContext);if (typeof premountFor === "undefined") {throw new Error(@@ -182,7 +187,10 @@ export const Premount: React.FC<PremountProps> = ({? false: context.imperativePlaying.current,},- frame: Math.max(0, currentFrame - premountFor) + contextOffset,+ // Remotion v4+ frame: { [id]: Math.max(0, currentFrame - premountFor) + contextOffset },+ // Remotion v3+ // frame: Math.max(0, currentFrame - premountFor) + contextOffset,};}, [context, premountFor, sequenceContext]);