title: ffmpeg decode h.264 stream latency one frame always
body: <p>Now I use the x264 library to compress the video (from camera) and transmit to client side by TCP. In the client side, use the ffmpeg library to decode the stream on the Win32. But I find the stream decoding always <strong>latency one frame</strong>. That is to say, if the client side received <strong>A,B,C</strong> three frame, when decode the <strong>A</strong> frame, can't get the image. Then decode the <strong>B</strong> frame, get the <strong>A</strong> frame image.</p>
  
  <p>For the h.264 encode, i have set zerolatency - ultrafast - baseline. So I think there is no B frame.</p>
  
  <p>For the ffmpeg decoder, i have tried to set the <strong>thread_type = 0</strong> to disable frame buffering decoding. But no efficient! By the way, after decoded one frame, passing <strong>NULL</strong> to the decoder to flush the decoder can help this case. But i think this is not a good solution.</p>
  
  <p><strong>So how to set the ffmpeg library to avoid the one frame latency?</strong></p>