Script to get JPEG snapshot from RTSP-stream (ffmpeg)
Posted: Monday 25 May 2015 21:11
Edit: Jump directly to working script here.
------------------------------------------------------------------------------------------------------------------------------------------------------------------
I recently bought a EScam QD500 ipcamera.
Unfortunately it only offers a RTSP-stream, and no snapshot URL
I want to use it to make a snapshot when someone rings my doorbell, so i build a little script after Googling for a while on how to do this.
You need ffmpeg (sudo apt-get install ffmpeg) and create the 'snapshots' directory in the 'www' folder (or somewhere else, but the files in 'www' can be accessed from the web).
Copy the contents of the script below, change the camera IP-address to your situation and save the script as 'snapshot.sh'. Then make it executable (chmod +x snapshot.sh)
Only downside is that (for now) i can only get the low-quality stream (stream=1.sdp) to work, the HQ (720p) stream (stream=0.sdp) is too large for the buffer(s) of ffmpeg or so, i receive a lot of errors OR only a completely grey output image is generated.
Another downside (for me personally) is that this only works on Raspberry Pi, when i try to run this on my Synology it almost stops immediately: "RTSP: protocol not found"
Run the script by excecuting
After a few seconds, the snapshot will be saved in the folder you configured in the script.
FFmpeg parameters maybe need adjustment if you use it with a different camera than the QD500.
With the '-s' parameter you can define the size of the image, like '-s 640x480' if you want to stretch it a bit bigger. Put it between the '-r 1' and the imagepath part
------------------------------------------------------------------------------------------------------------------------------------------------------------------
I recently bought a EScam QD500 ipcamera.
Unfortunately it only offers a RTSP-stream, and no snapshot URL

I want to use it to make a snapshot when someone rings my doorbell, so i build a little script after Googling for a while on how to do this.
You need ffmpeg (sudo apt-get install ffmpeg) and create the 'snapshots' directory in the 'www' folder (or somewhere else, but the files in 'www' can be accessed from the web).
Copy the contents of the script below, change the camera IP-address to your situation and save the script as 'snapshot.sh'. Then make it executable (chmod +x snapshot.sh)
Code: Select all
#!/bin/sh
export DATETIME=`date +%Y%m%d%H%M%S`
ffmpeg -loglevel fatal -i rtsp://192.168.4.20//user=admin_password=_channel=1_stream=1.sdp -vframes 1 -r 1 /home/pi/domoticz/www/snapshots/$DATETIME.jpg
Another downside (for me personally) is that this only works on Raspberry Pi, when i try to run this on my Synology it almost stops immediately: "RTSP: protocol not found"
Run the script by excecuting
Code: Select all
bash snapshot.sh
FFmpeg parameters maybe need adjustment if you use it with a different camera than the QD500.
With the '-s' parameter you can define the size of the image, like '-s 640x480' if you want to stretch it a bit bigger. Put it between the '-r 1' and the imagepath part