

> On Apr 9, 2015, at 1:10 AM, Max Vlasov wrote: But still, it would be nice to know how to do this… It certainly seems like one ought to be able to just force a particular bitrate, but I still don’t know how to do this.Īs a practical matter, forcing a particular bitrate may be a non-issue, as dialing in the right “crf” or “qp” value can yield a range of quality levels. And, as I’ve stated before, setting the bitrate with the “obvious” encoder API has no effect. So, for both “crf” and “qp”, I can tune the quality by using different values, but the resulting bitrate is determined algorithmically by the encoder.Īccording to ffmpeg command-line documentation, I should be able to explicitly set the bitrate with the equivalent to the “-b” option or similar, but I’m not able to find this in the AVOptions structure in libx264.c. Some forum posts suggest “crf” is a better approach, as it’s adaptive and generally results in smaller files for the same quality results I found this to be accurate. Again with smaller values, the quality can be drastically improved. A “1” value gives me more sampling than I need I’ve not played with the value to determine what would be optimal. A “0” value is lossless, but not all profiles support this. Using smaller values increases quality via increasing the bitrate (and other things?).


To avoid repeating what’s in a lot of forum posts, I’ll just note that “crf” defaults to 23, which seems not to be adequate for my purposes (very large images with high-frequency content, used as still images to be encoded). Notably, “crf” causes variable bitrate, and “qp” causes a constant bitrate. Of particular importance for controlling quality are the “crf” (Constant Rate Factor) or “qp” (Quantization Parameter) options, which are named as they are in the command-line ffmpeg (and thus referenced in numerous posts/forums).

Eventually, I looked at the source for FFmpeg’s libx264.c ( ), and found that there’s a rather large set of parameters/controls/options for x264 that are not part of the general encoder API:ħ54 static const AVOption options = ,Īv_opt_set(c->priv_data, "crf", "1", AV_OPT_SEARCH_CHILDREN) The problem was that I was not aware of the mapping between ffmpeg command-line parameters and the API. So I was convinced my goal is achievable. There’s a *lot* of info on command-line ffmpeg usage, with details on controlling quality for x264 encoding. I’m posting what I’ve learned so far, so that perhaps this will help others, or allow others to provide some more useful feedback. Good suggestion.I’ll try to create a minimal implementation to post.īut now my questions may be a bit more educated.
