webcam-stream.sh: add MQTT streaming of webcam - brcon2024-hackathons - Bitreichcon 2024 Hackathons HTML git clone git://bitreich.org/brcon2024-hackathons git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/brcon2024-hackathons DIR Log DIR Files DIR Refs DIR Tags DIR Submodules --- DIR commit 335b1e03150eb03337a5268bd899689277c51923 DIR parent 4cdf353a068334e1e2de224e05d022dcd303a26d HTML Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Fri, 9 Aug 2024 10:56:54 +0200 webcam-stream.sh: add MQTT streaming of webcam Signed-off-by: Christoph Lohmann <20h@r-36.net> Diffstat: A mqtt/webcam-stream.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+), 0 deletions(-) --- DIR diff --git a/mqtt/webcam-stream.sh b/mqtt/webcam-stream.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# stream your face to a MQTT topic +# requirements: +# ffmpeg +# imcat: https://github.com/stolk/imcat +# mosquitto_pub: https://github.com/eclipse/mosquitto +uri="${MQTT_URI:-mqtt://bitreich:bitreich@mx2.adamsgaard.dk:65431/}" +topic="${MQTT_TOPIC:-faces/$USER}" +sleep="${CAM_INTERVAL:-10}" +device="${1:-video0}" +f="$(mktemp).jpg" +while : +do + ffmpeg -y -f v4l2 -video_size 1280x720 -i "/dev/${device}" \ + -qscale:v 2 -vframes 2 -r 0.2 -update 1 "$f" \ + -loglevel 0 </dev/null + if ! msg="$(echo; imcat "$f")" + then + exit 2 + fi + mosquitto_pub -L "${uri}${topic}" -m "$msg" + sleep "$sleep" +done