Tool

FFmpeg Command Builder

Pick a codec and a quality target and get an FFmpeg command you can copy and run right away. Everything happens in your browser; no files or input values are uploaded.

1. Codec

Plays everywhere. File size tends to be the largest of the three.

2. Quality target (VMAF)

VMAF is a 0–100 score of how close the encode looks to the original. Higher means closer to the original, and a larger file. The CRF for this target is read from our measurements.

Current value 23 · source: FFmpeg default (data loading). A lower CRF means higher quality and a larger file. Range: 0–51.

CRF that reaches VMAF 90 in our measurements (H.264 (x264))

Loading…

More options

A slower preset gives a smaller file at the same CRF, at the cost of longer encoding time. When you pick a resolution, the width is calculated automatically to keep the aspect ratio (scale=-2:height).

Names with spaces or non-ASCII characters are wrapped in double quotes automatically.

FFmpeg command

ffmpeg -i input.mp4 -c:v libx264 -preset medium -crf 23 -pix_fmt yuv420p -c:a aac -b:a 128k -movflags +faststart output.mp4
  • -c:v libx264 — Selects the video codec (encoder).
  • -preset medium — Balances encoding speed against compression efficiency.
  • -crf 23 — The quality setting. File size depends on the video content.
  • -pix_fmt yuv420p — Sets the 8-bit 4:2:0 format that most devices can play.

Where does the recommended CRF come from?

In our CRF size-vs-quality measurements, four 1080p25 clips were encoded with x264, x265 and SVT-AV1 at six CRF levels each, and VMAF was measured. This tool connects those measured points with straight lines and reads off, for each clip, the CRF that matches the VMAF target you pick. Because the values differ quite a bit from clip to clip, the recommendation is the most demanding readable clip’s value (the lowest CRF), rounded down to an integer. That means an easy video can come out at higher quality than the target, and the file can be larger than it needs to be.

How to use it

  • If compatibility comes first, choose H.264. If you are not sure the recipient can play HEVC or AV1, check first with the Codec Support Checker.
  • If you cannot decide on a quality target, start at 90 and look at the result. If it falls short, lower the CRF by 2–3 or raise the target and run it again.
  • If you have a file size limit, note that CRF cannot set the file size directly. In that case the Video File Size & Bitrate Calculator is the right tool.
  • Slower presets shrink the file at the same CRF but take longer. One approach is to settle on a CRF with a fast preset and run only the final encode with a slow one.
  • Running the command: open a terminal, move to the folder with your video and paste it in. If the output file already exists, FFmpeg asks whether to overwrite it.

Limitations worth knowing

  • The measurements are four 10-second 1080p25 8-bit clips on a single PC. If your video is different, the same CRF can give a different VMAF.
  • The recommendations were measured with the medium preset (6 for SVT-AV1). Changing the preset changes the quality and file size at the same CRF, and this tool does not estimate that difference.
  • We did not measure the effect of changing resolution or frame rate. For video that is not 1080p, use the recommendation only as a starting point.
  • VMAF is only a score that imitates the human eye, and it does not match the viewing experience on every video.
  • The generated command is the basic form for converting a single video. Subtitles, multiple audio tracks, HDR and 10-bit are not covered. Your FFmpeg build must include the chosen encoder; otherwise you will get an Unknown encoder error.

Learn more

What CRF is and why codecs shrink files are covered in the course, and comparisons between codecs are in the lab article.