### Index --- layout: home title: Mediabunny — A complete JavaScript media toolkit for the browser titleTemplate: false hero: name: Mediabunny text: Complete media toolkit tagline: A JavaScript library for reading, writing, and converting video and audio files. Directly in the browser, and faster than anybunny else. image: src: /mediabunny-logo.svg alt: Mediabunny logo actions: - theme: brand text: Hop in link: /guide/introduction - theme: alt text: API link: /api - theme: alt text: Examples link: /examples - theme: alt text: Blog link: /blog - theme: alt text: Sponsors link: "#sponsors" - theme: alt text: License link: https://github.com/Vanilagy/mediabunny#license ---

{{ quote.quote }}

{{ quote.author }}

```bash npm install mediabunny ```

Read any media file, efficiently

Mediabunny allows you efficiently read data from any video or audio file, no matter the size: duration, resolution, rotation, tracks, codecs and other metadata, as well as raw or decoded media data from anywhere in the file. Load only what you need.

Docs
```ts const input = new Input({ source: new UrlSource('./bigbuckbunny.mp4'), formats: ALL_FORMATS, // .mp4, .webm, .wav, .m3u8, ... }); const duration = await input.computeDuration(); const videoTrack = await input.getPrimaryVideoTrack(); const displayWidth = await videoTrack.getDisplayWidth(); const displayHeight = await videoTrack.getDisplayHeight(); const rotation = await videoTrack.getRotation(); const audioTrack = await input.getPrimaryAudioTrack(); const sampleRate = await audioTrack.getSampleRate(); const numberOfChannels = await audioTrack.getNumberOfChannels(); // Get the frame halfway through the video const sink = new VideoSampleSink(videoTrack); const frame = await sink.getSample(duration / 2); // Loop over all frames of the video for await (const frame of sink.samples()) { // ... } ```
```ts const output = new Output({ format: new Mp4OutputFormat(), // .mp4 target: new BufferTarget(), // in memory }); // Add video, driven by a canvas const videoSource = new CanvasSource(canvas, { codec: 'av1', quality: new Quality('high'), }); output.addVideoTrack(videoSource); // Add audio, driven by audio buffers const audioSource = new AudioBufferSource({ codec: 'opus', quality: new Quality('high'), }); output.addAudioTrack(audioSource); await output.start(); // Add media data here... await output.finalize(); const { buffer } = output.target; // Contains the final file ```

Create new media files, programmatically

Generate new media files (such as MP4 or WebM) directly on the client, and as fast as the hardware allows. Add multiple video, audio, or subtitle tracks, and have precise control down to the microsecond.

Docs

Hopping-fast file conversion

Use the Conversion API to transform any media file into any other media file: perform transmuxing, transcoding, resizing, rotation, audio resampling, trimming, and more.

Docs
```ts const input = new Input({ source: new BlobSource(file), // Read from disk formats: ALL_FORMATS, }); const output = new Output({ format: new WebMOutputFormat(), // Convert to .webm target: new StreamTarget(writableStream), // Write to disk }); const conversion = await Conversion.init({ input, output }); await conversion.execute(); // Done! ```

Universal I/O

Read and write files from and to memory, disk, or the network. Create files for offline use, or live-stream them as they're being created. Inject media data from a canvas, webcam, screen, microphone, audio buffer, your own encoding stack, or whatever. It's all up to you.

Wide container & codec support

Mediabunny supports many commonly used container formats and a wide variety of video and audio codecs. And all of them bidirectionally, too! (that means for reading and writing)

See full list

{{ benchmark.name }}

{{ result.name }}

{{ result.value < 100 ? result.value.toPrecision(3) : Math.floor(result.value) }} {{ benchmark.unit }}

Reading BigBuckBunny1080pH264.mov (691 MiB) from disk
Ryzen 7600X, RTX 4070, NVMe SSD, measured 2025-06-22

High performance

By reading only what you need, writing progressively, utilizing hardware-accelerated encoding and decoding via the WebCodecs API, and using a pipelined design, Mediabunny is able to get the job done fast.

Built from scratch, for the web

Mediabunny is 100% implemented in TypeScript and has zero dependencies. Its API was designed to be highly tree-shakable, meaning you only include what you use.

Bundle size, minified + gzipped

{{ result.name }}

{{ result.size < 100 ? result.size.toPrecision(3) : Math.floor(result.size) }} kB

ffmpeg.wasm

Measured 2025-06-22


Made possible by you

Mediabunny is an open-source project released under the MPL-2.0 and is therefore free to use for any purpose, including closed-source commercial use. A permissive license is essential for a foundational library like this to truly thrive. That said, this project requires an immense amount of work and care. This is made possible by the generous financial backing of these awesome sponsors:

And you

--- ### Blog --- title: Blog posts description: Announcements, news, and devblogs about Mediabunny. outline: false ---

Blog posts

--- ### Examples --- description: "Demos showcasing the various features of Mediabunny: metadata extraction, thumbnail generation, compression, media playback, live streaming, and more." layout: home title: Examples hero: text: Examples tagline: Demos showcasing various features of Mediabunny features: - title: Metadata extraction details: Extract various metadata from an input media file. link: /examples/metadata-extraction/ target: _self icon: src: /mingcute--file-info-line.svg - title: Thumbnail generation details: Generate multiple small thumbnails for a video track. link: /examples/thumbnail-generation/ target: _self icon: src: /mingcute--photo-album-line.svg - title: Media player (advanced) details: "A full video & audio media player, implemented from scratch with Mediabunny, with microsecond playback accuracy." link: /examples/media-player/ target: _self icon: src: /mingcute--video-line.svg - title: File compression details: Convert an input file to a highly-compressed MP4 file. link: /examples/file-compression/ target: _self icon: src: /mingcute--file-zip-line.svg - title: Procedural video generation details: Generate a video file as fast as the hardware allows. link: /examples/procedural-generation/ target: _self icon: src: /mingcute--magic-3-line.svg - title: Live recording & streaming details: Record a video from live sources and stream it to a video element. link: /examples/live-recording/ target: _self icon: src: /mingcute--microphone-line.svg - title: HLS transcoding details: Convert one video into a full HLS manifest with five video renditions and one audio track. link: /examples/hls-transcoding/ target: _self icon: src: /mingcute--live-line.svg --- --- ### Llms --- description: Teach Claude Code, Codex, Cursor, Copilot or any other AI coding agent how to make full use of Mediabunny. --- # Mediabunny and LLMs
While Mediabunny is proudly human-generated, we want to encourage any and all usage of Mediabunny, even when the vibes are high. Mediabunny is still new and is unlikely to be in the training data of modern LLMs, but we can still make the AI perform extremely well by just giving it a little more context. --- Give one or more of these files to your LLM: ### [mediabunny.d.ts](/mediabunny.d.ts) This file contains the entire public TypeScript API of Mediabunny and is commented extremely thoroughly. ### [llms.txt](/llms.txt) This file provides an index of Mediabunny's guide, which the AI can then further dive into if it wants to. ### [llms-full.txt](/llms-full.txt) This is just the entire Mediabunny guide in a single file. ---