Skip to main content
rule CX Codex

get-audio-duration — Claude Code rule: what it does, how to install

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

no license ★ 849 updated 2026-01-24

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/get-audio-duration.md
Open on GitHub

What get-audio-duration 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.

What it helps with

  • 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 for the agent

  • 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

How to install get-audio-duration

Manually: put the files in place

.claude/rules/get-audio-duration.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about get-audio-duration

How do I install get-audio-duration in Claude Code?

Place the rule file at .claude/rules/get-audio-duration.md in your project root.

What does the get-audio-duration rule do?

It teaches Claude Code to retrieve audio file duration in seconds using Mediabunny — for remote files by URL, local files via File API, and static files through staticFile in Remotion.

Does the rule require Mediabunny to be installed?

Yes, the rule uses mediabunny — you need to add it to your project with npm install mediabunny or another package manager.

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set33

The whole set →
transcribe-captions The transcribe-captions rule outlines three ways to transcribe audio for Remotion captions: run Whisper.cpp on a server, use WebAssembly in a browser, or call OpenAI Whisper API. CX Codex +1 ★ 849repo stars measuring-dom-nodes The measuring-dom-nodes rule covers measuring DOM element sizes inside Remotion compositions without the video container's scale distorting the numbers. CX Codex +1 ★ 849repo stars trimming Guides Claude Code on Remotion animation trimming patterns, from cutting intro frames to capping duration and combining delays. CX Codex +1 ★ 849repo stars 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. CX Codex +1 ★ 849repo stars can-decode Checks whether the browser can decode a video or audio stream before attempting playback using Mediabunny. CX Codex +1 ★ 849repo stars assets The assets rule guides Claude Code in adding images, video, audio, and fonts to Remotion projects. Use it when an agent needs to wire media into a composition. CX Codex +1 ★ 849repo stars get-video-dimensions get-video-dimensions — a Claude rule that hands the agent working Mediabunny code for reading a video's width and height, whether the file sits behind a URL, on disk, or in Remotion. CX Codex +1 ★ 849repo stars charts Guidelines for building Remotion charts and animated metrics without frame flickering. CX Codex +1 ★ 849repo stars

Project sponsors

Companies that keep this analytics open