title: How to flush buffer data to disk when using FFmpeg to write a mp4 file?
body: <p>I am using FFmpeg to write a mp4 file, I grab bitmap images from remote IP camera and encode it by h.264, the media container is mp4 file, no problem to generate the MP4 file if I only record several minutes, the problem is FFmpeg never flushs buffer data to disk when I call method <code>av_interleaved_write_frame</code>(all encoded data in memory, never free them), only when I call method <code>avio_close(oc-&gt;pb);</code>, it will flush all encoded data to disk, I tried to call method <code>avcodec_flush_buffers</code> every time after calling <code>av_interleaved_write_frame</code>, but no effect. I am newbie to FFmpeg, if you are familiar with FFmpeg, please help me.</p>
  
  <p>thanks in advance.</p>
  
  <p>Sean</p>