noupload.tools

guides

How video compression actually works

Four things decide the size of a video file. Most people only touch one of them, and usually the wrong one.

A video file is a stream of pictures, and a modern encoder spends most of its effort not storing them. It stores the first picture of a scene, then for the next several dozen frames it stores only what moved and by how much. That is why a two-minute clip of a talking head is tiny and two minutes of confetti is enormous: the encoder has nothing to reuse when every pixel changes. Everything in this guide follows from that single idea. Compression is about how much of each frame can be described in terms of a frame that came before it, and how much error you are willing to tolerate in the description.

The four levers

There are exactly four things you can change that matter, and they are worth ranking, because they are not equal.

  1. Resolution. Going from 1080p to 720p drops the pixel count by 56 percent, and file size falls by roughly the same fraction at the same quality setting. If a video is going to be watched on a phone, inside a chat window or embedded at 640 pixels wide, 1080p is paying for detail nobody will see. This is the biggest lever and the one that costs least in perceived quality.
  2. Quality target (CRF). This is the error you tolerate per frame. It is the second-biggest lever and the one most compressors expose as a slider.
  3. Frame rate. Screen recordings at 60 fps can almost always drop to 30, which halves the number of frames the encoder has to describe. Footage of real motion is less forgiving; 24 or 30 fps material should be left alone.
  4. Audio. Usually a rounding error on a video file, but not always. A 30-minute lecture with 320 kbps stereo audio is carrying 72 MB of sound for a voice that would be indistinguishable at 96 kbps mono.

The compress tool exposes the first, second and fourth as controls, and the command panel shows how each one lands in the FFmpeg line as you move it.

What CRF means

CRF stands for constant rate factor. It is the quality dial for the x264 encoder, which is what produces the h.264 video that every phone, browser and television can play. The scale runs from 0 to 51. Lower is better quality and a bigger file. The encoder's default is 23. A useful rule of thumb is that every 6 steps roughly halves or doubles the bitrate: CRF 29 produces a file about half the size of CRF 23, and CRF 17 about twice the size.

The reason it is called constant is important. CRF does not aim for a file size. It aims for a consistent level of visual quality across the whole video, and lets the bitrate go wherever it needs to in order to hit that. Still scenes get almost no bits because they need almost none; a fast pan gets a lot. This is why two videos compressed at the same CRF can come out at wildly different sizes, and why it is the right tool when what you care about is how the result looks rather than exactly how many megabytes it is.

Sensible ranges, from experience with ordinary footage:

CRFWhat you get
18 to 20Visually lossless to most eyes. Archival, or a master you will edit again.
23The encoder's default. Good for anything you will watch full screen.
26 to 30Usually halves the size of a phone recording with no loss you would notice in a chat window or email preview. The tool here defaults to 28.
32 and upBlocking becomes visible in flat areas and gradients, especially skies and shadows. Acceptable for a preview, not for anything you are proud of.

What the preset does

The preset is the one control that costs nothing in quality. It tells the encoder how hard to search for a good way to describe each frame. veryfast makes quick decisions; slow tries many more options before committing. At the same CRF, a slower preset produces a smaller file of the same quality. It simply takes longer to do it.

In a browser, running on a single thread, the difference in time is large: medium can take three or four times as long as veryfast on the same clip. The size saving is usually in the range of 10 to 20 percent. So the trade is clear. For a one-off where you can wait, pick a slower preset. For a long recording, or on a laptop running on battery, stay fast and lower the resolution instead, which buys far more than the preset ever will.

Why the size target matters so much on chat apps

Discord's free tier caps uploads at 10 MB. Many email servers reject attachments over 20 or 25 MB. Neither of those numbers cares how your video looks; they care about bytes. When the constraint is a hard number, the process is to work backwards from it.

Bitrate is size divided by duration. A 10 MB cap on a 60-second clip means 10 megabytes times 8 bits, over 60 seconds, which is about 1.3 megabits per second for video and audio together. Take 96 kbps off for audio and you have about 1.2 Mbps for the picture. At 720p that is fine for a talking head and poor for sport. At 480p it is fine for nearly anything. So the honest advice for a 10 MB target on a minute of footage is 480p or 540p, not 1080p at a punishing CRF. The Discord preset starts from exactly that calculation, and the email one is the same idea with a higher ceiling.

If you are doing this in a terminal rather than here, two-pass encoding with a bitrate target (-b:v 1200k across two passes) hits a size almost exactly. The tools on this site use CRF instead, because it is a single pass and because the result looks better for the same bytes on anything that is not edge-of-the-cliff tight. If the first attempt comes out too large, step the CRF up by two and run again; each step of two removes roughly a fifth of the size.

The things that do not help

  • Converting MP4 to MP4. Re-encoding a file that is already h.264 at the same resolution and a similar CRF will make it slightly worse and barely smaller. Compression is lossy; each pass throws more away. If a file is already small enough, leave it.
  • Changing the container. MP4, MOV and MKV are wrappers. Moving a video from one to another does not touch the picture. See containers and codecs if that distinction is new.
  • Upscaling first. Enlarging a 720p video to 1080p and then compressing it gives you a 1080p-sized file with 720p worth of detail. Nothing is gained.
  • A higher audio bitrate than the source. If the input has 128 kbps AAC, asking for 192 kbps stores the same sound in a bigger box.

h.264 or something newer

h.265 (HEVC) and AV1 both produce smaller files than h.264 at the same quality, by somewhere between 25 and 50 percent depending on the content. They are also much slower to encode, and playback support is less universal: h.265 plays on Apple devices and most modern hardware but not in every browser, and AV1 is the reverse. For a file that will be sent to somebody else and has to simply work, h.264 in an MP4 with AAC audio remains the right default, and it is what the compress tool produces. The -pix_fmt yuv420p and -movflags +faststart flags you will see in its command exist for the same reason: the first guarantees the colour format every player expects, the second moves the index to the front of the file so it starts playing before it has finished downloading.

A procedure

  1. Decide where the video will be watched, and pick the resolution for that screen. Phone or chat: 720p or below. Embedded on a page: whatever width the player is. Television: leave it.
  2. Start at CRF 26. Look at the result on the device it is for, not on a 27-inch monitor at 200 percent.
  3. If it needs to be smaller, drop the resolution one step before touching CRF again.
  4. Set audio to 96 kbps for speech and 128 for music, or remove it if the video does not need sound.
  5. Only then, if you can afford the time, move the preset one step slower.

That order exists because it removes the bytes nobody would have seen first, and the bytes you would have seen last.

Tools this applies to

More guides