-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
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset medium \
-c:a aac -b:a 96k -movflags +faststart small.mp4CRF 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
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 hvc1keeps 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.mp4Scale 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.mp4Use a slower preset
-preset slowsearches 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 thanmedium.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
| Flag | What it does | Used here |
|---|---|---|
-crf 28 | Quality target; higher means smaller and softer. libx264 defaults to 23 | Every encode |
-c:v libx265 | Encodes HEVC; its CRF scale is its own, with 28 as the default | x265 |
-tag:v hvc1 | Writes the hvc1 tag that Apple players look for in an HEVC MP4 | x265 |
-vf scale=720:-2 | Scales to 720 pixels wide; -2 keeps the shape with an even height | 720 wide |
-preset slow | Spends more time looking for a smaller file at the same quality | Slow preset |
-c:a aac -b:a 96k | Re-encodes the audio to AAC at 96 kbit/s | Every encode |
-movflags +faststart | Moves the index to the front so playback starts before the download ends | Every 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.
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"]
}'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.
- Choose a CRF value in ffmpegWhat CRF does in libx264, the file size and VMAF score for CRF 18, 23, 28 and 33 on one clip, and how x265's scale differs.
- Set the video bitrate with ffmpegSet an average bitrate with -b:v, cap it with -maxrate and -bufsize, or run two passes to land on a file size, with measured results.
- Encode H.265 (HEVC) with ffmpegEncode HEVC with libx265: CRF 28 against x264 CRF 23 on one clip, the hvc1 tag Apple players need, and 10-bit output.
- Encode AV1 with ffmpegEncode AV1 with SVT-AV1 or libaom: presets 4, 8 and 12 against libaom and x264 on one clip, with file size, VMAF and time.
- Resize a video with ffmpegScale a video with scale=w:h: keep the aspect ratio with -2, fit a 1080x1920 frame with pad, and fix the odd-size error.
- Add faststart to an MP4 with ffmpegMove the moov atom to the front of an MP4 with -movflags +faststart so it plays before the download ends, and check where it sits.
- Video compressionCompress a video to a size budget in one ffmpeg call: a 129 MB 1080p clip fits a 5 MB target at 4.6 MB, for under 1 cent.
Sources, checked November 2026
Ready to build?
Ship video from your app today
Your first $0.50 is free, and one key covers every endpoint.
