mediacodec.dev

Video file size calculator

Bits per second times seconds, divided by eight. Everyone gets the formula right and the units wrong; this page keeps the audio track, the container and the megabyte definition straight.

Work out

Duration

min
s
kbps

Audio bitrate

128 kbps AAC or 96 kbps Opus is transparent for most stereo material; the audio track is a rounding error next to the video on anything but a very long file.

File size

Duration
600 s
Video
375.0 MB
Audio
9.6 MB
Container (≈1%)
3.8 MB
Total
388.4 MB

Decimal units, as media tools report them: 1 MB is 1,000,000 bytes. Windows Explorer counts in 1,048,576 and will show about 5% less.

How this is calculated

A stream at b kilobits per second for t seconds is b × 1000 × t ÷ 8 bytes. Video and audio are separate streams with separate bitrates, so they are added, and then the container adds its own few bytes: MP4's sample tables and Matroska's cluster headers come to roughly 1% of the payload for ordinary files, more for very low bitrates and fragmented MP4 with short fragments. The calculator reserves 1% in both directions, so a bitrate it suggests lands just under the target rather than just over.

Megabytes here are decimal: 1 MB is 1,000,000 bytes, which is how FFmpeg, ffprobe, macOS and every media tool report sizes. Windows Explorer and many upload limits count in binary (1 MiB is 1,048,576 bytes) and will show about 5% less for the same file. If a service says "100 MB limit" it is worth finding out which it means.

Fitting a size

"Make this fit in 25 MB" is the one case where a bitrate target beats a quality target. One pass with -b:v asks the encoder to hit an average it cannot see coming, and it will miss by up to 10% either way. Two passes fix that: the first pass measures every frame's complexity and writes a log, the second pass spends the budget against that log, moving bits from easy scenes to hard ones and landing within a percent or two of the target. The command under the result is that recipe; for anything that does not have to fit a number, a CRF encode will look better for the bytes.

The audio track matters more than it looks for long files: 128 kbps over two hours is 115 MB on its own. When a target is tight, the order to cut is audio bitrate first (96 kbps Opus is transparent for most material), then frame size, then video bitrate.