[Libav-user] Using sample format AVOption and av_opt_set?

Pero Brbora pero.brbora at gmail.com
Sat Sep 19 18:44:10 EEST 2020


I wasn't able to set audio sample format using av_opt_set functions. It
seems it is not available in libavcodec/options_table.h.

As an example I used encode_audio.c

    av_opt_set_int (c, "ab", 64000, 0);
    av_opt_set_int (c, "ac", av_get_channel_layout_nb_channels
(c->channel_layout), 0);
    av_opt_set_int (c, "ar", select_sample_rate (codec), 0);
    av_opt_set_int (c, "channel_layout", AV_CH_LAYOUT_STEREO, 0);
#if 0
    // error: Specified sample format -1 is invalid or not supported
    av_opt_set_sample_fmt (c, "sample_fmt", AV_SAMPLE_FMT_S16, 0);
    // no error
    c->sample_fmt = AV_SAMPLE_FMT_S16;

Is it possible to set sample format using av_opt_set* functions?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200919/46b00815/attachment.html>

More information about the Libav-user mailing list