Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Vanilagy/mediabunny/llms.txt

Use this file to discover all available pages before exploring further.

Install Mediabunny using your favorite package manager:
npm install mediabunny

Requirements

JavaScript environment

Mediabunny requires any JavaScript environment that can run ECMAScript 2021 or later. It’s designed to run in modern browsers.

TypeScript

For TypeScript projects, you’ll need TypeScript 5.7 or later for type definitions.

Browser compatibility

Mediabunny works in modern browsers that support:
  • ECMAScript 2021 features
  • WebCodecs API (for encoding/decoding)
  • Modern JavaScript APIs (Promises, async/await, etc.)
Supported browsers include:
  • Chrome 94+
  • Edge 94+
  • Safari 16.4+
  • Firefox (with WebCodecs behind a flag)
Some features like hardware-accelerated encoding and decoding require WebCodecs API support. Check browser compatibility for your target browsers.

Node.js support

Mediabunny also works in Node.js environments. However, WebCodecs API features may require polyfills or may not be available depending on your Node.js version.

Import the library

Once installed, import Mediabunny in your project:
import { Input, Output, Conversion, ALL_FORMATS } from 'mediabunny';
ESM imports are preferred because they enable tree shaking, which significantly reduces your bundle size.

Using a script tag

You can also include Mediabunny directly in your HTML using a script tag:
<script src="mediabunny.cjs"></script>
This will add a Mediabunny object to the global scope, giving you access to all exports:
const input = new Mediabunny.Input({
  source: new Mediabunny.BlobSource(file),
  formats: Mediabunny.ALL_FORMATS,
});

Download distribution files

You can download built distribution files from the releases page.
Use the *.cjs builds for normal script tag inclusion:
<script src="mediabunny.cjs"></script>

TypeScript types for global usage

If you’re using TypeScript with the script tag approach, include the mediabunny.d.ts declaration file in your project. This will declare a global Mediabunny namespace with full type support.

Bundle size

One of Mediabunny’s key advantages is its tree-shakable architecture:
  • Minimum size: 5 kB gzipped (when using only specific features)
  • Full library: Varies based on which formats and codecs you use
  • Smart bundling: Only the formats and codecs you import are included
Because Mediabunny is extremely tree-shakable, you only pay for what you use. If you only need an MP4 muxer, your bundle will be very small.

Next steps

Now that you have Mediabunny installed, you’re ready to start building:

Quick start

Jump right in with code examples for common tasks

Read media files

Learn how to extract metadata and media data

Write media files

Create new media files from scratch

Convert files

Convert between different media formats

Build docs developers (and LLMs) love