calculate-metadata

calculate-metadata is a cursor rule for Cursor from ratnesh-maurya/cursor-claude-personas. It costs 11 tokens per session (668 once invoked), scanned A, original, MIT.

A Remotion pattern for calculating a video's duration, dimensions, and other composition settings from its input data before rendering.

In plain words
What is it for?
Use it to set duration and size from a video's metadata before creating the final video.
Why use it?
It keeps the rendered composition matched to the source video instead of relying only on fixed settings.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import {getMediaMetadata} from '../get-media-metadata';.

Good fit Use it to set duration and size from a video's metadata before creating the final video.

Compare 6 cursor rules from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/ratnesh-maurya/cursor-claude-personas
agentmods
npx agentmods add rules/ratnesh-maurya/cursor-claude-personas/rules-calculate-metadata

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for calculate-metadata

README.md
[![agentmods](https://agentmods.dev/badge/rules/ratnesh-maurya/cursor-claude-personas/rules-calculate-metadata/github.svg)](https://agentmods.dev/rules/ratnesh-maurya/cursor-claude-personas/rules-calculate-metadata)
Your own site
<a href="https://agentmods.dev/rules/ratnesh-maurya/cursor-claude-personas/rules-calculate-metadata"><img src="https://agentmods.dev/badge/rules/ratnesh-maurya/cursor-claude-personas/rules-calculate-metadata/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for calculate-metadata

Your own site · 80×15
<a href="https://agentmods.dev/rules/ratnesh-maurya/cursor-claude-personas/rules-calculate-metadata"><img src="https://agentmods.dev/badge/rules/ratnesh-maurya/cursor-claude-personas/rules-calculate-metadata.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 668 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00011 $0.00668
Opus 5 $0.00005 $0.00334
Sonnet 5 $0.00002 $0.00134
Haiku 4.5 $0.00001 $0.00067

Measured 8d ago against content hash b258c788fb33, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

calculate-metadata scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const response = await fetch(props.dataUrl, {signal: abortSignal});
3d-frontend-developer/.cursor/rules/rules--calculate-metadata.mdc · 105 lines

How it starts

The opening of the file, as written. The whole thing — 105 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Using calculateMetadata

Use calculateMetadata on a <Composition> to dynamically set duration, dimensions, and transform props before rendering.

<Composition id="MyComp" component={MyComponent} durationInFrames={300} fps={30} width={1920} height={1080} defaultProps={{videoSrc: 'https://remotion.media/video.mp4'}} calculateMetadata={calculateMetadata} />

Setting duration based on a video

Use the getMediaMetadata() function from the mediabunny/metadata skill to get the video duration:

import {CalculateMetadataFunction} from 'remotion';
import {getMediaMetadata} from '../get-media-metadata';

const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
  const {durationInSeconds} = await getMediaMetadata(props.videoSrc);

  return {
    durationInFrames: Math.ceil(durationInSeconds * 30),
  };
};

Matching dimensions of a video

const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
  const {durationInSeconds, dimensions} = await getMediaMetadata(props.videoSrc);

  return {
    durationInFrames: Math.ceil(durationInSeconds * 30),
    width: dimensions?.width ?? 1920,
    height: dimensions?.height ?? 1080,
  };
};

Setting duration based on multiple videos

const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
  const metadataPromises = props.videos.map((video) => getMediaMetadata(video.src));
  const allMetadata = await Promise.all(metadataPromises);

  const totalDuration = allMetadata.reduce((sum, meta) => sum + meta.durationInSeconds, 0);

  return {
    durationInFrames: Math.ceil(totalDuration * 30),
  };
};

Setting a default outName

Set the default output filename based on props:

const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
  return {
    defaultOutName: `video-${props.id}.mp4`,
  };
};

Transforming props

Fetch data or transform props before rendering:

const calculateMetadata: CalculateMetadataFunction<Props> = async ({props, abortSignal}) => {
  const response = await fetch(props.dataUrl, {signal: abortSignal});
  const data = await response.json();

  return {
    props: {
      ...props,
      fetchedData: data,
    },
  };
};

Read the full file on GitHub · 105 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 105 lines · 11 tokens per session scan A b258c788fb33

Subscribe to this mod's changes

calculate-metadata is a cursor rule published in the GitHub repository ratnesh-maurya/cursor-claude-personas (8 stars, last pushed 5mo ago), licensed MIT. It adds 11 tokens to every session and 668 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.