title: Reading out specific video frame using FFMPEG API
body: <p>I read frames from video stream in FFMPEG using this loop:</p>
  
  <pre><code>while(av_read_frame(pFormatCtx, &amp;packet)&gt;=0) {
          // Is this a packet from the video stream?
          if(packet.stream_index==videoStream) {
              // Decode video frame
              avcodec_decode_video2(pCodecCtx,pFrame,&amp;frameFinished,&amp;packet);
  
              // Did we get a video frame?
              if(frameFinished) {
  
  
                  sws_scale(img_convert_context ,pFrame-&gt;data,pFrame-&gt;linesize,0,
                       pCodecCtx-&gt;height, pFrameRGBA-&gt;data, pFrameRGBA-&gt;linesize);
                  printf("%s\n","Frame read finished ");
  
                                         ExportFrame(pFrameRGBA-&gt;data[0]);
                      break;
                  }
              }
              // Save the frame to disk
  
          }
              printf("%s\n","Read next frame ");
  
          // Free the packet that was allocated by av_read_frame
          av_free_packet(&amp;packet);
      }
  </code></pre>
  
  <p>So in this way the stream is read sequentially.What I want is to have a random access to the frame to be able reading a specific frame (by frame number).How is it done?</p>