Created
July 29, 2011 18:35
-
-
Save sheffler/1114426 to your computer and use it in GitHub Desktop.
Webcam upload to Sensr using periodic FTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Example FTP upload to Sensr from /dev/video0 | |
# (uses ffmpeg to grab frames from webcam) | |
# Sensr FTP information | |
HOST=f7.sensr.net | |
USER=cam28 | |
PASS=l4hqpy0ywm | |
echo Starting FtpCam ${HOST} ${USER} ${PASS} | |
# Exit by hitting ^C | |
trap 'echo EXIT FTPCAM; exit 0' SIGINT SIGTERM | |
# Set image size | |
W=640 | |
H=480 | |
# Specify the video input dvice | |
DEV=/dev/video0 | |
# Set size, framerate of camera | |
dov4l -d ${DEV} -s ${W},${H} | |
dov4l -d ${DEV} -f 25 | |
for (( ; ; )) | |
do | |
# Get two frames. First frame is usually dirty. | |
ffmpeg -f video4linux2 -s ${W}x${H} -y -r 2 -t 4 -i ${DEV} -f image2 -vcodec mjpeg "image%02d.jpg" | |
if [ -f image02.jpg ]; then | |
# Upload to Sensr via FTP method | |
ftp -d -v -n ${HOST} <<EOF | |
quote user ${USER} | |
quote pass ${PASS} | |
passive | |
binary | |
put image02.jpg | |
quit | |
EOF | |
rm image*.jpg | |
else | |
sleep 5 | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment