Compress a video to a target size (like 25 MB) with ffmpeg: the bitrate maths and two-pass commands

The form says 25 MB maximum and your two-minute clip is 120 MB. Guessing a quality setting and hoping takes several tries. A bit of arithmetic gets it right first time.

Why the maths works

File size is just bitrate multiplied by time. If you fix the size and you know the length, the bitrate is the only thing left to choose. ffmpeg's -b:v sets an average video bitrate; the audio adds its own bitrate on top, and the MP4 container adds a little more. Leaving about 3% headroom keeps the result just under the limit.

Limit1 minute2 minutes5 minutes10 minutes
25 MB~3,100 kbps~1,490 kbps~520 kbps~200 kbps
100 MB~12,800 kbps~6,340 kbps~2,460 kbps~1,170 kbps
500 MBvery generous~32,200 kbps~12,800 kbps~6,340 kbps

Video bitrate after 128 kbps of audio and 3% headroom.

What resolution for that bitrate?

Squeezing full HD into a tiny bitrate makes it blocky. A smaller picture at the same bitrate looks sharper, and players scale it up smoothly. As a rough guide for H.264:

Video bitrateLooks good at
5,000 kbps and up1080p (even 1440p)
2,500 to 5,000 kbps1080p
1,200 to 2,500 kbps720p
600 to 1,200 kbps480p
under 600 kbps360p, or trim the clip

Add -vf scale=-2:720 (or 480, 360) to scale the height and keep the shape; -2 keeps the width an even number, which H.264 needs.

Why two passes?

On the first pass ffmpeg only reads the video and notes which scenes are busy and which are calm, writing a small log file. On the second it spends more bits on busy scenes and fewer on still ones, while landing close to the average you asked for. One pass with -b:v also hits the size roughly, but looks worse; a quality setting like -crf 23 looks good but you can't predict the size.

Common snags

Related

Why video smears when skipping (keyframes) · Split a video into parts without re-encoding · Make a GIF smaller instead · File too large for a USB stick (FAT32) · How big a minute of video is · Photo too large to email · How long a video takes to upload · Lossless vs lossy compression · Why squished video goes blocky (interactive lesson)

Questions

How do I compress a video to 25 MB?

Divide 25 MB by the length to get a bitrate: for 2 minutes with 128 kbps audio, use about 1,490 kbps of video at 720p, encoded in two passes with ffmpeg. The calculator writes the exact commands.

What does two-pass encoding do?

The first pass measures how busy each scene is; the second pass spends bits where they're needed while keeping the average bitrate you set, so the file lands close to your target and looks better.

Why is my compressed video still too big?

Usually the audio was left out of the sums, or the site counts megabytes as 1,048,576 bytes. Leave 3% headroom and subtract the audio bitrate, as the calculator does.

Should I use CRF or a bitrate?

Use CRF when you want a steady quality and don't mind the size. Use a bitrate with two passes when the file must fit a limit.

Do I have to upload my video to compress it?

No. ffmpeg runs on your own computer. The calculator only does the arithmetic in your browser and never sees the file.

Published 路 updated .

Try it

Related guides

Newest guides