Comprimir Vídeo
Apunta a un tamaño — 10 MB para Discord, 25 MB para email — o simplemente baja la calidad. Se ejecuta en tu máquina, así que no hay límite de tamaño ni colas.
Tu navegador lee y recodifica el archivo. Ninguna petición lo envía a ninguna parte: esta página no tiene servidor al que subirlo.
Preguntas
¿Puede alcanzar un tamaño exacto?
Para eso está el modo «ajustar a un tamaño». El peso de un archivo es su bitrate multiplicado por su duración, así que, conocida la duración, el bitrate necesario es pura aritmética. Los codificadores no obedecen un bitrate al pie de la letra —el control de tasa varía según el material—, de modo que si la primera pasada falla por más de un pequeño margen, se mide el error y se vuelve a codificar una vez con la cifra corregida. En la práctica queda a un par de puntos porcentuales del objetivo.
¿Por qué 10 MB, 16 MB, 25 MB?
Son los muros con los que la gente choca: 10 MB es el límite gratuito de Discord, 16 MB el de WhatsApp, 25 MB el de Gmail y la mayoría de servidores de correo, y 50 MB el de Discord Nitro Basic. La herramienta apunta justo por debajo del límite y no exactamente a él, porque un archivo de 10,0 MB sigue siendo rechazado por un límite de 10 MB.
¿Y si el objetivo es imposible?
Lo dice antes de empezar, e indica el tamaño mínimo honesto para ese vídeo. Meter una hora de metraje en 10 MB exigiría un bitrate que ninguna resolución sobrevive: una herramienta que produjera un archivo invisible y lo llamara éxito sería peor que una que se niega.
¿Cuánto se reducirá mi archivo?
La estimación aparece antes de pulsar nada, a partir de los ajustes y la duración. El material recién salido de un móvil o una cámara suele grabarse muy por encima de lo que necesita, y reducciones del 60–90 % son habituales. Lo que ya se comprimió una vez tiene poco que dar, y la herramienta compara tu archivo con lo que su resolución necesita razonablemente y avisa cuando recodificar solo lo haría más grande.
¿Qué hace pequeño a un vídeo?
Menos píxeles y menos bits por píxel. La resolución es la palanca contundente y fiable: pasar de 4K a 1080p elimina tres cuartas partes de los píxeles antes siquiera de hablar de calidad. El bitrate decide después cuánto detalle sobrevive. Quitar el audio ayuda poco: rara vez supera un pequeño porcentaje de un archivo de vídeo.
¿Se sube a algún sitio?
No. Funciona con WebCodecs en tu navegador, que es lo que lo hace práctico: subir un gigabyte para que un servidor devuelva 200 MB es más lento que hacerlo localmente, y de paso deja tu material en el disco de otra persona. Sin límite de tamaño, sin cola y sin marca de agua, porque no hay servidor que los imponga.
Las demás herramientas
Build this into your own project
Compressing video to a target file size — the same way this page does it, on the user's machine, with no server. Take the code, or hand the prompt to a coding agent.
// 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'); Build me a video compressor that runs entirely in the browser — no upload, no server.
Requirements:
- Use the "mediabunny" npm package, which wraps WebCodecs. Do not use ffmpeg.wasm: it is ~30 MB and
needs SharedArrayBuffer, which requires COOP/COEP headers that break third-party scripts.
- Let the user target a file size (presets: 10 MB Discord, 16 MB WhatsApp, 25 MB email) as well as
picking a quality.
- To hit a size: size = bitrate x duration, so videoBitrate = (targetBytes * 8 * 0.96 - audioBitrate
* duration) / duration. Aim at 96% of the limit, because a file of exactly 10.00 MB is still
rejected by a 10 MB limit.
- Encoders do not obey a requested bitrate exactly. Measure the result; if it missed by more than 4%
or broke the limit, re-encode once with bitrate * (target / actual), damped to at most a halving
or doubling. Stop at two passes.
- Pass hardwareAcceleration: 'prefer-hardware'. Measured on an M5 at 1080p: 180 fps against 34 fps
for software, and the software encoder also overshot the requested bitrate by 3.5x.
- Show the estimated output size before encoding, and the real before/after afterwards.
- Refuse impossible targets up front: below about 90 kbps video is unwatchable, so if the target
cannot be met at that floor, say so and give the smallest honest size instead of producing junk.
- Warn when the source is already compressed below what its resolution needs — re-encoding it will
make it larger, and only reducing the resolution will help.
Reference implementation: https://life2film.com/tools/video-compressor/
The engine is documented for agents, and every tool page is available as
markdown by adding .md to its address.