title: ffmpeg c/c++ get frame count or timestamp and fps
body: <p>I am using ffmpeg to decode a video file in C.  I am struggling to get either the count of the current frame I am decoding or the timestamp of the frame.  I have read numerous posts that show how to calculate an estimated frame no based on the fps and frame timestamp, however I am not able to get either of those.</p>
  
  <p>What I need:  fps of video file, timestamp of current frame or frame no(not calculated)</p>
  
  <p>What I have:  I am able to get the time of the video using </p>
  
  <pre><code>pFormatCtx-&gt;duration/AV_TIME_BASE
  </code></pre>
  
  <p>I am counting the frames currently as I process them, and getting a current frame count, this is not going to work longterm though.  I can get the total frame count for the file using</p>
  
  <pre><code>pFormatCtx-&gt;streams[currentStream-&gt;videoStream]-&gt;nb_frames
  </code></pre>
  
  <p>I have read this may not work for all streams, although it has worked for every stream I have tried.</p>
  
  <p>I have tried using the time_base.num and time_base.den values and packet.pts, but I can't make any sense of the values that I am getting from those, so I may just need to understand better what those values are.</p>
  
  <p>Does anyone know of resources that show examples on how to get this values?</p>