Repolode
Vanilagy

Vanilagy/mediabunny

Zero-dependency TypeScript library for reading, writing, and converting video and audio files (MP4, WebM, MP3, etc.) in the browser.

Stars
7,441
Forks
339
Open issues
53
Last commit
yesterday

What is it?

Mediabunny is a JavaScript library for reading, writing, and converting media files such as MP4, WebM, MP3, and HLS directly in the browser. It is written from scratch in TypeScript with no dependencies, and is designed as a web-native alternative to the approach FFmpeg takes for command-line media work.

The library covers container demuxing and muxing for formats including MOV, MKV, WAV, Ogg, FLAC, and MPEG-TS, and supports 25+ video, audio, and subtitle codecs. Encoding and decoding use the WebCodecs API for hardware acceleration where available. Its conversion API offers transmuxing, transcoding, resizing, rotation, cropping, resampling, and trimming.

File handling is streaming-based, so large files can be processed without loading everything into memory. The package is tree-shakable, with the smallest bundles around 5 kB gzipped, and the same code can run in Node, Bun, and Deno through the separate @mediabunny/server package.

Key features

  • 01Reads and writes MP4, MOV, WebM, MKV, HLS, WAV, MP3, Ogg, ADTS, FLAC, and MPEG-TS.
  • 02Supports 25+ video, audio, and subtitle codecs with hardware acceleration via WebCodecs.
  • 03Provides a conversion API for transmuxing, transcoding, resizing, cropping, rotation, and trimming.
  • 04Streams input and output so files of any size can be processed.
  • 05Tree-shakable with no runtime dependencies, as small as about 5 kB gzipped.
  • 06Runs in browsers and, via @mediabunny/server, in Node, Bun, and Deno.

Use cases

  • Converting a user's uploaded video to WebM or MP4 before sending it to a server.
  • Reading duration, dimensions, rotation, and metadata tags from media files in a web app.
  • Generating MP4 videos in the browser from canvas frames.
  • Trimming or resizing clips in a browser-based video editor.

Quick start

  1. 1

    Install the package from npm

    npm install mediabunny
  2. 2

    Import Input, ALL_FORMATS and BlobSource and read file metadata from a file

Things to know

  • Targets the browser, relying on the WebCodecs API for hardware-accelerated codecs.
  • TypeScript 5.7 or later is required for types.

Topics

#video#audio#webcodecs#typescript#media-processing#transcoding#browser#mp4#decoding#demuxing

FAQ

What is mediabunny?
Zero-dependency TypeScript library for reading, writing, and converting video and audio files (MP4, WebM, MP3, etc.) in the browser. Mediabunny is a JavaScript library for reading, writing, and converting media files such as MP4, WebM, MP3, and HLS directly in the browser. It is written from scratch in TypeScript with no dependencies, and is designed as a web-native alternative to the approach FFmpeg takes for command-line media work.
Is mediabunny free to use? What license does it have?
mediabunny is open source under the MPL-2.0 license. Check the license terms before using it in commercial products.
Is mediabunny still maintained?
Actively maintained. The last commit to mediabunny was on Nov 6, 2026.
What can I use mediabunny for?
Converting a user's uploaded video to WebM or MP4 before sending it to a server. Reading duration, dimensions, rotation, and metadata tags from media files in a web app. Generating MP4 videos in the browser from canvas frames. Trimming or resizing clips in a browser-based video editor.
How do I install mediabunny?
Install the package from npm: npm install mediabunny Import Input, ALL_FORMATS and BlobSource and read file metadata from a file
Where can I get mediabunny?
The source code and installation instructions are on GitHub: https://github.com/Vanilagy/mediabunny

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects