esp-pixelbox/tools/webcam.sh

27 lines
872 B
Bash
Raw Permalink Normal View History

#!/bin/bash
CURRENTWIFI=$(iwconfig 2>&1 | grep ESSID | grep \" | sed 's/.*:"\(.*\)"/\1/')
if [ ${#CURRENTWIFI} -eq 0 ]; then
echo "You have to be in the CTDO-IoT-WiFi for this to work. You're not connected at all."
exit 0
fi
if [ ${CURRENTWIFI} != "CTDO-IoT" ]; then
echo "You have to be in the CTDO-IoT-WiFi for this to work"
exit 0
fi
PIXELBOXIP=$(mosquitto_sub -h raum.ctdo.de -t 'homie/pixelbox/$localip' -C 1)
echo "Pixelbox should be on ${PIXELBOXIP}, presuming WiFi connection."
ping -c 1 -s 1 -W 1 ${PIXELBOXIP} 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Pixelbox replies, starting webcam."
else
echo "The Pixelbox with IP ${PIXELBOXIP} is unreachable."
exit 0
fi
while true
do
ffmpeg -y -f video4linux2 -i /dev/video0 -vframes 1 -vf scale=8:8 -f image2 - 2>/dev/null | convert - -rotate 90 -normalize rgb:- >/dev/udp/${PIXELBOXIP}/4210
sleep 0.1
done