I would like to encode a simple pcm to amr using libavcodec.
To begin with, I compiled ffmpeg and run the encode_audio example and it worked fine for the default Mp2 codec.
Then modified the encode_audio example and replace AV_CODEC_ID_MP2 with AV_CODEC_ID_AMR_NB and changed bit_rate, sample_rate, and channel_layout to 12200, 8000, and AV_CH_LAYOUT_MONO respectively. Now, I am getting invalid fastbin entry (free) error.
The compiled ffmpeg cli binary worked as expected and encode audio files to amr successfully, so the issue is not in compilation or the linking step.
Any help would be much appreciated
Update:
As mentioned in the comments, the issue is not specifically for amr and the encode_audio example would fail for all codecs if AV_CH_LAYOUT_MONO is selected for the channel layout. To get the demo to work, you need to also change the signal generator code block, in which having two channels of audio if assumed and hard-corded. Thanks @ronald-s-bultje for helping me here.