SkillsMar 29, 2026·1 min read

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.

TL;DR
Use Mediabunny to check if a video file can be decoded by the browser before attempting playback in Remotion.
§01

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.

§02

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.

§03

How to use

  1. Install the Remotion skills collection:
npx skills add remotion-dev/skills
  1. Install Mediabunny in your Remotion project:
npx remotion add mediabunny
  1. 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');
}
§04

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;
};
§05

Related on TokRepo

§06

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 mediabunny rather than installing directly via npm to ensure version compatibility.

Frequently Asked Questions

What does canDecode check exactly?+

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.

Does this work with all video formats?+

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.

Can I use this outside of Remotion?+

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.

What happens if canDecode returns false?+

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.

How do I install this skill rule?+

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)
🙏

Source & Thanks

Created by Remotion. Licensed under MIT. remotion-dev/skills — Rule: can-decode

Part of the Remotion AI Skill collection on TokRepo.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets