Translating ffmpeg command line to C++ codec settings

前端 未结 1 656
攒了一身酷
攒了一身酷 2021-01-21 09:07

I\'ve been doing some work in ffmpeg for a while in C++. Most of the help regarding encoder settings is explained as command line options. For example (taken from the ffmpeg sit

相关标签:
1条回答
  • 2021-01-21 09:19

    You're doing it wrong™

    av_opt_set (and friends) take an object of type AVClass (proof). Don't touch priv_data.

    You should notice that AVCodecContext is an AVClass because it's first member is an AVClass (which is more or less how "inheritance" (to abuse the term) works in C).

    In short, what you should be doing is:

    AVCodecContext* c;
    av_opt_set_int(c, "cmp", 2, 0);
    

    If you want to know what options a particular class can take, just look at the source. For example, the libopenjpeg encoder takes many options. Other classes in avcodec/avformat define the options they take in a very similar way. These options are dumped out when you do ffmpeg's long help, but sometimes going to the source can shed some light on things.

    Also, for future reference, and to help you, you might want to read this for how options that don't take parameters are set.

    0 讨论(0)
提交回复
热议问题