title: How do I decode opus file to pcm file using libavcodec from ffmpeg?
body: <p>I am trying to decode opus to pcm file using libavcodec.So,I use ffmpeg example from <a href="https://ffmpeg.org/doxygen/trunk/decode_audio_8c-example.html" rel="nofollow noreferrer">https://ffmpeg.org/doxygen/trunk/decode_audio_8c-example.html</a> .And I change AV_CODEC_ID_MP2 to AV_CODEC_ID_OPUS.But I get an error.</p>
  
  <pre><code>codec = avcodec_find_decoder((AV_CODEC_ID_MP2);
  codec = avcodec_find_decoder(AV_CODEC_ID_OPUS);
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>    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.
  </code></pre>
  
  <p>So I try to change opus AV_CODEC_ID_OPUS to AV_CODEC_ID_MP3 and try again.</p>
  
  <pre><code>    codec ./decode_audio ./out.mp3 ./out.pcm            
      [mp3float @ 0x7fe564002000] Header missing
      Error submitting the packet to the decoder
  </code></pre>
  
  <p>Why does the example from ffmpeg get error?What should I do ?</p>