I am trying to decode opus to pcm file using libavcodec.So,I use ffmpeg example from https://ffmpeg.org/doxygen/trunk/decode_audio_8c-example.html .And I change AV_CODEC_ID_MP2 to AV_CODEC_ID_OPUS.But I get an error.
codec = avcodec_find_decoder((AV_CODEC_ID_MP2);
codec = avcodec_find_decoder(AV_CODEC_ID_OPUS);
error:
codec ./decode_audio ./out.opus ./out.pcm
[opus @ 0x7ff361800000] Error parsing Opus packet header.
[opus @ 0x7ff361800000] Error parsing Opus packet header.
[opus @ 0x7ff361800000] Error parsing Opus packet header.
[opus @ 0x7ff361800000] Error parsing Opus packet header.
[opus @ 0x7ff361800000] Error parsing Opus packet header.
[opus @ 0x7ff361800000] Error parsing Opus packet header.
So I try to change opus AV_CODEC_ID_OPUS to AV_CODEC_ID_MP3 and try again.
codec ./decode_audio ./out.mp3 ./out.pcm
[mp3float @ 0x7fe564002000] Header missing
Error submitting the packet to the decoder
Why does the example from ffmpeg get error?What should I do ?