🎥 Make videos programmatically with React
Skills: Use composition FPS for editable clip timing
JonnyBurgerc3d83b7a11da
diff --git a/packages/skills/skills/remotion-markup/SKILL.md b/packages/skills/skills/remotion-markup/SKILL.mdindex 315e6dbfb0..836615e0b0 100644--- a/packages/skills/skills/remotion-markup/SKILL.md+++ b/packages/skills/skills/remotion-markup/SKILL.md@@ -15,6 +15,13 @@ If you detect a surprising change made in the meanwhile, don't overwrite it, ass## General rules+Inside a composition or scene component, get `fps` from `useVideoConfig()` for+all seconds-to-frames calculations, including timing props such as `from`,+`trimBefore`, `durationInFrames`, and `premountFor`. Do not define a separate+`const FPS = 30` for these props. Keeping the expression on the JSX node, such+as `trimBefore={4 * fps}`, lets Studio edit the timing and keeps it correct if+the composition frame rate changes.+Drive animations using `useCurrentFrame()` and `interpolate()`.CSS `transition` or `animation` will not render correctly, they need to refactored.Tailwind animation class will not render correctly, they need to be refactored.diff --git a/packages/skills/skills/remotion-markup/timing-props.md b/packages/skills/skills/remotion-markup/timing-props.mdindex 9cf9e456f8..1336bbd9c0 100644--- a/packages/skills/skills/remotion-markup/timing-props.md+++ b/packages/skills/skills/remotion-markup/timing-props.md@@ -1,5 +1,9 @@## Delaying, trimming+In the component that renders these items, get `const {fps} = useVideoConfig()`.+Use this `fps` for seconds-to-frames expressions on the JSX node, rather than+a fixed FPS constant.+The following timing props are supported by built-in components (`<AbsoluteFill>`, `<Interactive.*>`, `<Img>`, `<AnimatedImage>`, `<CanvasImage>`, `<HtmlInCanvas>`, `<Solid>`, `<Sequence>` from `remotion`, `<Video>` and `<Audio>` from `@remotion/media`, `<Gif>`, and more).Custom components made with `Interactive.withSchema({wrapInSequence: true})` accept them too, see [Prefer interactive components with their own timelines](../remotion-interactivity/SKILL.md#prefer-interactive-components-with-their-own-timelines).Set `premountFor={fps}` on these timed items when they support it, includingdiff --git a/packages/skills/skills/remotion-markup/video-editing.md b/packages/skills/skills/remotion-markup/video-editing.mdindex d854415944..af8eab9f92 100644--- a/packages/skills/skills/remotion-markup/video-editing.md+++ b/packages/skills/skills/remotion-markup/video-editing.md@@ -23,11 +23,16 @@ Choose the timeline structure based on the editing behavior:Use `const {fps} = useVideoConfig()` in the enclosing composition and set`premountFor={fps}` on each timed clip, sequence, and overlay that supports it.When a clip is inside a series sequence, premount both the sequence and clip.+For trims and other timing props expressed in seconds, use that same `fps`+directly in each clip's JSX, for example `trimBefore={4 * fps}`. Do not use a+separate fixed `FPS` constant: Studio must be able to update each clip's source+expression when the user trims or splits it.## Independently positioned clips-Place every `<Video>` directly in the composition and hardcode its timing-props. `from={0}` may be omitted:+Place every `<Video>` directly in the composition and write its timing props+on the JSX node. Use literal frame counts when they are already known;+`from={0}` may be omitted:```tsx<Videodiff --git a/packages/skills/skills/remotion-markup/voiceover.md b/packages/skills/skills/remotion-markup/voiceover.mdindex f4b022c371..5a18438aa0 100644--- a/packages/skills/skills/remotion-markup/voiceover.md+++ b/packages/skills/skills/remotion-markup/voiceover.md@@ -61,7 +61,8 @@ Use [`calculateMetadata`](./calculate-metadata.md) to measure the [audio duratioimport { CalculateMetadataFunction, staticFile } from "remotion";import { getAudioDuration } from "./get-audio-duration";-const FPS = 30;+// Match the fps on this composition's <Composition> registration.+const compositionFps = 30;const SCENE_AUDIO_FILES = ["voiceover/my-comp/scene-01-intro.mp3",@@ -77,7 +78,7 @@ export const calculateMetadata: CalculateMetadataFunction<Props> = async ({);const sceneDurations = durations.map((durationInSeconds) => {- return durationInSeconds * FPS;+ return durationInSeconds * compositionFps;});return {@@ -87,6 +88,9 @@ export const calculateMetadata: CalculateMetadataFunction<Props> = async ({```The computed `sceneDurations` are passed into the component via a `voiceover` prop so the component knows how long each scene should be.+`calculateMetadata` runs outside the composition component, so it cannot call+`useVideoConfig()`. Inside the component, use `const {fps} = useVideoConfig()`+for timing props instead of reusing `compositionFps`.If the composition uses [`<TransitionSeries>`](./transitions.md), subtract the overlap from total duration: [./transitions.md#calculating-total-composition-duration](./transitions.md#calculating-total-composition-duration)