#video · #webcodecs · #mediabunny · #privacy

Compress video in the browser with WebCodecs: what works and what doesn't

LitPhoto compresses MP4, MOV, WebM, MKV and MPEG-TS video locally using WebCodecs and Mediabunny. Here are the supported paths, the controls and the honest limits.

· 4 min read · LitPhoto

Video compression in a browser used to mean uploading the clip to a service. LitPhoto now runs the whole path locally: Mediabunny demuxes the container, WebCodecs decodes and encodes frames, and the result is muxed back into a downloadable file.

It is genuinely useful, but it is not a desktop video editor. This guide covers what the current build can do and where it stops.

The short answer

LitPhoto accepts MP4, M4V, MOV, WebM, Matroska (MKV) and MPEG-TS files up to 2 GB each. It prefers H.264 in MP4 and falls back to WebM/VP9 when the browser cannot encode H.264. You can choose a quality target or a target file size in MB, cap the resolution at 1080p, 720p or 480p, and keep or remove audio.

Everything happens on your device. The clip is not uploaded.

The local processing path

  1. The worker opens the file with a random-access blob source. It does not read the whole video into the main thread.
  2. Mediabunny parses the container and exposes the video and audio tracks.
  3. The app checks whether the browser can decode the source codec and encode a practical target codec.
  4. WebCodecs decodes frames, the encoder re-encodes them at the requested bitrate and resolution.
  5. Mediabunny muxes the encoded video and the audio stream into MP4 or WebM.
  6. The resulting Blob is returned to the page for preview and download.

The video queue runs one job at a time. Video encoding saturates a hardware encoder and holds both decode and encode buffers; running several jobs in parallel is not a good use of memory.

Supported inputs and outputs

Input Notes
MP4 / M4V Most phone and camera exports; AAC audio is usually copied
MOV QuickTime files; often the same codecs as MP4
WebM VP8/VP9/AV1 video and Opus audio are common
MKV Matroska containers; actual codecs still need browser support
MPEG-TS Broadcast/recording containers

Output prefers H.264 in MP4. If the browser cannot encode H.264 at the requested size, the app tries HEVC/AV1/VP9 and may produce WebM instead. The result row always shows the actual container and codec.

AVI, FLV and WMV are rejected before they enter the queue. They require demuxers/codecs that the browser build does not bundle.

The settings that matter

  • Quality maps to an estimated bitrate from resolution and frame rate. The estimate is then capped at the source bitrate so compression does not inflate the file.
  • Target size converts a target MB value into a video bitrate, leaving room for audio and container overhead. It is a single-pass estimate, not a two-pass studio encode.
  • Resolution cap limits the longest side to 1080p, 720p or 480p. It never upscales a smaller clip.
  • Keep audio copies AAC/Opus when the container allows it. If the output cannot carry the source audio and no encoder is available, the audio track is removed and the row shows a warning.

Changing video settings does not automatically re-encode finished jobs. The panel has an explicit “Re-compress all” action, because accidentally re-encoding a queue of long clips is expensive.

Honest limits

  • 2 GB per file. Larger files put too much pressure on browser memory and the encoder.
  • One job at a time. This is deliberate; parallel video encodes compete for the same hardware.
  • Decode support varies. HEVC and AV1 sources depend on the browser and the operating system. If the browser cannot decode the source, the job fails with a clear message rather than producing a broken file.
  • No trimming, cropping or filters. This is a compressor, not an editor.
  • Target size is approximate. The encoder uses variable bitrate; the final size may be a few percent above or below the target, and the UI warns when it cannot get close.
  • Safari audio support is limited. Safari before version 26 does not provide WebCodecs audio encoding. Audio is copied when the container allows it; otherwise it may be removed with a warning.
  • AVI/FLV/WMV are not supported.

Browser requirements

Video compression needs WebCodecs video encoding and decoding. Current desktop Chrome/Edge, Safari 16.4+ and desktop Firefox 130+ provide the API; the exact codecs available still depend on the machine. If the browser lacks WebCodecs, the video mode shows an explicit unsupported message instead of a failing queue.

Is it private?

The file is processed by the worker on your machine. There is no upload request. The page may load the local worker chunk and WebAssembly assets from the same origin, but the clip itself stays in the browser.

As with any static site, the hosting server may keep ordinary access logs when the page is loaded. Those logs do not contain your video.

When to use it

Browser video compression is convenient for shrinking a clip before sending it through a size-limited form, reducing a phone recording for storage, or converting a WebM/MP4 between common containers without installing software. For multi-track editing, subtitles, color grading or precise two-pass encodes, use a dedicated desktop tool.

Try it locally

Every file is processed on your device. No uploads, no account, no tracking.
Open LitPhoto →