---
name: video-compressor
description: "Compress a video to a target file size, or by quality, entirely in the browser. Nothing is uploaded. Use when someone asks for: compress video online, compress video. Free browser tool on Life2Film (life2film.com): runs in the user's browser, nothing is uploaded."
---

# Compress Video

Compress a video to a target file size, or by quality, entirely in the browser. Nothing is uploaded.

Page: https://life2film.com/tools/video-compressor/?utm_source=skill

## What matters

- Target a size (10 MB Discord, 16 MB WhatsApp, 25 MB email, 50 MB Nitro Basic) or pick a quality.
- Size = bitrate x duration, so the required bitrate follows from the length of the video.
- Aims at 96% of the limit: a file of exactly 10.00 MB is still rejected by a 10 MB limit.
- Measures the first pass and re-encodes once with a correction if it missed by over 4%.
- Refuses impossible targets and reports the smallest honest size instead.
- Warns when the source is already below the bitrate its resolution needs, re-encoding would enlarge it.
- Measured: a 17.7 MB 1080p file at 12 Mbps came out 9.4 MB against a 10 MB target.

## Limits

- Runs entirely in the user's browser. Nothing is uploaded, no account, no watermark.
- Because it runs on the user's machine, you cannot call it as an API: open the page for the person, or drive it with a browser (Playwright) on their machine.

## How to use it as an agent

1. The person has a file and a browser: give them https://life2film.com/tools/video-compressor/?utm_source=skill and say what to set. The file stays on their device.
2. You run a browser (Playwright, computer use): open the page, put the file in the drop zone, wait for the result, save the download.

## From code

```js
// npm i mediabunny
import { Input, Output, Conversion, BlobSource, BufferTarget, Mp4OutputFormat, ALL_FORMATS } from 'mediabunny';

// Size is bitrate x duration, so a target size fixes the bitrate.
const OVERHEAD = 0.04;               // container headers and packaging
const AUDIO_BITRATE = 128_000;

export async function compressToSize(file, targetBytes, { width } = {}) {
  const input = new Input({ source: new BlobSource(file), formats: ALL_FORMATS });
  const duration = await input.computeDuration();

  // Aim under the wall: a file of exactly 10.00 MB is still refused by a 10 MB limit.
  const aim = targetBytes * 0.96;
  const videoBitrate = Math.max(
    90_000,
    Math.round((aim * 8 * (1 - OVERHEAD) - AUDIO_BITRATE * duration) / duration),
  );

  const output = new Output({ format: new Mp4OutputFormat(), target: new BufferTarget() });
  const conversion = await Conversion.init({
    input,
    output,
    video: {
      ...(width ? { width } : {}),
      bitrate: videoBitrate,
      hardwareAcceleration: 'prefer-hardware',  // 180 fps vs 34 on an M5 at 1080p
    },
    audio: { bitrate: AUDIO_BITRATE },
  });

  if (!conversion.isValid) throw new Error('Cannot convert this file');
  await conversion.execute();

  return new Blob([output.target.buffer], { type: 'video/mp4' });
}

// Encoders drift, so measure and correct once if the first pass missed.
const blob = await compressToSize(file, 10 * 1024 * 1024);
console.log(blob.size / 1048576, 'MB');
```

## Life2Film MCP

Every tool on Life2Film and our other sites, their skills and guides, as a read-only MCP server (`list_tools`, `get_tool`):

```sh
# Claude Code
claude mcp add --transport http life2film https://life2film.com/mcp
# Codex CLI
codex mcp add life2film --url https://life2film.com/mcp
```

Claude.ai, Claude Desktop, ChatGPT: add a custom connector with the URL `https://life2film.com/mcp`.
Cursor and other clients (`mcp.json`): `{"mcpServers":{"life2film":{"url":"https://life2film.com/mcp"}}}`

## Related

- [Trim Video](https://life2film.com/tools/video-trimmer/?utm_source=skill)
- [Video to MP3](https://life2film.com/tools/video-to-mp3/?utm_source=skill)
- [Convert Video](https://life2film.com/tools/video-converter/?utm_source=skill)
- [Remove Audio](https://life2film.com/tools/remove-audio-from-video/?utm_source=skill)
- [Rotate Video](https://life2film.com/tools/rotate-video/?utm_source=skill)
- [Video Info](https://life2film.com/tools/video-info/?utm_source=skill)

---
Life2Film: https://life2film.com/ · llms.txt: https://life2film.com/llms.txt
