title: Problem with ffmpeg function avformat_seek_file()
body: <p>I am trying to seek the given frame in the video using ffmpeg library. I knew that there is <code>av_seek_frame()</code> function but it was recommended to use <code>avformat_seek_file()</code>instead. Something similar mentioned <a href="https://stackoverflow.com/questions/5261658/how-to-seek-in-ffmpeg-c-c">here</a>.</p>
  
  <p>I know that <code>avformat_seek_file()</code> can't always take you to exact frame you want, but this is ok for me. I just want to jump to the nearest keyframe. So i open the video, find videostream and calling it like this:</p>
  
  <pre><code>avformat_seek_file( formatContext, streamId, 0, frameNumber, frameNumber, AVSEEK_FLAG_FRAME )
  </code></pre>
  
  <p>It always returns 0, so i understand it as correct finish. However, it doesn't work as it should to. I check byte position like <a href="https://stackoverflow.com/questions/3032929/problem-ffmpeg-seeking-with-av-seek-frame-using-byte-positions">here</a> before and after calling <code>avformat_seek_file()</code>. Actually it changes, but it changes always in the same way whenever i'm trying to put different target frame numbers! I mean that byteposition after this call is always same even with different <code>frameNumber</code> values. Obviously, i'm doing something wrong but i don't know what exactly. I don't know if it does matter but i'm using .h264 files for that. I tried different flags, different files, using timestamps instead of frames, flushing buffers before and after and so on but it doesn't work for me. I will be very grateful if someone could show me what is wrong with it.</p>