ffmpeg - Constant Quality and Presets

This post will show how to control the quality of your output file and the encoding time when using libx264 or libx265. This will only give a summary of using constant quality / constant rate factor mode. For more information, see this ffmpeg wiki article on H.264 Video Encoding

Constant Rate Factor (CRF)

If you only care about achieving the best compression rate at some target quality, and do not care about the file size, then constant quality / constant rate factor (CRF) mode is a great mode to use. CRF is controlled using the -crf option. The range for 8-bit libx264 is 0-51, where lower is better quality, but a sensible range is 17–28, and the default value is 23. By default, libx264 will use CRF mode.

ffmpeg -i in.mkv -vcodec libx264 -acodec copy out.mkv

Note that we added -acodec copy to the command. Without it, ffmpeg reencode the audio part using the default audio encoder. To change the default CRF value, use the following command:

ffmpeg -i in.mkv -vcodec libx264 -crf 23 -acodec copy out.mkv
Read more  ↩︎

ffmpeg - Transcoding Basics

This post on ffmpeg will focus on one of the basic use cases of ffmpeg: transcoding videos. The commands given in this post are the minimum command line arguments needed to transcode a video. For controlling encoding equality and encoding time, see my post on constant quality and presets

Read more  ↩︎