Mediabunny - JavaScript media toolkit Mediabunny is a JavaScript library for reading, writing, and converting media (like MP4, WebM, MP3, HLS), directly in the browser. It aims to be a complete toolkit for high-performance media operations on the web. It's written from scratch in pure TypeScript, has zero dependencies, is very performant, and is extremely tree-shakable, meaning you only include what you use. You can think of it a bit like FFmpeg, but built from the ground up for the web. Documentation | Examples | Sponsoring | License | Discord Sponsor Mediabunny's development Wide format support: Read and write MP4, MOV, WebM, MKV, HLS, WAVE, MP3, Ogg, ADTS, FLAC, MPEG-TS Built-in encoding & decoding: Supports 25+ video, audio, and subtitle codecs, hardware-accelerated using the WebCodecs API High precision: Fine-grained, microsecond-accurate reading and writing operations Conversion API: Easy-to-use API with features such as transmuxing, transcoding, resizing, rotation, cropping, resampling, trimming, and more Streaming I/O: Handle reading & writing files of any size with memory-efficient streaming Cross-platform: Works in all browsers as well as in Node, Bun, and Deno using @mediabunny/server Tree-shakable: Only bundle what you use (as small as 5 kB gzipped) Zero dependencies: Implemented in highly performant TypeScript Alternatively, include it directly with a script tag using one of the builds. Doing so exposes a global Mediabunny object. <script src="mediabunny.cjs"></script> Requires any JavaScript environment that can run ECMAScript 2021 or later. Mediabunny is expected to be run in modern browsers. For types, TypeScript 5.7 or later is required. import { Input, ALL_FORMATS, BlobSource } from 'mediabunny'; // Reading from disk const input = new Input({ source: new BlobSource(file), formats: ALL_FORMATS, }); const duration = await input.computeDuration(); // in seconds const videoTrack = await input.getPrimaryVideoTrack(); const audioTrack = await input.getPrimaryAudioTrack(); const displayWidth = await videoTrack.getDisplayWidth(); const displayHeight = await videoTrack.getDisplayHeight(); const rotation = await videoTrack.getRotation(); const sampleRate = await audioTrack.getSampleRate(); const numberOfChannels = await audioTrack.getNumberOfChannels(); const { title, artist, album } = await input.getMetadataTags(); import { Output, Mp4OutputFormat,…