webcam-stream.sh - brcon2024-hackathons - Bitreichcon 2024 Hackathons | |
git clone git://bitreich.org/brcon2024-hackathons git://enlrupgkhuxnvlhsf6lc3fz… | |
Log | |
Files | |
Refs | |
Tags | |
Submodules | |
--- | |
webcam-stream.sh (602B) | |
--- | |
1 #!/bin/sh | |
2 # stream your face to a MQTT topic | |
3 # requirements: | |
4 # ffmpeg | |
5 # imcat: https://github.com/stolk/imcat | |
6 # mosquitto_pub: https://github.com/eclipse/mosquitto | |
7 uri="${MQTT_URI:-mqtts://bitreich:oogui3queex&[email protected]/}" | |
8 topic="${MQTT_TOPIC:-faces/$USER}" | |
9 sleep="${CAM_INTERVAL:-10}" | |
10 device="${1:-video0}" | |
11 f="$(mktemp).jpg" | |
12 while : | |
13 do | |
14 ffmpeg -y -f v4l2 -video_size 1280x720 -i "/dev/${device}" \ | |
15 -qscale:v 2 -vframes 2 -r 0.2 -update 1 "$f" \ | |
16 -loglevel 0 </dev/null | |
17 if ! msg="$(echo; imcat "$f")" | |
18 then | |
19 exit 2 | |
20 fi | |
21 mosquitto_pub -L "${uri}${topic}" -m "$msg" | |
22 sleep "$sleep" | |
23 done |