Shell script to upload RTSP camera images to PrusaConnect Camera API
 
Benachrichtigungen
Alles löschen

Shell script to upload RTSP camera images to PrusaConnect Camera API  

  RSS
nicolaw
(@nicolaw)
Mitglied
Shell script to upload RTSP camera images to PrusaConnect Camera API

I just wanted to share my short script solution to upload to the PrusaConnect Camera API. This is worked out with the help of others' posts in this forum, so I thought other people might also find this helpful. It just requires that you have `ffmpeg`, `curl` and `bash` installed:

#!/usr/bin/env bash

set -Eeuo pipefail
shopt -s extdebug

# shellcheck disable=SC2154
trap 'declare rc=$?;
      >&2 echo "Unexpected error (exit-code $rc) executing $BASH_COMMAND at ${BASH_SOURCE[0]} line $LINENO";
      exit $rc' ERR

main () {
  # Enable RTSP streaming for your UniFi Protect camera and paste the URL here.
  declare rtsp_stream="rtsps://10.10.10.10:7441/AbCdEfGh12345678?enableSrtp"
  declare token="YOUR_PRUSACONNECT_CAMERA_TOKEN_HERE"
  # Generate a new fingerprint with 'uuidgen'.
  declare fingerprint="YOUR_ARBITARY_PRUSACONNECT_CAMERA_FINGERPRINT_STRING_HERE"
  declare printer_uuid="YOUR_PRUSACONNECT_PRINTER_UUID_HERE"

  while sleep 30
  do
    if ffmpeg \
      -y \
      -loglevel quiet \
      -rtsp_transport udp \
      -i "$rtsp_stream" \
      -vframes 1 \
      -q:v 1 \
      -f image2pipe - \
    | curl  https://webcam.connect.prusa3d.com/c/snapshot  \
      -X PUT \
      -s \
      -H "Content-Type: image/jpg" \
      -H "fingerprint: $fingerprint" \
      -H "token: $token" \
      --data-binary @-
    then
      printf "."
    else
      printf "?"
      sleep 30
    fi
  done
}

main "$@"
Veröffentlicht : 30/11/2023 5:20 pm
Marvzek gefällt das
Marvzek
(@marvzek)
Mitglied
RE: Shell script to upload RTSP camera images to PrusaConnect Camera API

Thank you very much for your script. I am running it since a week and it works nicely. I am thinking about making a modification to turn on and off the for the shot.

Veröffentlicht : 20/12/2023 6:45 am
Teilen: