Why quality-based compression doesn't solve this problem directly
Standard video compression usually asks you to pick a quality level or bitrate and see what size comes out the other end — which works fine when you just want something smaller, but fails you completely when the actual requirement is a hard number: exactly under 25MB for a Discord upload, under an email provider's attachment cap, or under a specific platform's upload limit. Guessing a quality setting and checking the resulting size, then adjusting and re-compressing if it's still too big, wastes real time on trial and error.
Compressing to a target size works backward from the number you actually need — you specify the size limit, and the calculation works out what bitrate will land the output at or just under that size, skipping the guesswork entirely.
The math behind hitting a target size
File size for video is essentially bitrate multiplied by duration, so a target-size calculation works out the bitrate needed to fit a clip of known length into a specific size budget — a 2-minute clip aiming for 25MB needs a meaningfully lower bitrate than a 30-second clip hitting the same 25MB target. This is why the same size limit produces very different visual quality depending on how long the source clip is: longer clips have to spread the same size budget across more content, so quality drops proportionally.
This also means there's a practical floor — a very long video squeezed into a very small target size will eventually hit a bitrate so low that quality becomes genuinely poor, since there's a limit to how far any codec can stretch a fixed amount of data across a large amount of content.
Trimming first is often the better fix
If a clip needs heavy quality sacrifice to squeeze into a size limit, it's often because the clip is longer than it needs to be for what you're actually sharing — trimming to just the relevant portion before compressing to a target size usually preserves far more visual quality than compressing the full-length clip harder. This is worth trying before accepting a low-quality result: a shorter, sharper clip is almost always more useful than a longer, blockier one at the same file size.
Common size limits worth knowing
Discord's free-tier upload limit, most email providers' attachment caps (typically 25MB, though this varies by provider), and various messaging apps' media size limits are the situations that most commonly send people looking for exact-size compression rather than general size reduction. Knowing your actual target number before starting — rather than compressing repeatedly and checking — turns a frustrating trial-and-error process into a single pass.