title: Why does av_write_trailer fails?
body: <p>I am processing a video file.
  I use ffmpeg to read each packet.</p>
  
  <p>If it is an audio packet, I write the packet into the output video file using  av_interleaved_write_frame.</p>
  
  <p>If it is a video packet, I decode the packet, get the data of the video frame, process the image, and compress back to a packet. Then I write the processed video frame packet into the output video file using av_interleaved_write_frame.</p>
  
  <p>Through debugging, it read audio packets and video packets correctly.
  However, when it goes to "av_write_trailer", it exits. But the output video file exists.</p>
  
  <p>The error information is:</p>
  
  <pre><code>*** glibc detected *** /OpenCV_videoFlatten_20130507/Debug/OpenCV_videoFlatten_20130507: corrupted double-linked list: 0x000000000348dfa0 ***
  </code></pre>
  
  <p>Using Movie Player (in Ubuntu), the output video file can plays the audio correctly, but without video signals.
  Using VLC player, it can show the first video frame (keep the same video picture), and play the audio correctly.</p>
  
  <p>I tried to debug into "av_write_trailer", but since it is in the ffmpeg library, I could not get a detailed information what is wrong.</p>
  
  <p>Another piece of information: the previous version of the project is only to process the video frame, without adding audio stream; and it works well.</p>
  
  <p>Any hint or clue?</p>