deepch / RTSPtoWeb

RTSP Stream to WebBrowser
MIT License
1.33k stars 313 forks source link

Feature Request - snapshot/grab image #85

Open t3therdev opened 2 years ago

t3therdev commented 2 years ago

Hi, is there a way in the current web/api or can be added the ability to snapshot (grab current frame) of the video player instance?

deepch commented 2 years ago

you can use canvas and js

vdalex25 commented 2 years ago

add two function to index.js 916383feec2247fb20f75212d7018f2470e5b8a4 when player is playing for download snapshot

downloadBase64Image(getImageBase64(document.getElementById('videoPlayer')))

for use as image

const img = new Image();
img.src = getImageBase64(document.getElementById('videoPlayer'));
document.body.appendChild(img)
t3therdev commented 2 years ago

can we add a button on the web interface to call this function and save the jpg?

gabrielklein commented 2 years ago

I have the following script that take the image directly from the camera.

I have the following cron that run each minutes. * * * * * /home/cam/getImage12345.sh >> /tmp/getImage7.log

You need to know the snap url of your camera.

File: getImage12345.sh

cam=cam12345
url="http://IPOFTHECAM/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=abc123&user=SOMEUSER&password=SOMEPASSWORD"

# ---------------------------

now=`date +%Y%m%d-%H%M`
nowd=`date +%Y%m%d`
nowm=`date +%Y%m`

path=/home/cam/site/${cam}
pathn=$path/${nowm}/${nowd}
paths=$path/small/${nowm}/${nowd}
filen=${pathn}/${now}.jpg
files=${paths}/${now}.jpg
filel=$path.latest.jpg

filetmp=${path}.temp.jpg

mkdir -p "${pathn}"
mkdir -p "${paths}"

rm -rf "${filetmp}"
wget "${url}" -q -O ${filetmp}

cp "${filetmp}" "$filen"
convert -sample 100x60 -quality 40 "${filetmp}" "${files}"
rm -rf "${filel}"
mv "${filetmp}" "${filel}"
Kitof commented 8 months ago

it would be great to have the ability to make a snapshot from the API for webcams that don't have the functionality.