title: ffmpeg jpg frame capture - How to discard corrupted frames
body: <p>I'm using ffmpeg 2.2.2 (Windows) to export a live camera stream into JPG frames.  I'm using the command line:</p>
  
  <pre><code>ffmpeg -err_detect aggressive -i rtsp://[ip address]:554/11 -r 1 -s 640x320 -an -f image2 c:\temp\snapshots\snapshot-%03d.jpg
  </code></pre>
  
  <p>This starts a continuous process which exports approximately 1 frame per second from the live stream.  However, at various times during the export, ffmpeg throws errors like this:</p>
  
  <pre><code>[h264 @ 00037ae0] RTP: missed 2 packets=00:01:09.00 bitrate=N/A dup=0 drop=1186
  [h264 @ 02fbc340] Cannot use next picture in error concealment
  [h264 @ 02fbc340] concealing 4386 DC, 4386 AC, 4386 MV errors in P frame
  [h264 @ 00037ae0] RTP: missed 13 packets
  [h264 @ 02fbf7a0] left block unavailable for requested intra mode at 0 15p=1196
  [h264 @ 02fbf7a0] error while decoding MB 0 15, bytestream 128288
  [h264 @ 02fbf7a0] concealing 6409 DC, 6409 AC, 6409 MV errors in I frame
  </code></pre>
  
  <p>However, it proceeds to create a jpg file that is corrupted.  For example, the top of the file is fine, but then the same pixels smear down the rest of the image. Here's an example:
  <a href="https://i.stack.imgur.com/gExJF.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/gExJF.jpg" alt="enter image description here"></a></p>
  
  <p>How can I force ffmpeg to either 1) discard these corrupt images after saving, or 2) simply "don't write" the image to a file after an error like this occurs?</p>
  
  <p>I thought the err_detect flag may help, but it seems to make no difference.</p>