[Libav-user] How to transcode without usage of av_opt_set_sample_fmt function

Robert Smith wmk587 at yahoo.com
Sun Nov 7 04:35:05 EET 2021


I need to write C++ function to transcode any mp3 file to G.711 encoded wav file using LibAV API. Since we run on custom ARM board, I can use only specific available cross compiled version of LibAV libraries (pretty old, not the latest one) and there is no way to use latest LibAV library.

As part of transcoding I need to perform resampling using swr_convert.To prepare swr context I need to setup input and output parameters including sample format, e.g.:
    av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt",  pMp3CodecCtx->sample_fmt, 0);    av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", pG711CodecCtx->sample_fmt,  0);
The problem is that in my old version LibAV library there is NO method av_opt_set_sample_fmt defined.
If I skip setting setting sample format option the swr_init display warning

[SWR @ 0x2c7b950] Requested sample format (null) is not supported internally, only float & S16 is supported
and eventually swr_convert fails on assertion:
Assertion a->planar failed at libswresample/swresample.c:284

Could you advise how to resolve this issue? Thanks


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20211107/3808d3d7/attachment.htm>


More information about the Libav-user mailing list