Remotion Rule: Can Decode
Remotion skill rule: Check if a video can be decoded by the browser using Mediabunny. Part of the official Remotion Agent Skill for programmatic video in React.
What it is
This is a Remotion Agent Skill rule that provides a reusable function to check whether a video file can be decoded by the browser before attempting playback. It uses Mediabunny to probe video and audio tracks, returning a boolean indicating decoder support.
The rule targets developers building programmatic videos with Remotion who need to validate source media before rendering. It prevents silent failures where a video appears blank because the browser lacks codec support for the input file.
How it saves time or tokens
Without decode checking, a Remotion render can fail silently -- producing a video with missing frames or no audio. Debugging these failures requires manually testing each source file. The canDecode() function catches unsupported formats upfront, saving hours of debugging.
The token estimate for this skill rule is approximately 500 tokens. It installs as part of the official Remotion Agent Skill collection and activates automatically in relevant contexts.
How to use
- Install the Remotion skills collection:
npx skills add remotion-dev/skills
- Install Mediabunny in your Remotion project:
npx remotion add mediabunny
- Use the
canDecode()function before rendering:
const isPlayable = await canDecode('https://example.com/video.mp4');
if (!isPlayable) {
console.error('Video format not supported by browser');
}
Example
Complete canDecode implementation using Mediabunny:
import { Input, ALL_FORMATS, UrlSource } from 'mediabunny';
export const canDecode = async (src: string) => {
const input = new Input({
formats: ALL_FORMATS,
source: new UrlSource(src, {
getRetryDelay: () => null,
}),
});
try {
await input.getFormat();
} catch {
return false;
}
const videoTrack = await input.getPrimaryVideoTrack();
if (videoTrack && !(await videoTrack.canDecode())) {
return false;
}
const audioTrack = await input.getPrimaryAudioTrack();
if (audioTrack && !(await audioTrack.canDecode())) {
return false;
}
return true;
};
Related on TokRepo
- AI Tools for Video -- Video generation and processing tools
- AI Tools for Coding -- Developer productivity tools and agent skills
Common pitfalls
- The function checks browser codec support, not general format validity. A file may be valid but use a codec the browser cannot decode (e.g., HEVC in Chrome without hardware support).
canDecode()makes network requests to probe the file. For local files, ensure they are served via a local HTTP server rather than passed as file:// URLs.- Mediabunny must match your Remotion version. Use
npx remotion add mediabunnyrather than installing directly via npm to ensure version compatibility.
Frequently Asked Questions
It probes the video file format, then checks whether the primary video track and primary audio track can be decoded by the current browser environment. It returns false if any track uses an unsupported codec.
The function tests against ALL_FORMATS supported by Mediabunny. It covers common containers like MP4, WebM, and MOV. The actual decode capability depends on the browser and its codec support.
The canDecode function uses Mediabunny which is a Remotion ecosystem library. While it could technically run in any browser environment, it is designed for and tested with Remotion projects.
Your application should handle the failure gracefully -- either transcode the video to a supported format, show an error message, or skip that source file. Remotion will not render unsupported video correctly.
Run 'npx skills add remotion-dev/skills' to install the full Remotion Agent Skill collection. The can-decode rule activates automatically when Claude Code or compatible agents detect relevant video tasks.
Citations (3)
- Remotion GitHub— Remotion Agent Skill for programmatic video creation in React
- Remotion Documentation— Mediabunny provides format and codec detection for video files
- MDN Web Docs— Browser codec support varies by platform and configuration
Related on TokRepo
Source & Thanks
Created by Remotion. Licensed under MIT. remotion-dev/skills — Rule:
can-decode
Part of the Remotion AI Skill collection on TokRepo.
Discussion
Related Assets
Claude-Flow — Multi-Agent Orchestration for Claude Code
Layers swarm and hive-mind multi-agent orchestration on top of Claude Code with 64 specialized agents, SQLite memory, and parallel execution.
ccusage — Real-Time Token Cost Tracker for Claude Code
CLI that reads ~/.claude logs and breaks down Claude Code token spend by day, session, and project — pluggable into your statusline.
SuperClaude — Workflow Framework for Claude Code
Adds 16+ slash commands, 9 cognitive personas, and a smart flag system to Claude Code in one pipx install.