Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg jpg frame capture - How to discard corrupted frames

I'm using ffmpeg 2.2.2 (Windows) to export a live camera stream into JPG frames. I'm using the command line:

ffmpeg -err_detect aggressive -i rtsp://[ip address]:554/11 -r 1 -s 640x320 -an -f image2 c:\temp\snapshots\snapshot-%03d.jpg

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:

[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

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: enter image description here

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?

I thought the err_detect flag may help, but it seems to make no difference.

like image 519
Ryan Griggs Avatar asked Aug 31 '17 14:08

Ryan Griggs


1 Answers

You can try the discardcorrupt flag on the input. The full command-line would be:

ffmpeg -err_detect aggressive -fflags discardcorrupt -i rtsp://[ip address]:554/11 -r 1 -s 640x320 -an -f image2 c:\temp\snapshots\snapshot-%03d.jpg
like image 72
Daniel Coelho Avatar answered Oct 18 '22 00:10

Daniel Coelho