title: How to read any frame while having frame number using ffmpeg av_seek_frame()
body: <pre><code>int64_t timeBase;
  timeBase = (int64_t(pavStrm-&gt; time_base.num) * AV_TIME_BASE) / int64_t(pavStrm-&gt;time_base.den);
  int64_t seekTarget = int64_t(iFrameNumber) * timeBase;
  av_seek_frame(fmt_ctx, -1, seekTarget, AVSEEK_FLAG_FRAME);
  </code></pre>
  
  <p>here I want to read next 5 frame after iFrameNumebr</p>
  
  <pre><code>for(int iCnt = 0; iCnt &lt;= 4; iCnt++)
  {
      iRet = av_read_frame(fmt_ctx, &amp;pkt);
          do 
          {
              ret = decode_packet(&amp;got_frame, 0);
              if (ret &lt; 0)
                  break;
              pkt.data += ret;
              pkt.size -= ret;
  
          }while (pkt.size &gt; 0);
      av_free_packet(&amp;pkt);
  }
  
  static int decode_packet(int *got_frame, int cached)
  {
  int ret = 0;
  int decoded = pkt.size;
  *got_frame = 0;
  
  if (pkt.stream_index == video_stream_idx)
  {
      /* decode video frame */
      ret = avcodec_decode_video2(video_dec_ctx, frame, got_frame, &amp;pkt);
  }
  </code></pre>
  
  <p>when i am using AVSEEK_FLAG_BACKWARD its return 5 packet and 5 frame first two is blank but correct.</p>
  
  <p>when i am using AVSEEK_FLAG_FRAME its return 5 packet and 3 frame which are not first 3 frame its return specific frame from video.</p>
  
  <p>for any iFrameNumber</p>
  
  <p>so please help me how to get frame while having frame number and what is exact value of seektarget 3rd param of av_seek_frame()</p>
  
  <p>also I have problem while converting frame to rgb24 format</p>