Guides Tested

Can you predict a video's final size before exporting?

Here at Edit Videos we tested what happens when you set the final size you want and the codec (H.264, AV1…), and measured it many times: how close each lands to the size you asked for, where our predictions fail, and how much video fits in 10 or 20 MB, in duration, for each codec.

By Thiago Vitorino, Edit Videos Team

When you pick a size in Edit Videos, the editor works out a bitrate and a picture size, and your browser's encoder makes the file. We measured how closely that encoder keeps to the bitrate it is given, then ran whole exports with a 20 MB target. In short: on our first two clips the file landed within a few percent of the size asked once each pixel got about 0.03 bits per frame, harder footage needed more, and below its floor the encoder stops listening. That is why the size you pick is a target the editor aims under, not a promise.

The question behind the size slider

Edit Videos lets you set a maximum size before you export, so a clip fits an upload form or a chat's limit. The editor cannot weigh a file it has not made yet, so it plans one: from the size you picked it works out a bitrate, the number of bits each second of video may use, and hands that number to the encoder built into your browser.

Whether the file comes out the size you asked for depends on how well that encoder keeps to the number. We wanted to know how close it lands, where it stops following, what the editor does when the first try comes out too big, and what all of that means for the 10 or 20 MB that the editor's Discord send works to.

The clips, the browser and the script

Every run happened in headless Chrome 145 on Linux, on one machine, with the browser's software encoders reached through WebCodecs and the same media library the editor uses. Our script, measure-bitrate.ts, loops a short clip to a set length, encodes it at a chosen bitrate and picture size, and compares the bytes that come out with the bitrate multiplied by the length.

The first round used two clips at 30 frames a second: Jellyfish, camera footage full of fine moving detail and hard to compress, and Big Buck Bunny, an animated film that compresses easily. The second round, ten days later, added AV1 and three harder clips from Xiph's test collection, crowd_run, park_joy, ducks_take_off, at 50 frames a second. The clips are not in our repository; the reports that sum up each run are.

One unit runs through this page: bits per pixel per frame, written bpp. It is the video's bitrate divided by its width, its height and its frame rate, so it says how many bits each pixel of each frame gets. It puts a 480p file and a 1080p file on the same scale, and it matters because the editor's plan is written in it.

Does the encoder keep to its bitrate?

The first table compares the size of each file with the size its bitrate asked for, over a minute of output, the MP4 container included. A plus sign means bigger than asked, a minus sign smaller. Each clip was encoded at three bitrates and three picture sizes, once in constant and once in variable bitrate mode, and the two modes gave the same file, often to the byte.

File size against what the bitrate asked for, H.264, by clip, bitrate and picture size
ClipAsked1080p720p480p
Jellyfish2,500 kbps−0.4%−0.5%−0.5%
Big Buck Bunny2,500 kbps−1.4%−0.8%−1.8%
Jellyfish1,200 kbps+28%−0.5%−0.7%
Big Buck Bunny1,200 kbps−0.2%−0.8%−1.4%
Jellyfish400 kbps+278%+94%+1.6%
Big Buck Bunny400 kbps+137%+2.8%−0.8%

Every run that could reach its target landed between 1.8% under and 2.8% over the size asked. The worst ten-second stretch inside any of those files was within 5.3% of its share, so the rate holds along the whole video and not only on average. The container itself added under 0.5%.

The large plus signs in the table are not near misses. At those bitrates the encoder had reached its coarsest setting and made the file as big as that setting makes it: about 1.5 Mbps for Jellyfish at 1080p, whichever of the two lower bitrates it was given. Asking for less changed nothing, and that sets the rule the rest of this page follows.

The floor, and why the plan stops at it

Where the encoder stops listening depends on the footage. For Big Buck Bunny it was about 0.015 bpp, for Jellyfish between 0.024 and 0.028, and every run at 0.032 bpp or more landed where it was asked. So the editor's plan never gives the picture less than 0.03 bpp. Below that, the size you pick could not be controlled; only the look of the file would get worse.

The plan also aims at 90% of the size you pick rather than all of it. These clips needed less room than that, but phones and many laptops encode with dedicated hardware, which this machine did not offer, and the margin is kept for them. The line above Export video shows the size the plan aims at, so it reads a little lower than the number you set.

A whole export with a 20 MB target

A bitrate test is half the story, so the second test went through the editor's own export with a 20 MB target. Each clip was looped to the lengths in the second table at 1080p, with sound, and the engine chose the bitrate and the picture size by itself, exactly as it does when you move the slider.

The file each clip came out as with a 20 MB target in the editor's export, H.264, and the picture the plan chose
LengthSourceJellyfishBig Buck BunnyPicture
60 s86 MB17.9 MB17.7 MB1080p
120 s172 MB17.9 MB17.8 MB720p
300 s430 MB18.5 MB17.9 MB480p

Every file came out between 17.7 and 18.5 MB: under the target each time, and close to the 90% the plan aims at. No first encode came out over, so the second encode described below never ran. What changed with length was the picture. A longer video gets fewer bits each second, and the plan stepped down from 1080p to 720p and then 480p to keep every pixel above the floor.

That step is the trade a size target makes. Squeezing the longest of these videos into 20 MB at 1080p would push the encoder under its floor, where it ignores the bitrate and the file comes out too big anyway. A smaller picture keeps the size under control. The line above Export video names the picture size before you start, so the trade is in plain view.

When the first file comes out too big

After the encode, the engine compares the finished file with the size you picked. If the file is over, it encodes once more, one picture step smaller at the same bitrate, and returns that result whatever its size. It does not try a lower bitrate: near the floor the encoder makes the same file whatever number it gets, so only fewer pixels make the file smaller.

To watch the second encode at work we built a clip no encoder can compress well: 4 seconds of fresh random noise in every frame, at 720p, with a 1 MB target. That works out at 0.07 bpp, above the floor, yet the first encode came out at 2.5 MB. The second, at 480p, made 1.7 MB, still over. The same test with a sliding texture in place of noise came in under the target on the first try, at 0.93 MB.

There is no third encode. At 480p, with the encoder at its coarsest setting, a lower bitrate changes nothing, and the editor does not go below 480p because a picture that small is not worth keeping. When the file is over, the size line on the done screen says it is over the size you picked, and the file is still offered: it is the smallest the editor could make, and you decide whether it will do.

AV1 on harder footage

The second round began with a surprise. Given no frame rate, the browser's encoder budgets for 30 frames a second, so a file at 50 frames came out about 1.67 times the size asked, in H.264 as well as AV1. The editor now passes each video's own frame rate to every encode, and every number from here on is with that fix.

The furthest over its bitrate any of the three harder clips came out, by bits per pixel per frame
bppAV1 constantAV1 variableH.264
0.026+136%+88%—
0.048+30%+16%+67%
0.054+13.5%+18%+40%
0.059+3.6%+17%+9.6%
0.077+0.3%+6%+6.6%
0.109+0.3%+6.7%−1%

The third table shows, at each bpp level, the furthest over its bitrate any of the three clips came out. On this footage H.264 stayed within 3% only above 0.077 bpp, well over the floor that held for the first two clips. AV1 in constant mode got there above 0.0585, and in variable mode only above 0.174. So for a size target the editor encodes AV1 in constant mode; without one it stays variable, as H.264 does.

Under its floor neither encoder goes below a minimum, whatever it is asked: on ducks_take_off at 1080p, about 5.2 Mbps for AV1 and 8.3 for H.264. AV1's floor in the editor stayed at 0.03 bpp, the same as H.264's, so the slider's smallest size is the same for both formats, and AV1 never gets a smaller picture than H.264 at the same size.

The size target on the harder clips

The last table repeats the 20 MB export on the three harder clips, AV1 beside H.264. At the two shorter lengths AV1 landed near the plan's aim every time, in one encode, at a picture as large as H.264's or larger. H.264 needed its second encode once, on ducks_take_off at the shortest length, which is why it ended at 480p there while AV1 kept 720p.

A 20 MB target on the harder clips at 50 frames a second: the file and the picture, AV1 beside H.264
ClipLengthAV1PictureH.264Picture
crowd_run60 s18 MB720p18 MB720p
park_joy60 s18.1 MB720p18 MB720p
ducks_take_off60 s18.1 MB720p17.9 MB480p
crowd_run120 s18 MB480p18 MB480p
park_joy120 s18 MB480p17.9 MB480p
ducks_take_off120 s18 MB480p18.4 MB480p
crowd_run300 s37.8 MB480p40.5 MB480p
park_joy300 s28.8 MB480p31.4 MB480p
ducks_take_off300 s41.2 MB480p——

At the longest length both missed, by a lot. 20 MB over that time is 0.37 Mbps, which at 480p and 50 frames a second is 0.018 bpp, under both floors. The slider does not offer that size for such a video, because its lowest point is the smallest size the plan can keep; we forced it to see what happens, and the one retry had no smaller picture to go to. The empty cells are H.264's second encode on ducks_take_off, where the test page ran out of memory.

What fits the Discord send: 10 or 20 MB

The screen after an export can post the video to a Discord channel. That route normally takes up to 20 MB, and 10 MB in some cases. Working the plan backwards from the floor, with Opus sound and a 30 fps video, gives the longest video each size holds at each picture. At 10 MB: about 0:36 at 1080p, 1:14 at 720p and 2:24 at 480p. At 20 MB: about 1:12, 2:29 and 4:48. These lengths are worked out from the measured floor rather than measured one by one.

Longer than the 1080p length, a file of that size means a smaller picture. Past the 480p length it means trimming, and the editor asks you to make the video shorter. Game footage at twice that frame rate gets a little over half of each length, since every second carries twice the frames. Hard footage may also need the second encode, as ducks_take_off did.

Limits of this test

This was one machine with Chrome's software encoders. Phones and many laptops encode with dedicated hardware, which may keep to the bitrate less closely. The margin in the plan and the second encode are there for those, and the editor's anonymous counts record how often an export comes out over the size picked, so misses in daily use would show up.

The clips were short and looped, so a long video that changes from scene to scene may behave differently. The first round's raw output was not kept; its report was written from the figures recorded when it ran. Your own footage will sit somewhere between the easy and the hard clips here, and when we measure again, the tables and the tested dates change with it.

What to know

  • On our first two clips, above about 0.03 bits per pixel per frame, the browser's H.264 landed between 1.8% under and 2.8% over the size its bitrate asked for.
  • Below its floor the encoder stops at its coarsest setting, so asking for less gives the same file.
  • With a 20 MB target, every H.264 export of our first two clips came out between 17.7 and 18.5 MB in one encode.
  • The Discord send's 10 MB hold about 0:36 of 30 fps video at 1080p and 2:24 at 480p, and its 20 MB about 1:12 and 4:48, before the size can no longer be kept.

Questions

Will my export always come out under the size I pick?

Not always. The editor aims at 90% of it, and our exports of real footage, at sizes the slider offers, all came in under it. Footage that is very hard to compress, or a hardware encoder, can still go over; then the done screen says so and still offers the file.

Why does the picture get smaller when I pick a smaller size?

Below about 0.03 bits per pixel per frame the encoder stops following its bitrate. Fewer pixels keep each one above that floor, so the size stays under control instead of being missed.

Why not encode a third time if the file is still too big?

By then the picture is at 480p and the encoder at its coarsest setting, so a lower bitrate changes nothing. A third pass would add a full encode to the wait without making the size more likely to fit.

Is AV1 better than H.264 for a small file?

On our clips, yes. It kept to its bitrate from a lower bpp in constant mode, and at the same size it never got a smaller picture than H.264. Pick it when the place the file goes plays AV1.

How long a video can the editor send to Discord at 1080p?

The Discord send normally takes up to 20 MB, and 10 MB in some cases. At 30 frames a second, 20 MB keeps 1080p for about 1:12 and 10 MB for about 0:36; longer videos step down to 720p, then 480p, and past about 4:48 (2:24 at 10 MB) the editor asks you to make the video shorter.

Thiago Vitorino Tech Lead and software engineer

Thiago Vitorino leads the Edit Videos Team. His articles draw on 22 years of building for the web, with TypeScript, Rust and front-end performance.