get-video-duration — Claude Code rule for video length
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.
no license ★ 849 updated 2026-01-24
.claude/rules/get-video-duration.mdWhat get-video-duration 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.
What it helps with
- 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 for the agent
- Add a function that reads a video URL’s duration with Mediabunny.
- Change the local-video example to use
FileSource. - Use Remotion’s
staticFileto get the duration ofvideo.mp4.
How to install get-video-duration
Manually: put the files in place
.claude/rules/get-video-duration.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/get-video-duration.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/get-video-duration.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/get-video-duration.mdManually: put the files in place
.clinerules/get-video-duration.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about get-video-duration
How do I install get-video-duration in Claude Code?
Create .claude/rules/get-video-duration.md and add the rule there.
What does get-video-duration do?
It describes how to calculate a video’s duration in seconds with Mediabunny’s computeDuration().
How does the rule handle local video files?
Use FileSource for a local file rather than UrlSource. The example passes a File object as the source.