Resize a video
Scaling changes every pixel, so the video must be re-encoded: there is no lossless resize. This command scales to a target width, computes an even height automatically, and re-encodes with x264 at a quality target. Audio passes through untouched.
Target width
720p-class. The workhorse size for embedded web video. The default.
Height is derived from the aspect ratio. Downscaling keeps quality; upscaling never adds detail; it only makes the file bigger.
Scaling algorithm
FFmpeg’s default: a good all-rounder, so it is omitted from the command.
How new pixel values are computed from old ones. The differences are subtle but real, especially on large downscales.
Quality (CRF)
CRF 20: high-quality delivery. Artifacts are very hard to spot.
x264’s Constant Rate Factor, on its 0–51 scale. 18–23 is the useful range for delivery; each step of ±6 roughly halves or doubles file size.
x264 preset
The x264 default and a sane one.
Presets trade encode time for compression efficiency at the same CRF. Slower presets produce smaller files with identical quality targets.
Your command
updates live · ffmpeg 8.x
ffmpeg -i input.mp4 \
-vf scale=1280:-2 -c:v libx264 \
-crf 20 -preset medium \
-c:a copy \
output.mp4Worth knowing
The -2 in scale=WIDTH:-2 keeps the aspect ratio while forcing the height to an even number: H.264 with 4:2:0 chroma subsampling requires even dimensions.
-c:a copy passes the audio stream through bit-for-bit: no quality loss, no re-encode time.
If the source is portrait, WIDTH applies to the horizontal axis as-is; swap in scale=-2:HEIGHT to target height instead.
Run this on your own file
no FFmpeg · runs in this tab
The command above needs FFmpeg on a machine. The settings it encodes do not: your browser can perform the same operation on a real file, right here, through WebCodecs.
Drop a video or audio file here, or
Files are processed in this tab and never uploaded.
WebCodecs has no CRF, so -crf 20 becomes a bitrate target for the output resolution, using the rule that every 6 CRF steps halve or double the size.
x264 presets are not exposed through WebCodecs; your encoder picks its own speed trade-off.
Audio passes through untouched when the container allows it, matching -c:a copy.
Waiting on a file.