calculate-metadata — Claude Code rule: setup
The calculate-metadata rule configures Remotion composition metadata before rendering, including duration, dimensions, FPS, props, and the output filename.
no license ★ 849 updated 2026-01-24
.claude/rules/calculate-metadata.mdWhat calculate-metadata does
The rule shows how to attach calculateMetadata to a Remotion <Composition>. The callback receives the current props and can return frame duration, width, height, FPS, transformed props, a default output name, and a rendering codec.
It uses getMediaMetadata() from the mediabunny/metadata skill to read video duration and dimensions. The examples cover adding several video lengths, matching the composition to source dimensions, fetching data from dataUrl, and passing an abortSignal so stale Studio requests can be cancelled.
The video-duration and dimension examples depend on getMediaMetadata() from mediabunny/metadata; without that function, those calculations cannot run.
What it helps with
- calculate composition length from a video
- match the canvas size to source media
- combine the lengths of several videos
- fetch data before rendering
- derive an output filename from props
Example prompts for the agent
- Configure
calculateMetadatafor a composition whose duration comes from the metadata ofvideoSrc. - For
props.videos, calculate the combined length of all sources and return it as frames. - Fetch JSON from
dataUrlwithabortSignal, then pass the result into the component props before rendering.
How to install calculate-metadata
Manually: put the files in place
.claude/rules/calculate-metadata.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/calculate-metadata.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/calculate-metadata.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/calculate-metadata.mdManually: put the files in place
.clinerules/calculate-metadata.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about calculate-metadata
How do I install calculate-metadata in Claude Code?
Save the Claude Code rule at .claude/rules/calculate-metadata.md.
What does calculate-metadata do?
It guides Remotion to compute composition duration, dimensions, FPS, transformed props, the default output name, and the rendering codec before rendering.
What is required to calculate video duration?
Use getMediaMetadata() from the mediabunny/metadata skill to read video duration and dimensions.