# get-video-duration

The get-video-duration rule shows how to read a video’s duration in seconds with Mediabunny. Use it when code needs the length of a remote or local clip.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 849 repo stars
- Author: coleam00
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/coleam00/second-brain-skills/tree/HEAD/.claude/skills/remotion/rules/get-video-duration.md
- Updated: 2026-01-24
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/get-video-duration

## What it does

The rule uses `Input` and `computeDuration()` from `mediabunny` to calculate a video’s duration. For a video URL, it configures the source with `UrlSource` and accepts formats through `ALL_FORMATS`. The result is a duration in seconds.

Local files need a different source: use `FileSource` instead of `UrlSource`. The examples target browser, Node.js, and Bun environments. For a file used with Remotion, the rule shows passing a path from `staticFile`.

Add the rule at `.claude/rules/get-video-duration.md`. The local-file example takes a `File` object, so a URL source is not interchangeable with it.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/rules/get-video-duration.md` — The paths frontmatter field limits the files

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### Cursor

**Manually: put the files in place**
- File: `.cursor/rules/get-video-duration.mdc` — Frontmatter: description, globs, alwaysApply

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/get-video-duration.instructions.md` — The applyTo field sets which files it applies to

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/get-video-duration.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/get-video-duration.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/coleam00/second-brain-skills/tree/HEAD/.claude/skills/remotion/rules/get-video-duration.md

## When to use it
- read a video’s duration in seconds
- set up a source for a video URL
- handle a local clip with `FileSource`
- pass a Remotion asset through `staticFile`

## Example prompts
- Add a function that reads a video URL’s duration with Mediabunny.
- Change the local-video example to use `FileSource`.
- Use Remotion’s `staticFile` to get the duration of `video.mp4`.

## Similar
- [linkfox-echotik-get-video-download-url](https://affpapa.org/en/nevibecode/skills/linkfox-echotik-get-video-download-url.md) — skill · 232 installs
- [downtrend-duration-analyzer](https://affpapa.org/en/nevibecode/skills/downtrend-duration-analyzer.md) — skill · 3400 installs
- [duration-prediction](https://affpapa.org/en/nevibecode/skills/duration-prediction.md) — skill · 115 installs
- [platform-docs-get](https://affpapa.org/en/nevibecode/skills/platform-docs-get.md) — skill · 6900 installs
- [platform-metadata-api-context-get](https://affpapa.org/en/nevibecode/skills/platform-metadata-api-context-get.md) — skill · 6200 installs
- [google-mobile-ads-get-started](https://affpapa.org/en/nevibecode/skills/google-mobile-ads-get-started.md) — skill · 5855 installs

From the same set: [coleam00/second-brain-skills](https://affpapa.org/en/nevibecode/by/coleam00/second-brain-skills.md) — 33 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
