-c:v libx264 -crf 28 shrank a 13.6 MB video to 6.3 MB at a VMAF near 95, and libx265 got it to 4.4 MB. ReelSDK's free compressor does it in your browser; from code, the API runs it for $0.02 per compute minute, under three quarters of a cent here.

Compress a video with ffmpeg

Three levers make a file smaller, and ReelSDK's API takes each as plain ffmpeg args: CRF 28 instead of 23, a newer codec like x265, or fewer pixels; a 720p copy came out at about a quarter of the size.

GuidesUpdated

x264
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset medium \
  -c:a aac -b:a 96k -movflags +faststart small.mp4

CRF 28 is five steps above the libx264 default of 23. It more than halved a 13.6 MB clip to 6.3 MB, and the result still looks close to the original. The audio becomes AAC at 96k.

Variations

The other commands you will need

  1. Switch to libx265

    Same number, different scale: x265 at CRF 28 made a file 68% smaller than the input that scored a little above x264, but it took 1.7 times as long to encode. -tag:v hvc1 keeps the file playable on Apple devices.

    x265
    ffmpeg -i input.mp4 -c:v libx265 -crf 28 -tag:v hvc1 \
      -c:a aac -b:a 96k -movflags +faststart small-hevc.mp4
  2. Scale down to 720 pixels wide

    Fewer pixels need fewer bits. At 720x1280 the file came out 76% smaller in about half the encode time, but scaled back up to full size it scored a VMAF of about 86, a clear step down.

    720 wide
    ffmpeg -i input.mp4 -vf scale=720:-2 -c:v libx264 -crf 28 \
      -c:a aac -b:a 96k -movflags +faststart small-720.mp4
  3. Use a slower preset

    -preset slow searches harder at the same CRF. Here it saved under 1% and nudged the VMAF up by a fraction of a point, but the encode took almost a third longer than medium.

    slow preset
    ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset slow \
      -c:a aac -b:a 96k -movflags +faststart small-slow.mp4

The flags

The flags in these commands

The flags in these commands
FlagWhat it doesUsed here
-crf 28Quality target; higher means smaller and softer. libx264 defaults to 23Every encode
-c:v libx265Encodes HEVC; its CRF scale is its own, with 28 as the defaultx265
-tag:v hvc1Writes the hvc1 tag that Apple players look for in an HEVC MP4x265
-vf scale=720:-2Scales to 720 pixels wide; -2 keeps the shape with an even height720 wide
-preset slowSpends more time looking for a smaller file at the same qualitySlow preset
-c:a aac -b:a 96kRe-encodes the audio to AAC at 96 kbit/sEvery encode
-movflags +faststartMoves the index to the front so playback starts before the download endsEvery encode

Sources: FFmpeg H.264 encoding guide, FFmpeg H.265 encoding guide, checked November 2026.

What we measured

The input is a 13.6 MB, 1080x1920 phone video. Each command re-encoded it once, and libvmaf scored the result against the original with its default model, so the score shows what the compression cost.

libx264 at CRF 28 more than halved the file and kept a VMAF of about 95, and the slow preset landed within 1% of it. libx265 matched that quality in a file two thirds smaller than the input. The 720p copy was the smallest, because it drops more than half the pixels.

Which lever to pull

Start with CRF. It is one flag, it keeps the frame size, and it moves the size a long way: the FFmpeg H.264 guide puts +6 at roughly half the bitrate. Look at the result before you push past 28; see choose a CRF value for scores from 18 to 33.

Switch codecs when the players you care about decode HEVC, and when encode time is cheap next to storage or bandwidth. Scale down when the video will only ever be watched small. A slower preset is the weakest lever here: under 1% for a lot more time.

When the file has to fit a size

CRF fixes quality, not size, so the output size depends on the video. When a platform caps the file, set a bitrate instead, or run two passes: aimed at 8 MB, our two-pass encode landed less than 2% over. See set the video bitrate with ffmpeg.

Without installing ffmpeg

The same command as one API call

Send the same args to POST /v1/ffmpeg with the video's URL in inputs. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second; this one finished about 19 seconds after the request and cost under three quarters of a cent.

terminalTry it
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
  -H "Authorization: Bearer $REELSDK_KEY" \
  --json '{
    "inputs": {
      "input.mp4": "https://api.reelsdk.com/f/lib/out/job_x5wepdaqkop4tepq05xp/video.mp4"
    },
    "args": [
      "-i", "input.mp4", "-c:v", "libx264", "-crf", "28", "-preset",
      "medium", "-c:a", "aac", "-b:a", "96k", "-movflags", "+faststart",
      "small.mp4"
    ],
    "outputs": ["small.mp4"]
  }'
small.mp4 from the API: libx264 at CRF 28, 6.3 MB for the full 28 seconds.Input: video.mp4

FAQ

Questions, answered

How do I compress a video with ffmpeg?

Re-encode it at a higher CRF: ffmpeg -i input.mp4 -c:v libx264 -crf 28 -c:a aac -b:a 96k small.mp4. That more than halved a 13.6 MB phone clip and kept a VMAF of about 95 against the original.

Does H.265 compress better than H.264?

Yes, at the cost of encode time. At CRF 28, libx265 made a file almost a third smaller than libx264 did, at a slightly higher VMAF, and took 1.7 times as long.

Is a slower preset worth it?

Rarely for size alone. At CRF 28, -preset slow saved under 1% and barely moved the VMAF, while the encode took almost a third longer.

How do I compress a video to a specific file size?

Work out the bitrate from the size and the duration, then run two passes with -b:v. Aimed at 8 MB, our two-pass encode landed less than 2% over.

Can I compress videos with an API?

Yes. Send the same args to POST https://api.reelsdk.com/v1/ffmpeg with the video's URL in inputs. It runs ffmpeg 8.1 on a fresh machine per job for $0.02 per compute minute, billed per second, and failed jobs are free.

Ready to build?

Ship video from your app today

Your first $0.50 is free, and one key covers every endpoint.

Moonlit lake with a lit cabin under the mountains