How to grab a single image from RTSP stream using FFMPEG
38,772
Solution 1
Try
ffmpeg -y -i rtsp://admin:[email protected]:554/live -vframes 1 do.jpg
Solution 2
I've been using variations to use my Ubiquiti cameras to give me a Weather Underground JPG.
The tcp transport addition fixed everything. The modified command follows.
E $FFMPEG -y -loglevel fatal -rtsp_transport tcp -i $URL1 -frames:v 2 -r 1 -s 320x240 $TMPFILE
Solution 3
My take on this command, but its not perfect, about 20% of the time I get a corrupted (as in incomplete, or glitchy) image over a bad link:
avconv -rtsp_transport tcp -y -i rtsp://user:[email protected]:554/live -vframes 1 do.jpg
Author by
sealfab
Updated on July 09, 2022Comments
-
sealfab almost 2 years
I have seen several other related questions but they all seem to be related to grabbing a still shot every X number of seconds. How can I grab 1 image when the command is run.
I was trying
ffmpeg -y -i rtsp://admin:[email protected]:554/live -f image2 -updatefirst 1 do.jpg
-
Gyan over 8 yearsWhy the
-f image2 -updatefirst 1
. You only want one output. -
sealfab over 8 yearswhen I run it without I get
[image2 @ 0x2886980] Could not get frame filename number 2 from pattern 'do.jpg' (either set updatefirst or use a pattern like %03d within the filename pattern) av_interleaved_write_frame(): Invalid argument
-
-
user230910 almost 6 yearsi've used this command for a while, but about 20% of the time I get a corrupted frame
-
Gyan almost 6 yearsRTSP, if via UDP, can drop packets. Try TCP.
-
Pathead about 5 yearsFor those wondering, to use TCP with the above command add:
-rtsp_transport tcp
-
ttous over 4 yearsFor those who struggled over this as much as I did, 2 pro tips:
-rtsp_transport tcp
option must be placed before-i ...
option, and-vframes
is an now an obsolete alias for-frames:v
(use the latter instead of the former) -
frakman1 over 3 yearsWhile this works on my Mac, it hangs on windows after listing the library names ending with libpostproc