[Libav-user] decoding/encoding example passes c->priv_data to av_opt_set; shouldn't it just pass c?

Michael Bradshaw mjbshaw at gmail.com
Thu Dec 11 06:17:27 CET 2014

In the encoding/decoding example[1], in the video_encode_example()
function, av_opt_set() is used to set the option "preset" to "slow" (here,
c is a AVCodecContext*):

    av_opt_set(c->priv_data, "preset", "slow", 0);

I have come across a few people repeating this, all stating that the
options aren't being set correctly.

After I suggest passing the AVCodecContext* instead of the priv_data
member, like so:

    av_opt_set(c, "preset", "slow", 0);

they report that the options are correctly set.

The ffmpeg source itself (ffmpeg.c) seems to use the codec context, not the
priv_data member; for example:

   av_opt_set_int(ist->dec_ctx, "refcounted_frames", 1, 0);

Is the encoding/decoding example flawed? Should it be passing c instead of
c->priv_data to av_opt_set()?


Michael Bradshaw

[1]: https://www.ffmpeg.org/doxygen/trunk/decoding_encoding_8c-example.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20141210/fb5a13a0/attachment.html>

More information about the Libav-user mailing list