Guides

How to compress a video to an exact file size

Updated November 18, 2026

Most video settings ask for a quality level, not a size. But upload forms, chat apps and email all have a hard limit in megabytes. To land under it, you work backwards from the size to a bitrate, then pick a resolution and frame rate that look good at that bitrate. Below are the math, what happened when we compressed one clip to 8, 20 and 50 MB, and ffmpeg commands for doing it by hand.

The basic formula: size × 8 ÷ duration

A video file is mostly a stream of bits that plays for a fixed time. So the bitrate you can afford is:

bitrate (bits per second) = target size in bytes × 8 ÷ length in seconds

The × 8 turns bytes into bits. Take a 2-minute clip and a 25 MB target: 25 MB is 25,000,000 bytes, which is 200,000,000 bits. Divided by 120 seconds, that is about 1,667 kbps (1.67 Mbps) for everything in the file, video and audio together.

Two things follow. Doubling the length halves the bitrate. And the content doesn’t change the budget: a calm screen recording and a fast shooter clip get the same bits per second, but the shooter clip will look worse with them.

What audio and the container take

That 1.67 Mbps isn’t all for the picture.

SizeClip aims for 95% of the size you choose, sets aside 64 KB for the container, and takes another 3% for muxing overhead. Then it subtracts the audio. For the 2-minute, 25 MB example, that leaves about 1.53 Mbps in total and about 1.40 Mbps for video after 128 kbps of audio.

Why the resolution drops at low bitrates

A fixed bitrate is spread over every pixel of every frame. A 1080p frame has 2.25 times as many pixels as a 720p frame, so at 1.4 Mbps each 1080p pixel gets far fewer bits, and the encoder throws away detail: you see blocks and smearing. A smaller picture with enough bits per pixel, scaled up by the player, often looks sharper.

SizeClip picks the resolution from the video bitrate left after audio. It never upscales, and it applies the cap to the shorter side, so a vertical phone video is treated the same way:

Video bitrateHighest resolution used
2.5 Mbps or more1080p
1.2 to 2.5 Mbps720p
0.6 to 1.2 Mbps480p
Below 0.6 Mbps360p

These are SizeClip’s own thresholds, chosen for H.264, not an industry standard. Other tools draw the lines in slightly different places.

Frame rate: 60 fps costs bits too

Frame rate works the same way as resolution. A 60 fps clip has twice as many frames as a 30 fps clip, so at the same bitrate each frame gets half the bits. When a high-frame-rate source (above 31 fps) would get too few bits per frame, SizeClip encodes it at 30 fps (25 fps for 50 fps sources) unless you tick “Keep original frame rate”. For a 1080p 60 fps clip with sound, it keeps 60 fps only for clips shorter than about 8 seconds at 8 MB, about 19 seconds at 20 MB, and about 48 seconds at 50 MB. Turn it on when smooth motion matters more than detail, as in a fast game.

Worked examples

Here is what SizeClip plans for a 1080p, 30 fps source with sound at a few common lengths and targets. The “raw” column is the plain formula; the other columns come from its planning logic after the margins and audio.

LengthTargetRaw bitrateVideo bitrateAudioResolution
30 s8 MB2.13 Mbps1.82 Mbps128 kbps720p
1 min8 MB1.07 Mbps0.88 Mbps96 kbps480p
30 s25 MB6.67 Mbps6.00 Mbps128 kbps1080p
2 min25 MB1.67 Mbps1.40 Mbps128 kbps720p
5 min25 MB0.67 Mbps0.52 Mbps96 kbps360p
2 min50 MB3.33 Mbps2.94 Mbps128 kbps1080p
5 min50 MB1.33 Mbps1.13 Mbps96 kbps480p
5 min100 MB2.67 Mbps2.33 Mbps128 kbps720p

A quick rule of thumb for 1080p with sound: it stays at 1080p up to about 22 seconds at 8 MB, 55 seconds at 20 MB, 69 seconds at 25 MB and 2 minutes 20 seconds at 50 MB.

Measured: one clip at 8, 20 and 50 MB

We ran a 40-second 1080p, 30 fps test clip (51.6 MB, a synthetic test pattern rather than a real recording) through SizeClip at three targets. We measured in a desktop Chromium browser; times will be different on your device.

TargetOutput sizeResolutionTime
8 MB7.44 MB720p3.9 s
20 MB18.7 MB1080p8.7 s
50 MB46.4 MB1080p8.8 s

At 8 MB the 40 seconds get about 1.37 Mbps of video, under the 1080p line, so the output is 720p. At 20 MB there is about 3.5 Mbps, enough for 1080p. At 50 MB a different limit applies: the source only averages about 10.3 Mbps, and re-encoding at nearly that bitrate would make the copy bigger without making it better. SizeClip caps the video at about 85% of the source’s video bitrate, so it stopped at 46.4 MB. We also ran a 20-second 1080p 60 fps test clip (30.5 MB) at 8 MB: it came out at 7.65 MB, 1080p at 30 fps, in 5.1 seconds.

Doing it by hand with ffmpeg

If you’d rather use the command line, work out the video bitrate yourself: size × 8 ÷ seconds, minus audio, minus a margin of about 5–10%. For the 2-minute, 25 MB example that is about 1,400 kbps of video at 720p, with 128 kbps audio.

Single pass is quicker but less accurate, because the encoder can’t see the hard scenes coming. Capping the peak rate makes an overshoot much less likely:

ffmpeg -i input.mp4 -vf scale=-2:720 -c:v libx264 -preset medium -b:v 1400k -maxrate 1400k -bufsize 2800k -c:a aac -b:a 128k -movflags +faststart output.mp4

Two-pass encoding reads the whole video first, then spends the bits where they’re needed. It is the usual way to hit a size closely:

ffmpeg -y -i input.mp4 -vf scale=-2:720 -c:v libx264 -preset medium -b:v 1400k -pass 1 -an -f null /dev/null
ffmpeg -i input.mp4 -vf scale=-2:720 -c:v libx264 -preset medium -b:v 1400k -pass 2 -c:a aac -b:a 128k -movflags +faststart output.mp4

On Windows, use NUL instead of /dev/null. scale=-2:720 sets the height to 720 and keeps the width even; for a vertical video, use scale=720:-2. Drop the -vf part to keep the original resolution, and add fps=30 (as -vf scale=-2:720,fps=30) to halve a 60 fps clip. Avoid -crf here: CRF targets a quality level, so the file size depends on the content.

Common mistakes

Frequently asked questions

Why did my file come out smaller than the target?

Tools leave a margin so the file doesn’t go over, and SizeClip never spends more bits than the original had or than a resolution can use. If your source is already close to the target, the output can be noticeably smaller than the number you picked.

Can I get exactly 25.00 MB?

Not reliably. Encoders control the average bitrate, not the final byte count. Aiming for 90–95% of a limit and checking the result is the practical way to stay under it.

Is two-pass encoding always better?

For hitting a size, yes: it is more accurate and spreads the bits better across easy and hard scenes. It takes longer, because the video is read twice. For a quick share where a few percent of error doesn’t matter, single pass with a margin is fine.

Does a smaller resolution always look worse?

No. At a low bitrate a smaller picture often looks cleaner than a blocky 1080p one, especially on a phone or in a chat window. At high bitrates, keep the original resolution.

More guides

Tools