title: aac bitstream error when writing mp4 file
body: <p>My application receives an audio-video stream from an RTSP source and writes it out to an mp4 file using libffmpeg.</p>
  
  <p>I set up the audio output stream to use aac encoding and configured it this way:</p>
  
  <pre><code>            stream-&gt;codec-&gt;sample_fmt = codec-&gt;sample_fmts ? codec-&gt;sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
              stream-&gt;codec-&gt;bit_rate = 64000;
              stream-&gt;codec-&gt;sample_rate = pFormatCtx-&gt;streams[audioStream]-&gt;codec-&gt;sample_rate;
              stream-&gt;codec-&gt;channels = 1;
              stream-&gt;codec-&gt;channel_layout = av_get_default_channel_layout(1);
              stream-&gt;codec-&gt;flags |= CODEC_FLAG_GLOBAL_HEADER;
  </code></pre>
  
  <p>This seems like it should work. However when I run the application I get the error message "aac bitstream error", and the resulting mp4 file plays back without any audio.</p>
  
  <p>I'm at a dead end right now. I don't know how to find out more about what this error means. Does anyone know?</p>