External camera skill

I have some external security cameras from Reolink around my house, I have tried setting up notifications when something triggers the cameras but it is flakey at best and I end up just ignoring the notifications. I also dont have recording setup as theyre 4k and I am not sure it would be that useful. I have just discovered that you can access the cameras on my local network using the RSTP (real time streaming protocol) and process the stream using ffmpeg.

Now i have a skill i can view a clip or image from any one of my cameras.

You will need the cameras ip address and username and password to access the camera stream.

Get an image

ffmpeg -rtsp_transport tcp -i "rtsp://WEBCAM_USERNAME:<CAMERA_PASS>@<CAMERA_IP>:554/h264Preview_01_sub" -frames:v 1 snapshot_<CAMERANAME>_<TIMESTAMP>.jpg

This will save a 1 frame image from the camera stream.

Streams

THe path in the url ‘h264Preview_01_sub’, this is the lower res sub stream from the camera, if you have a 8k/4k camera there should be a high resolution stream available at ‘h265Preview_01_main’.

Video

You can stream for a specified time and create a vide clip:

ffmpeg -rtsp_transport tcp -i "rtsp://WEBCAM_USERNAME:<CAMERA_PASS>@<CAMERA_IP>:554/h264Preview_01_main" \
  -t 60 -c copy output.mp4

Open

on macos you can open an image or video using:

open <WEBCAM_SAVE_LOCATION>/<CAMERANAME>/snapshot_<CAMERANAME>_<TIMESTAMP>.jpg
open <WEBCAM_SAVE_LOCATION>/<CAMERANAME>/video_<CAMERANAME>_<TIMESTAMP>.mp4

I can now use this skill from an agent like claude code or gemini, I have also setup this to take an image every hour and save it to google drive.

© 2024 Timney.