Search code examples
pythonstreamingrtsp

Record Frame of IP-Cam with Python


I'm trying very hard to safe a frame of a ip-cam. The cam streams in (h264 mp4 avc - says vlc) and supports rtsp and onvif. So i can see the stream in vlc.

I want to record the frame on a headless raspberry pi.

I can receive the rpt frames with this python script: https://code.google.com/p/python-mjpeg-over-rtsp-client/downloads/detail?name=rtsp_mjpeg_client-0.1.zip&can=2&q= But since my cam is not streaming mjpeg i can't use his jpeg-creation.

I tried several other solutions

  • headless selenium (to slow)
  • live555 (do not get it to run)
  • opencv (does not record a stream ?)

Do you have any other suggestion ?


Solution

  • I made it with ffmpeg and some shell scripts. FFmpeg is able to read the stream and create an jpeg for every frame in one line of Code:

    ffmpeg -i rtsp://$user:$pw@$ip:554 -f image2 -vf fps=3 $name_%03d.jpg -loglevel quiet
    

    This limits the stream to 3Fps, which is enough for me.