# get-audio-duration

get-audio-duration — a rule that teaches Claude Code to extract audio file duration in seconds using the Mediabunny library.

- 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-audio-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-audio-duration

## What it does

The rule shows the agent how to retrieve audio duration via Mediabunny, a library that runs in browsers, Node.js, and Bun. Inside: a function with `Input` and `UrlSource` for remote files, a `FileSource` variant for local ones, and a `staticFile` example for Remotion projects.

The library returns duration as a decimal number in seconds. For local files, you need a File object from an input element or drag-and-drop event.

Useful when the agent needs to know audio length before processing — calculating video timings or validating uploads, for instance.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/rules/get-audio-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-audio-duration.mdc` — Frontmatter: description, globs, alwaysApply

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/get-audio-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-audio-duration.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/get-audio-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-audio-duration.md

## When to use it
- get duration of MP3, WAV and other audio formats
- check audio file length before processing
- extract audio metadata in browser or server environments

## Example prompts
- Find the duration of `audio.mp3` from the `public` folder
- How long is the audio at the URL in `trackUrl`?
- Add a function that returns the length of an uploaded WAV file

## Similar
- [remotion-multimedia](https://affpapa.org/en/nevibecode/skills/remotion-multimedia.md) — skill · 3 installs
- [audio-and-sound](https://affpapa.org/en/nevibecode/skills/audio-and-sound.md) — skill · 1200 installs
- [add-audio](https://affpapa.org/en/nevibecode/skills/add-audio.md) — skill · 1100 installs
- [platform-metadata-discovery-get](https://affpapa.org/en/nevibecode/skills/platform-metadata-discovery-get.md) — skill · 107 installs
- [web-audio-api](https://affpapa.org/en/nevibecode/skills/web-audio-api.md) — skill · 422 installs
- [audio-producer](https://affpapa.org/en/nevibecode/skills/audio-producer.md) — skill · 200 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
