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
Share:
38,772
sealfab
Author by

sealfab

Updated on July 09, 2022

Comments

  • sealfab
    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
      Gyan over 8 years
      Why the -f image2 -updatefirst 1. You only want one output.
    • sealfab
      sealfab over 8 years
      when 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
    user230910 almost 6 years
    i've used this command for a while, but about 20% of the time I get a corrupted frame
  • Gyan
    Gyan almost 6 years
    RTSP, if via UDP, can drop packets. Try TCP.
  • Pathead
    Pathead about 5 years
    For those wondering, to use TCP with the above command add: -rtsp_transport tcp
  • ttous
    ttous over 4 years
    For 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
    frakman1 over 3 years
    While this works on my Mac, it hangs on windows after listing the library names ending with libpostproc