Search code examples
ffmpeglibavcodec

libavcodec: How do I use AVOptions to set up encoder parameters?


libavcodec seems to have 3 ways to specify parameters for a codec:

  • Certain members of the AVCodecContext struct
  • values in an AVDictionary passed to avcodec_open2
  • AVOptions, which seem to cover everything the other two do

Can I use AVOptions to setup all of the encoding parameters? In addition, can AVOptions provide sensible defaults? Google doesn't yield any results and there's no example provided in the documentation.


Solution

  • Sure. Look at the examples of av_opt_* calls in doc/examples. For defaults, call av_opt_set_defaults