Files
mediabunny/docs/index.md
T
2026-02-24 11:07:05 +01:00

21 KiB
Raw Blame History

layout, title, hero
layout title hero
home Mediabunny
name text tagline image actions
Mediabunny Complete media toolkit A JavaScript library for reading, writing, and converting video and audio files. Directly in the browser, and faster than anybunny else.
src alt
/mediabunny-logo.svg Mediabunny logo
theme text link
brand Hop in /guide/introduction
theme text link
alt API /api
theme text link
alt Examples /examples
theme text link
alt Sponsors #sponsors
theme text link
alt License https://github.com/Vanilagy/mediabunny#license
<script setup> const quotes = [ { quote: 'The missing part in the JS ecosystem for building web-first media apps.', author: 'Yonatan, Gling AI', image: '/avatars/yonatan.jpeg', url: 'https://x.com/yonatanbd', }, { quote: 'Mediabunny gives you low-level control with high-level ease. It’s fast, lightweight, and finally feels like media processing built for the web, not ported to it.', author: 'Konstantin, Diffusion Studio', image: '/avatars/konstantin.png', url: 'https://x.com/konstipaulus', } ]; const benchmarks = [ { name: 'Extract metadata', unit: 'ops/s', results: [ { name: 'Mediabunny', value: 1000/1.16 }, { name: '@remotion/media-parser', value: 1000/4.28 }, { name: 'web-demuxer', value: 1000/12.4 }, { name: 'mp4box.js', value: 1000/23 }, { name: 'ffmpeg.wasm', value: 1000/547 }, ] }, { name: 'Iterate over all video packets', unit: 'packets/s', results: [ { name: 'Mediabunny', value: 10800 }, { name: 'web-demuxer', value: 2390 }, { name: '@remotion/media-parser', value: 842 }, ] }, { name: 'Convert to .webm & resize to 320x180', unit: 'frames/s', results: [ { name: 'Mediabunny', value: 804 }, { name: '@remotion/webcodecs', value: 324 }, { name: 'ffmpeg.wasm', value: 12 }, ] } ]; const bundleSizes = [ { name: 'Reading .wav files', size: 5.1 }, { name: 'Writing .wav files', size: 5.79 }, { name: 'Writing .webm files', size: 11.36 }, { name: 'Reading .webm files', size: 15.2 }, { name: 'Reading .mp4 files', size: 16.03 }, { name: 'Writing .mp4 files', size: 17.28 }, { name: 'Reading all formats', size: 30.02 }, { name: 'mp4box.js', size: 37.3, isThirdParty: true }, { name: 'All features', size: 69.62 }, { name: '@remotion/webcodecs', size: 87.2 + 20.8, isThirdParty: true }, ]; const sponsors = { gold: [ { image: '/sponsors/remotion-light.png', name: 'Remotion', url: 'https://remotion.dev/' }, { image: '/sponsors/gling.svg', name: 'Gling AI', url: 'https://www.gling.ai/' }, { image: '/sponsors/diffusionstudio.png', name: 'Diffusion Studio', url: 'https://diffusion.studio/' }, { image: '/sponsors/kino.jpg', name: 'Kino', url: 'https://kino.ai/' }, { image: '/sponsors/screen-studio.webp', name: 'Screen Studio', url: 'https://screen.studio/' }, { image: '/sponsors/tella.svg', name: 'Tella', url: 'https://www.tella.com/' }, ], silver: [ { image: '/sponsors/ponder.png', name: 'Ponder', url: 'https://ponder.ai/' }, ], bronze: [ { image: '/sponsors/elevenlabs.png', name: 'ElevenLabs', url: 'https://elevenlabs.io/' }, { image: '/sponsors/rve.png', name: 'React Video Editor', url: 'https://www.reactvideoeditor.com/' }, { image: '/sponsors/mux.jpg', name: 'Mux', url: 'https://www.mux.com/' }, { image: '/sponsors/jellypod.png', name: 'Jellypod', url: 'https://jellypod.ai/' }, ], individual: [ { image: '/sponsors/pintura-labs.png', name: 'Pintura Labs', url: 'https://pqina.nl/pintura/' }, { image: 'https://avatars.githubusercontent.com/u/82552321', name: 'Polotno', url: 'https://github.com/polotno-project' }, { image: 'https://avatars.githubusercontent.com/u/489051', name: 'Roman Rädle', url: 'https://github.com/raedle' }, { image: 'https://avatars.githubusercontent.com/u/197597', name: 'Christopher Chedeau', url: 'https://github.com/vjeux' }, { image: 'https://avatars.githubusercontent.com/u/84167135', name: 'Memenome', url: 'https://github.com/memenome' }, { image: 'https://avatars.githubusercontent.com/u/5913254', name: 'Brandon McConnell', url: 'https://github.com/brandonmcconnell' }, { image: 'https://avatars.githubusercontent.com/u/9549394', name: 'studnitz', url: 'https://github.com/studnitz' }, { image: 'https://avatars.githubusercontent.com/u/4714175', name: 'Phoomparin Mano', url: 'https://github.com/heypoom' }, { image: 'https://avatars.githubusercontent.com/u/504909', name: 'Hirbod', url: 'https://github.com/hirbod' }, { image: 'https://avatars.githubusercontent.com/u/2698271', name: 'Matthew Gardner', url: 'https://github.com/spheric' }, { image: 'https://avatars.githubusercontent.com/u/5475819', name: 'AJ Funk', url: 'https://github.com/AJFunk' }, { image: 'https://avatars.githubusercontent.com/u/30229596', name: 'Pablo Bonilla', url: 'https://github.com/devPablo' }, { image: 'https://avatars.githubusercontent.com/u/139718', name: 'Anton Kosiakin', url: 'https://github.com/deil' }, { image: 'https://avatars.githubusercontent.com/u/56988069', name: 'SyhabouthAlex', url: 'https://github.com/SyhabouthAlex' }, { image: 'https://avatars.githubusercontent.com/u/38181164', name: 'wcw', url: 'https://github.com/asd55667' }, { image: 'https://avatars.githubusercontent.com/u/1836701', name: 'Bean Deng', url: 'https://github.com/HADB' }, { image: 'https://avatars.githubusercontent.com/u/255616819', name: 'cronischarles-del', url: 'https://github.com/cronischarles-del' }, { image: 'https://avatars.githubusercontent.com/u/37973863', name: 'Gomi', url: 'https://github.com/gxy5202' }, { image: 'https://avatars.githubusercontent.com/u/36898190', name: 'jepcd', url: 'https://github.com/jepcd' }, { image: 'https://avatars.githubusercontent.com/u/63088713', name: 'taf2000', url: 'https://github.com/taf2000' }, { image: 'https://avatars.githubusercontent.com/u/58149663', name: 'H7GhosT', url: 'https://github.com/H7GhosT' }, { image: 'https://avatars.githubusercontent.com/u/91711202', name: 'ihasq', url: 'https://github.com/ihasq' }, { image: 'https://avatars.githubusercontent.com/u/61233224', name: 'Allwhy', url: 'https://github.com/Allwhy' }, { image: 'https://avatars.githubusercontent.com/u/97225946', name: '808vita', url: 'https://github.com/808vita' }, { image: 'https://avatars.githubusercontent.com/u/3709646', name: 'Rodrigo Belfiore', url: 'https://github.com/roprgm' }, { image: 'https://avatars.githubusercontent.com/u/31102694', name: 'Aiden Liu', url: 'https://github.com/aidenlx' }, { image: 'https://avatars.githubusercontent.com/u/41021374', name: 'arthco', url: 'https://github.com/arthtyagi' }, { image: 'https://avatars.githubusercontent.com/u/5907357', name: 'Harvey Zhao', url: 'https://github.com/zhw2590582' }, ], }; </script>

{{ quote.quote }}

Author image

{{ quote.author }}

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
const input = new Input({
	source: new UrlSource('./bigbuckbunny.mp4'),
	formats: ALL_FORMATS, // .mp4, .webm, .wav, ...
});

const duration = await input.computeDuration();

const videoTrack = await input.getPrimaryVideoTrack();
const { displayWidth, displayHeight, rotation } = videoTrack;

const audioTrack = await input.getPrimaryAudioTrack();
const { sampleRate, numberOfChannels } = audioTrack;

// 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()) {
	// ...
}
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',
	bitrate: QUALITY_HIGH,
});
output.addVideoTrack(videoSource);

// Add audio, driven by audio buffers
const audioSource = new AudioBufferSource({
	codec: 'opus',
	bitrate: 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
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:

Gold sponsors

Silver sponsors

Bronze sponsors

Individual sponsors

And you