mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-15 06:23:28 +08:00
Ports functionality from 10+ separate plugins into ECC so users only need one plugin installed. Consolidates: pr-review-toolkit, feature-dev, commit-commands, hookify, code-simplifier, security-guidance, frontend-design, explanatory-output-style, and personal skills. New agents (8): code-architect, code-explorer, code-simplifier, comment-analyzer, conversation-analyzer, pr-test-analyzer, silent-failure-hunter, type-design-analyzer New commands (9): commit, commit-push-pr, clean-gone, review-pr, feature-dev, hookify, hookify-list, hookify-configure, hookify-help New skills (8): frontend-design, hookify-rules, github-ops, knowledge-ops, lead-intelligence, oura-health, pmx-guidelines, remotion Enhanced skills (8): article-writing, content-engine, market-research, investor-materials, investor-outreach, x-api, security-scan, autonomous-loops — merged with personal skill content New hook: security-reminder.py (pattern-based OWASP vulnerability warnings on file edits) Totals: 36 agents, 69 commands, 128 skills, 29 hook scripts
105 lines
2.9 KiB
Markdown
105 lines
2.9 KiB
Markdown
---
|
|
name: calculate-metadata
|
|
description: Dynamically set composition duration, dimensions, and props
|
|
metadata:
|
|
tags: calculateMetadata, duration, dimensions, props, dynamic
|
|
---
|
|
|
|
# Using calculateMetadata
|
|
|
|
Use `calculateMetadata` on a `<Composition>` to dynamically set duration, dimensions, and transform props before rendering.
|
|
|
|
```tsx
|
|
<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:
|
|
|
|
```tsx
|
|
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
|
|
|
|
```tsx
|
|
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
|
|
|
|
```tsx
|
|
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:
|
|
|
|
```tsx
|
|
const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
|
|
return {
|
|
defaultOutName: `video-${props.id}.mp4`,
|
|
};
|
|
};
|
|
```
|
|
|
|
## Transforming props
|
|
|
|
Fetch data or transform props before rendering:
|
|
|
|
```tsx
|
|
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,
|
|
},
|
|
};
|
|
};
|
|
```
|
|
|
|
The `abortSignal` cancels stale requests when props change in the Studio.
|
|
|
|
## Return value
|
|
|
|
All fields are optional. Returned values override the `<Composition>` props:
|
|
|
|
- `durationInFrames`: Number of frames
|
|
- `width`: Composition width in pixels
|
|
- `height`: Composition height in pixels
|
|
- `fps`: Frames per second
|
|
- `props`: Transformed props passed to the component
|
|
- `defaultOutName`: Default output filename
|
|
- `defaultCodec`: Default codec for rendering
|