video-compressionffmpegvideo-encoding

How to compress video: five reasons, five different settings

··11 min read
How to compress video: five reasons, five different settings

To compress video, pick the lever that matches your reason for compressing: re-encode at a lower bitrate or CRF, downscale the resolution, or switch codecs. Most jobs need two of the three, and the reason decides which two.

  • Hard upload ceiling: compute a bitrate from duration, then verify the output size.
  • Web delivery: CRF around 23 on H.264, plus faststart.
  • A platform that re-encodes anyway: match its resolution and stop there.
  • Storage cost: change the codec, keep the resolution.
  • AI model input: cut resolution and frame rate, ignore bitrate.

Compression is three operations sharing one word

Compression covers three separate operations that most guides blend into one quality slider. Re-encoding keeps the frame size and codec but spends fewer bits per frame. Downscaling throws pixels away: 1920x1080 becomes 1280x720, a quarter less picture to encode. Switching codecs keeps the picture identical and asks a smarter encoder to describe it in fewer bits.

LeverWhat you changeWhat it costs you
Re-encode lowerBitrate or CRFDetail in motion and grain, first visible on fast pans
DownscalePixel dimensionsSharpness on large screens, permanently
Switch codecH.264 to H.265 or AV1Playback compatibility, and 4x or more encode time

Only the codec switch leaves the picture intact. Transcode vs encode vs remux vs compress sorts the four terms out.

A hard megabyte ceiling needs arithmetic, not a slider

An upload cap is the one case where a quality setting is the wrong tool: CRF gives you a quality target, and the cap is a size target. The arithmetic is one line: target bitrate in kbps equals target size in MB times 8,000, divided by duration in seconds. Subtract the audio bitrate and the rest is your video bitrate.

Real caps worth knowing: Gmail swaps any personal-account attachment over 25 MB for a Drive link (Google), and the WhatsApp Cloud API caps video media at 16 MB and wants H.264 video with AAC audio (Meta). Discord's ceiling moves with Nitro tier and server boost, which is why its number gets reported four different ways.

Each has its own post here with the math done: Discord at 10, 50, or 500 MB, the 25 MB email limit, and WhatsApp Business under 16 MB. The pattern is the same in all three: ceiling and duration give you the bitrate, then you measure the result instead of trusting it.

Web delivery wants a quality target and a moved header

Video you serve from your own site is the opposite job. Nobody gave you a size limit, so encode for a quality level and let the file land where it lands. x264's CRF scale runs from 0 to 51, defaults to 23, and 17 to 28 is the sane working range per FFmpeg's own H.264 guide. Lower is better quality and a bigger file, and every 6 points roughly halves or doubles the bitrate.

ffmpeg -i master.mov -c:v libx264 -crf 23 -preset slow \
  -vf scale=-2:1080 -c:a aac -b:a 128k \
  -movflags +faststart web.mp4

The -movflags +faststart is doing real work. Without it the MP4 index sits at the end of the file and a browser has to download most of the video before the first frame appears. It costs one extra pass over the finished file. Compress video for the web goes deeper on preset choice and where the bitrate goes.

A destination that re-encodes your upload caps how much work is worth doing

Social platforms transcode on ingest, so the file you upload is never the file anyone watches. Sending TikTok or Instagram a 60 Mbps ProRes master buys you a longer upload and an identical result; their encoder re-derives everything from your pixels. Match the resolution they publish, 1080x1920 for vertical, keep the bitrate high enough that their encoder isn't amplifying your artifacts, and stop.

That's the honest boundary here. If a host transcodes and serves your video for you, compressing beforehand saves upload time and nothing else, and a desktop encoder handles a one-off file for free. Compression is worth automating when the file has to arrive at a specific size, or when there are hundreds of them.

Storage cost is the only reason to change codec

Shrinking an archive is the case where the codec switch pays, because you control playback at both ends. HEVC was designed to hit roughly 50% bitrate reduction over H.264 at equivalent perceptual quality, the target stated in the HEVC standard overview paper-Sullivan-Ohm/d94750bc374747d3e90c99e25ab2e238882f46ae). Measured comparisons put AV1 about 20% below HEVC again at matched quality, at around four times the encoding cost.

The catch is playback. Chrome decodes HEVC only where a hardware decoder exists, and Firefox turned it on by default only from version 134 to 137 depending on platform (caniuse). AV1 has shipped in Chrome since 70 and Firefox since 67 (caniuse), which makes it the safer free-license choice for anything a browser has to play. An H.265 file is a storage format, and treating it as a delivery format is how you get support tickets. NetInt's 2026 state of video encoding survey of 286 professionals still found H.264 at 84% production adoption against AV1's 17% (NetInt), and compatibility is most of the reason.

A model reading your video charges by frame, not by byte

When the consumer is an AI model, bitrate stops mattering and two other numbers take over. Gemini tokenizes video at 1 FPS: 258 tokens per frame at default media resolution, 66 at low, plus 32 tokens per second of audio (Google). A 10 minute clip at default resolution is about 155,000 tokens of video before the audio track, and halving the bitrate changes that by zero.

What does change it: dropping to low media resolution, sampling fewer frames, trimming to the segment that matters, and stripping audio you aren't going to ask about. Gemini 4 Argon runs at $2 and $10 per million tokens through November 30, 2026, then $4 and $20 from December 1 (VentureBeat). Shrinking the input before Dec 1 works through that arithmetic on a real pipeline.

Worked example: 190 seconds under 16 MB, measured not assumed

The ceiling case end to end: a 190 second screen recording, 1920x1080 at 30fps, 212 MB, running about 9 Mbps, headed for the WhatsApp Cloud API at 16 MB.

First, decide what 16 MB means. The cap could be 16,000,000 bytes or 16,777,216 bytes. Size for a 15 MB decimal budget and you clear either one. That gives 15 times 8,000 divided by 190, or 631 kbps total. Reserve 64 kbps for mono AAC and the video gets 567 kbps, so round down to 560.

At 560 kbps, 1080p would look like wet paper. Downscale to 854x480 and two-pass the encode so the bits land where the motion is:

ffmpeg -y -i input.mp4 -c:v libx264 -b:v 560k -vf scale=854:-2 \
  -pass 1 -passlogfile wa -an -f mp4 /dev/null

ffmpeg -i input.mp4 -c:v libx264 -b:v 560k -vf scale=854:-2 \
  -pass 2 -passlogfile wa -c:a aac -b:a 64k -ac 1 \
  -movflags +faststart output.mp4

Two-pass works because the first run writes statistics to a log file, ffmpeg2pass by default and settable with -passlogfile, that the second run reads to hit the requested bitrate (FFmpeg docs). Run both commands on the same disk, in order, with that file intact between them.

Then verify, because a bitrate target is a request and not a guarantee:

ffprobe -v error -show_entries format=size,duration \
  -of default=noprint_wrappers=1 output.mp4

Expect roughly 14.8 MB. The same job as one call, with resolution, bitrate and codec options in the request body (the shapes are in the docs):

curl -X POST https://api.ffmpeg-micro.com/v1/transcodes \
  -H "Authorization: Bearer $FFMPEG_MICRO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [{"url": "https://storage.example.com/input.mp4"}],
    "outputFormat": "mp4"
  }'

Poll the job until it reports completed, download the output, and verify with POST /v1/ffprobe, which returns format.size in the same JSON shape as ffprobe locally. A 190 second input costs 19 tokens, because a token buys 10 seconds of input video metered per second.

The decision changes shape when it runs a thousand times a month

Everything above assumes a person looking at the result. Unattended, three things break. Nobody eyeballs the output, so the ffprobe size check decides whether the file ships or re-encodes at a lower target. Two-pass stops being available in any stateless job API, because the pass-1 stats file has no machine to live on between calls, so you either compute a single-pass bitrate from duration and verify, or use CRF and accept a floating size. And n8n, Make, and Zapier have no FFmpeg binary, so the encode has to happen somewhere that does.

Over 700 developers and automation builders run jobs through FFmpeg Micro, more than 300 of them from Make or n8n, where compressing a video means an HTTP call and a poll loop instead of a container with an encoder in it. Billing follows input duration per second, so compressing hard and compressing lightly cost the same, trimming 30 seconds out of an hour bills 30 seconds, and failed jobs are never billed. A thousand one-minute clips a month is 6,000 tokens, inside the 7,000 that the $49.99 Pro plan includes.

Batch work hits a question upstream of compression: when every input is a different resolution, codec and frame rate, the better move is normalizing to one house spec and compressing from there, instead of deriving settings per file forever.

FAQ about compressing video

Does compressing a video harder cost less to process?

Compressing harder does not cost less on an input-duration meter. FFmpeg Micro bills per second of input video, so a 90 second clip costs 9 tokens whether the output is 400 MB or 4 MB. On meters that count output minutes or output renditions, heavy compression and light compression also cost the same, because both produce one output of the same duration. Which meters keep billing after the job ends compares the shapes.

How do I check the compressed file actually landed under the cap?

Read the finished file's size with ffprobe instead of trusting the bitrate you asked for. ffprobe -v error -show_entries format=size -of default=noprint_wrappers=1 out.mp4 prints the byte count, and the API equivalent is a POST /v1/ffprobe call returning format.size in its JSON. Build the comparison against your ceiling into the workflow, because a bitrate target is a request to the encoder, not a promise.

Can I compress video inside n8n, Make, or Zapier?

n8n, Make, and Zapier can't run FFmpeg themselves, so compression inside them means calling an API that does. n8n and Make have a dedicated FFmpeg Micro node and app, and Zapier reaches the same REST endpoints through its HTTP action. The workflow step looks like submit, poll, download, the same as from code.

Is H.265 worth switching to?

H.265 is worth it for storage and usually wrong for delivery. It targets roughly half the bitrate of H.264 at matching quality, which is real money on an archive, but browser playback depends on hardware decoders and Firefox only enabled it by default in the 134 to 137 releases. If a web page or a social upload is the destination, stay on H.264, or use AV1 where encode time allows.

Does zipping a video make it smaller?

Zipping an MP4 saves almost nothing, usually under 2%, because H.264 has already removed the redundancy a general-purpose compressor looks for. The same is true of MOV, MKV and WebM files holding modern codecs. Re-encoding, downscaling or switching codec are the only three operations that meaningfully change a video's size.

Working through the five levers by hand is worth doing once, and the free Learn FFmpeg course covers the commands behind them across nine lessons. When the same decision repeats on a schedule, Sign up free hands you the API that runs it: nothing to install, no encoder box to keep alive, callable from your code, from n8n, Make and Zapier, or from an AI agent, with a free tier to start on.

About Javid Jamae

Founder & CEO at FFmpeg Micro

Javid is a software engineer, author, and entrepreneur with over 25 years of professional software development experience across enterprise, startup, and consulting environments. He founded FFmpeg Micro to make video processing accessible to developers through a simple, automation-first REST API.

Software EngineeringVideo ProcessingFFmpegCloud ArchitectureAPI DesignAutomation

Ready to process videos at scale?

Start using FFmpeg Micro's simple API today. No infrastructure required.

Get Started Free