57

When converting an array of JPEGs to a video file (Ogg format) I have been using the -crf option. What are the valid ranges for -crf? Currently I am using 23.

I cannot find the bookmark I read to know what this flag does and I have spent some time Googling around.

These are the arguments I am using at the moment:

-f image2 -r 10 -i " + _sourcePath + @"\img%05d.jpg -crf 18  -y -r 10 " + _destPath + "\\" + _filename + ".ogg"
4
  • 1
    I don't know any thing about this command, but it's very well documented here: ffmpeg.org/ffmpeg.html.
    – Ben Plont
    Nov 18, 2013 at 18:04
  • 1
    Are you using libx264 (for H.264 video) or libvpx (for VP8 video)? Please show your ffmpeg command and the complete console output.
    – llogan
    Nov 18, 2013 at 18:11
  • 1
    So, the question is if you want to keep this question rather general to CRF, or if you have a specific issue you need help with. In the latter case we'd need to get the full commandline output (i.e. everything from "ffmpeg version…" to the last bit) and the actual command you're using, but it'd unfortunately render the existing answers useless. You might want to ask a new question if you're facing a concrete issue.
    – slhck
    Nov 18, 2013 at 19:59
  • 1
    @slhck Hi, you are absolutely right. I do need to learn to be more specific and comprehensive in future. As it was your answer fitted my needs more than everyone else's but everyone else's were also informative. I will tread more carefully in the future :) Thank you for your time. Much appreciated. Nov 19, 2013 at 7:43

2 Answers 2

73

That refers to the Constant Rate Factor (crf).

As others have pointed out (Thanks all), the values will depend on which encoder you're using.

For x264 your valid range is 0-51:

The range of the quantizer scale is 0-51: where 0 is lossless, 23 is default, and 51 is worst possible. A lower value is a higher quality and a subjectively sane range is 18-28. Consider 18 to be visually lossless or nearly so: it should look the same or nearly the same as the input but it isn't technically lossless.

For vpx the range is 4-63 (as @sebastian-hoffner answered):

By default the CRF value can be from 4–63, and 10 is a good starting point. Lower values mean better quality.

In both cases, a lower value means higher quality. In my experience, I see x264 much more often.

Slhck's shameless plug (an SU mod) link looks like it has some good info.

4
  • 1
    Range for VPX is from 0-63 not 4-63, recommended rate is 15-30
    – Suhayb
    Oct 13, 2019 at 22:00
  • This seems to be old. Here are recommended CRF values for different resolution under VP9 from Google: developers.google.com/media/vp9/settings/vod#quality Feb 15, 2021 at 18:41
  • 1
    This is a beautifully constructed, formatted, and emphasized reply. Probably best I've seen in here 👏🏻 .
    – meeDamian
    Dec 12, 2021 at 17:22
  • idk if I would say x264's 18 is even visually lossless, I have 720p (so not insane resolution by any means) videos I concatted using -vcodec libx264 -crf 18 and fine lines and text are easily subjectively seen as smudgy/pixely. Even though this is a technical measure; for reference they were 56 x264 mp4 videos totaling 12GB and the output with 18 was a 33min 2.8GB, so considerable data loss.
    – Hashbrown
    Jul 21 at 23:58
8

The crf flag ensures a variable bitrate for constant quality, if I understand the page linked below correctly. The default range is from 4 to 63, but it can be tweaked further.

Have a look at https://trac.ffmpeg.org/wiki/Encode/VP9 for more information.

2
  • I'm a little confused by this, we both link to the same site and each page says something slightly different (ranges, that is). In any case, both look legitimate to me, so I'm a little boggled by this.
    – nerdwaller
    Nov 18, 2013 at 18:02
  • hi, thanks for that. I am looking to improve the quality of the video stream so a low crf will do it? Nov 18, 2013 at 18:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .