title: ffmpeg - how can I capture the timestamp of a screenshot using a seek and finding the nearest iframe?
body: <p>I've tried various different methods. ffprobe has always shown sensical results, with the pts_time increasing as the frames go on, using this command:</p>
  
  <pre><code>ffprobe -show_frames video.mp4 &gt; probestats.txt
  </code></pre>
  
  <p>I thought about using that data to find the video frame nearest to the seconds I'm seeking to in ffmpeg, but I am trying to keep this performant, as I'm generating thumbnails on uploads that could exceed 5GB, which means I would end up with 50MB+ probe files to parse.</p>
  
  <p>So, currently, I'm looping over this ffmpeg command, so as to end up with 10 thumbnails total per file, regardless of length: </p>
  
  <pre><code>ffmpeg -i video.mp4 -ss 00:00:05 -vf select="eq(pict_type\\,I)[s1];[s1]showinfo[out]" -vframes 1 -q:v 1 thumbs/thumb-1.jpg 2&gt;&amp;1
  </code></pre>
  
  <p>The aim is to get the nearest iframe of the seconds I'm seeking to, e.g. find the nearest iframe near the 5 second mark and take a thumbnail -- which gives some increased performance.</p>
  
  <p>The issue is, ffmpeg is outputting seemingly random pts_time's, definitely not correct compared to the pkt_pts_time shown in ffprobe.</p>
  
  <p>So as the title states, I'm looking for an ffmpeg command to generate a thumbnail at the nearest iframe to a specified seek, and get the timestamp.</p>