A video has to stay under a size limit, and the running time is fixed. The only setting left to choose is the bitrate, and the limit tells you how high it can go. This is the size formula run backward: you start with the bytes you are allowed and end with bits per second.
After reading, you will be able to turn a limit and a duration into a video bitrate, subtract the audio, leave sensible headroom, and avoid the unit mix-ups that make a result miss the limit.
Work backward from the limit
The forward formula says size equals bitrate times time, divided by 8. Solve it for the bitrate and you get the budget:
total bit/s = target bytes × 8 ÷ seconds
video bit/s = total bit/s − audio bit/s
The total covers every stream in the file. Whatever the audio uses comes out of the same budget, so the video gets what is left. The video file size calculator has a mode for exactly this: enter the target size and the duration, and it returns the bitrate you can afford.
Worked example. Example: a 10-minute video must be 100 MB (decimal) or less, with audio at 128 kbps.
- Target: 100 MB = 100,000,000 bytes. Duration: 600 seconds.
- Total bitrate: 100,000,000 × 8 ÷ 600 = 1,333,333 bit/s.
- Video bitrate: 1,333,333 − 128,000 = 1,205,333 bit/s, about 1.2 Mbps.
Check by going forward: (1,205,333 + 128,000) × 600 ÷ 8 is 99,999,975 bytes, which rounds back to the limit.
A method you can reuse
| Step | What to do | Example: 500 MB limit, 45 minutes, 128 kbps audio |
|---|---|---|
| 1 | Write the limit in bytes | 500 MB = 500,000,000 bytes |
| 2 | Convert the duration to seconds | 45 × 60 = 2,700 s |
| 3 | Compute the total bitrate | 500,000,000 × 8 ÷ 2,700 = 1,481,481 bit/s |
| 4 | Subtract the audio | 1,481,481 − 128,000 = 1,353,481 bit/s |
| 5 | Read it in Mbps | about 1.35 Mbps |
The result is the average the whole file can use. Larger jobs work the same way. Example: a 2-hour film (7,200 seconds) that must stay under 4 GB (4,000,000,000 bytes) with audio at 192 kbps has a total budget of 4,000,000,000 × 8 ÷ 7,200 = 4,444,444 bit/s. After the audio, the video gets 4,444,444 − 192,000 = 4,252,444 bit/s, about 4.25 Mbps. The forward calculation, with the same steps in the other direction, is in how to calculate video file size from bitrate and duration.
Leave headroom
A bitrate that fills the limit to the last byte is risky. Two things push a real file above the formula's answer.
First, the container adds overhead. RFC 8216 notes that the bit rate of a segment includes container overhead, so the streams plus the packaging are larger than the streams alone. Second, many encoders treat the bitrate as an average. MDN's audio guide describes an average bit rate setting as the encoder attempting to use, on average, the specified number of bits for each second, and says quality fluctuates over time as needed to meet that target. An average over the whole file can still land a little above or below the target.
The fix is to aim below the limit. Example: reserve 5 percent. For the 500 MB case, aim at 475,000,000 bytes. The total bitrate becomes 475,000,000 × 8 ÷ 2,700 = 1,407,407 bit/s, and the video gets 1,407,407 − 128,000 = 1,279,407 bit/s. The 5 percent is an illustration of the method, not a rule. Choose the margin that your limit and your risk require. Tracks or metadata you add later also count toward the limit. Constant vs. variable bitrate explains why a fixed rate predicts size better than a variable one.
When the bitrate comes out too low
The formula always returns a number, and it cannot see the picture. MDN's video guide says quality generally improves with higher bit rates, so a very small result is a warning that the video may look worse than you want. Only looking at an encoded sample tells you whether it is acceptable.
If the budget is too small, the formula shows the levers:
| Change | Effect on the video bitrate |
|---|---|
| Raise the size limit | More bits in total |
| Shorten the video | The same bytes cover fewer seconds, so the rate rises |
| Lower the audio bitrate | The freed bits go to the video |
| Remove an extra audio track | The whole of that track's bitrate goes to the video |
Example: in the 500 MB case, dropping the audio from 128 kbps to 64 kbps raises the video bitrate from 1,353,481 to 1,417,481 bit/s, a gain of about 4.7 percent. Cutting the video to 30 minutes at the same limit raises the total from 1,481,481 to 2,222,222 bit/s.
The unit of the limit matters
A limit written as "100 MB" and one written as "100 MiB" differ. NIST lists 1 MB as 1,000,000 bytes and 1 MiB as 1,048,576 bytes. So 100 MiB is 104,857,600 bytes, which is 4.86 percent more than 100 MB. For the 10-minute example, the total bitrate rises from 1,333,333 to 1,398,101 bit/s.
If you do not know which family a limit uses, plan for the smaller figure, the decimal one. Then you stay under the limit either way. Decimal vs. binary units explains where the two come from.
Common mistakes
- Forgetting to subtract the audio. The audio comes from the same budget. Leaving it out makes the file larger than the limit.
- Dividing by 8 instead of multiplying. Going from bytes to bits multiplies by 8. Dividing instead gives a bitrate 64 times too small.
- Using minutes. Convert to seconds first.
- Aiming exactly at the limit. Overhead and averaging can push the file over. Reserve a margin.
- Treating the bitrate as a quality promise. A bitrate that fits the limit may still look poor on difficult content. The formula only guarantees the size, within its limits.
FAQ
How do I calculate the bitrate I need for a given file size?
Multiply the size in bytes by 8, divide by the duration in seconds, then subtract the audio bitrate. The result is bits per second for the video. Example: 200,000,000 bytes over 400 seconds with 64 kbps audio gives 200,000,000 × 8 ÷ 400 = 4,000,000 bit/s in total, so 3,936,000 bit/s for the video.
Can I hit an exact file size?
Not exactly. A constant bitrate gets close to the formula's result, plus container overhead. A variable bitrate depends on an average, so the final size lands near the target and not on it.
What if my size limit is in MiB or GiB?
Convert it to bytes first, with 1 MiB = 1,048,576 bytes and 1 GiB = 1,073,741,824 bytes, then apply the formula. The storage unit converter does the conversion.
Which setting should I use to hit a size target: constant or variable bitrate?
A constant bitrate follows the formula most closely, so it is the easiest to predict. With a variable setting, enter your computed number as the average and keep the margin described above, since the average is what the size depends on.
Sources
- MDN Web Docs, Web video codec guide. Accessed November 6, 2026.
- MDN Web Docs, Digital audio concepts. Accessed November 6, 2026.
- IETF, RFC 8216: HTTP Live Streaming. Accessed November 6, 2026.
- NIST, Definitions of the SI units: The binary prefixes. Accessed November 6, 2026.



