How to reduce video file size: bitrate, codec and compression without losing quality
Our own ffmpeg measurements on a 1920×1080 test signal: the CRF ladder, the difference between presets, what the frame rate costs, and the formula that gives the weight of the finished file in advance.
How to reduce video file size is not a question about a compression program, but about the encoding parameters. The weight of the file is set by CRF: the higher its value, the more bits the codec spends on detail. The encoding preset and the frame rate change that weight by a few percent. Below are the tables from our own measurements and the formula by which the weight of the file is calculated in advance.
How to reduce the size of a video file
We encoded a synthetic 1920×1080 test signal at 25 fps, 30 seconds long, in ffmpeg 9.0.2 — a separate file for every setting, and the sizes were counted byte by byte. The source in the measurements is a test pattern: it has almost no detail and no movement, so real footage at the same CRF gives a higher bitrate, and every number below is a lower bound rather than a forecast for a particular project. Read the tables as the behaviour of the encoder on a clean signal, and not as a prediction for your own material.
| Codec and CRF | File size | Bitrate | What it means |
|---|---|---|---|
| H.264, CRF 18 | 31 758 807 bytes | 8.47 Mbit/s | The heaviest file in our ladder |
| H.264, CRF 23 | 20 558 332 bytes | 5.48 Mbit/s | A working compromise between weight and detail |
| H.264, CRF 28 | 10 773 733 bytes | 2.87 Mbit/s | The lightest file in our ladder |
A CRF step changes the weight by a factor, and not by a few percent: the move from 23 to 28 takes the file from 20 558 332 bytes down to 10 773 733 bytes — 1.9 times smaller, that is 52.4 % of the weight of the CRF 23 file. How much detail each row holds, we did not measure: our measurements contain no quality comparisons, we did not compute VMAF, SSIM or PSNR. So the choice of CRF in this article is a conversation about the weight of the file, and not about what exactly will be visible in the picture. What the ladder does show for sure is the price of the quality target: every step of CRF is paid for in bits.
The preset is responsible for the encoding speed, and not for the weight: the same CRF 20 on different presets gave files that differ by a few percent. We measured this parameter separately on our own material, to check whether a fast preset really saves what it promises. The size and the preset are different questions, and mixing them up is the usual source of the expectation that a faster preset makes the output lighter.
| Codec and preset | File size | Bitrate | Comment |
|---|---|---|---|
| H.264, CRF 20, preset slow | 26 963 938 bytes | 7.19 Mbit/s | Encodes the longest, the file is above average |
| H.264, CRF 20, preset medium | 28 031 814 bytes | 7.475 Mbit/s | The middle preset: a compromise between time and weight |
| H.264, CRF 20, preset veryfast | 24 872 350 bytes | 6.633 Mbit/s | Encodes the fastest, the file is the smallest |
On our material veryfast gave a file 7.8 % smaller than slow, and the medium preset gave a file 4.0 % bigger. The sign of the difference depends on the picture: on a synthetic signal the fast preset came out smaller than the slow preset, on live footage the direction can be the other way. Choosing a preset for the sake of the size makes no sense: CRF sets the size, and the preset sets the time spent on encoding. The same CRF keeps the same quality target on every preset — what changes is how long the encoder works to reach it.
The frame rate costs the file only when the frames in the file are new. A move from 25 to 30 fps by frame duplication adds repeated frames, but adds almost no bits: a repeated frame carries almost no new information, and the codec spends the minimum number of bits on it. Motion interpolation works the other way round — it creates pixels that were not in the source, and the codec has to encode them. This is why the frame rate by itself is not a reason to expect a heavier output.
| Variant | Frames | File size | Bitrate | Change |
|---|---|---|---|---|
| Source 25 fps | 750 frames | 29 796 554 bytes | 7.95 Mbit/s | The starting point of the measurement |
| → 30 fps, frame duplication | 900 frames | 29 073 502 bytes | 7.75 Mbit/s | 2.4 % smaller |
| → 60 fps, motion interpolation | 1796 frames | 37 956 427 bytes | 10.14 Mbit/s | 27.4 % bigger |
Duplication makes the file 2.4 % smaller, and interpolation to 60 fps makes it 27.4 % bigger — from the same source. The duration changes along with it: 29.933 seconds against 30 seconds. A separate caveat: the interpolation was done with the minterpolate filter in ffmpeg, the exact numbers depend on the algorithm, but the conclusion that interpolation costs more than duplication carries over to any interpolator. In this measurement we measured only the video stream — the source had no audio track, so the weight of the sound is not included in any of the rows.
Resolution affects the weight directly, and it is visible without any caveats: the vertical frame 1080×1920 weighs less than the full frame 1920×1080 at the same CRF.
| Frame | File size | Bitrate | How it was obtained |
|---|---|---|---|
| H.264, CRF 23 | 20 558 332 bytes | 5.48 Mbit/s | Full frame 1920×1080 |
| Vertical 1080×1920, H.264 CRF 23 | 8 346 717 bytes | 2.23 Mbit/s | Upscale to 3413×1920 with a centre crop |
| 4K 3840×2160, H.264 CRF 23 | 44 092 600 bytes | 11.76 Mbit/s | Upscale from 1920×1080 |
A caveat for this table: the vertical frame and the 4K were obtained by an upscale from 1080p, and not by a native resolution. After the interpolation there is less detail in the frame, so in our measurement the vertical weighs 8 346 717 bytes — 2.5 times lighter than the full frame — while the 4K, on the contrary, pulls 44 092 600 bytes, and it does that with a much larger pixel count. These numbers show the weight of a file of that size, and not how many times a real 4K is heavier than a real vertical. A native comparison needs material that was shot or rendered at those sizes in the first place.
How much the file weighs: the calculation by bitrate
The weight of the file follows directly from the bitrate and the runtime: add up the video bitrate and the audio bitrate, multiply by the duration in seconds and divide by 8 bit/B — that gives the bytes. The size formula: size = (video bitrate + audio bitrate) × time ÷ 8 bit/B. It is handy for calculating the weight before the render, when the runtime is already known and the limit of the platform is not. The division by 8 bit/B is where the bits of both streams become bytes, and it is the only place where a unit conversion is needed.
- A minute of video stream at CRF 23: 5.48 Mbit/s × 60 seconds ÷ 8 bit/B = 41.1 MB
- A minute of video stream at CRF 28: 2.87 Mbit/s × 60 seconds ÷ 8 bit/B = 21.5 MB
- A check against our own measurements: CRF 23 on the full frame gives 20 558 332 bytes in 30 seconds, CRF 28 — 10 773 733 bytes in the same 30 seconds
From here the reverse task: if the platform limit on the weight of the file is known and the duration is not agreed yet, divide the limit by the total bitrate and you get the maximum runtime. The same calculation in the other direction answers how many seconds fit into a file of a given size. Calculating from the bitrate is cheaper than re-encoding the finished file and looking at what came out. The point of the formula is not the exact byte count, but the order of magnitude: it shows whether the planned runtime and the planned bitrate fit into the limit of the platform before anyone starts the render.
Separately about the delivery: different platforms need different versions of the file, and not a version for all of them. In our editing work a render for YouTube/VK/Reels means separate versions per platform, and which bitrate and codec to put into them is decided by the requirements of the platform in question, and not by the wish to make the file lighter. A lighter file is not automatically a better file: the requirement of the platform is the reference point, and the estimate starts from it.
Frequently asked questions
Which bitrate should I choose?
The bitrate is a consequence of CRF, and not an independent decision: in our ladder CRF 23 on 1080p gives 5.48 Mbit/s, and CRF 28 — 2.87 Mbit/s. Calculate from what the platform requires and from the runtime: a minute of video stream at CRF 23 — 41.1 MB, at CRF 28 — 21.5 MB. If the platform sets a ceiling on the bitrate, then CRF is chosen to fit under it, and not the preset.
Is it worth changing the preset to reduce the file?
By a few percent: veryfast gave a file 7.8 % smaller than slow, and the medium preset gave a file 4.0 % bigger, at the same CRF 20. If the task is to fit into a limit, the preset will not help: CRF sets the size, and the preset changes only the encoding time. The preset decides how long you wait, and not how heavy the result is.
Why are your numbers so small?
The source in our measurements is a synthetic test pattern: it has almost no detail and no movement. Real footage at the same CRF gives a higher bitrate, so all our numbers are a lower bound. We did not measure picture quality, so the article contains no comparisons of the image quality — only the weight of the file, the bitrate and the frame rate.
What to read next
Need this done as a project?
We take on projects like this — with the same settings we walk through in this piece.