Looking for the best way to take a picture every hour on a few cameras

105437

BIT Beta Team
Jun 8, 2015
2,169
1,057
Anyone ever set this up? Best I can tell is that I'll need to create separate scheduled events to create a JPEG using the Queue JPEG post function. Thanks
 
Well so you already know you can do in your cameras WebUI under storage it seems.. Keep in mind that if you were to setup for a General Snapshot and later want to pull a few images it will fail after the first image until after the wait time is over.. At least that is how it works for me.. So for me. Making a Python script is better option. Leave your camera setup for 1 second images that it was setup for and when you start this script it will pull an image I setup for 4 different cameras I don't know if they were all the same password so I setup for making it command each camera change name and password to meet your needs and with this script it will pull an image every hour. Again can change to meet your needs.

Normal script. Windows 11 script will be below the first script if you are using Win11..

Python:
import requests
from datetime import datetime
import time

CAMERAS = {
    "cam1": "http://user:pass@192.168.1.10/cgi-bin/snapshot.cgi",
    "cam2": "http://user:pass@192.168.1.11/cgi-bin/snapshot.cgi",
    "cam3": "http://user:pass@192.168.1.12/cgi-bin/snapshot.cgi",
    "cam4": "http://user:pass@192.168.1.13/cgi-bin/snapshot.cgi",
}

def capture_snapshot(name, url):
    try:
        response = requests.get(url, timeout=5)
        if response.status_code == 200:
            filename = f"{name}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.jpg"
            with open(filename, "wb") as f:
                f.write(response.content)
            print(f"Saved {filename}")
    except Exception as e:
        print(f"Error capturing from {name}: {e}")

while True:
    for name, url in CAMERAS.items():
        capture_snapshot(name, url)
    time.sleep(3600)  # wait 1 hour

If you want for Win11..

Python:
import os
import time
import requests
from datetime import datetime

# Example camera URLs (replace with yours)
CAMERAS = {
    "cam1": "http://user:pass@192.168.1.10/cgi-bin/snapshot.cgi",
    "cam2": "http://user:pass@192.168.1.11/cgi-bin/snapshot.cgi",
    "cam3": "http://user:pass@192.168.1.12/cgi-bin/snapshot.cgi",
    "cam4": "http://user:pass@192.168.1.13/cgi-bin/snapshot.cgi",
}

SAVE_DIR = "snapshots"
os.makedirs(SAVE_DIR, exist_ok=True)

def capture_snapshot(name, url):
    try:
        now = datetime.now()
        timestamp = now.strftime("%Y-%m-%d_%H-%M-%S")
        date_folder = os.path.join(SAVE_DIR, now.strftime("%Y-%m-%d"))
        os.makedirs(date_folder, exist_ok=True)

        filename = os.path.join(date_folder, f"{name}_{timestamp}.jpg")
        response = requests.get(url, timeout=10)
        if response.status_code == 200:
            with open(filename, "wb") as f:
                f.write(response.content)
            print(f"Saved snapshot: {filename}")
        else:
            print(f"Failed to get snapshot from {name}")
    except Exception as e:
        print(f"[{name}] Error: {e}")

while True:
    print(f"Capturing snapshots at {datetime.now()}")
    for name, url in CAMERAS.items():
        capture_snapshot(name, url)
    print("Sleeping for 1 hour...")
    time. Sleep(3600)
 
I had about 10 cameras saving snap shots on version 5.0.
I crashed my system once with an Updated version of BI, when the default became " continous" over riding my settings of every ten min or so.
Had to catch it before crashed several times, to switch off that " continous" .jpg setting... then @wittaj told me about substreams and I quit using .jpgs for that system at that Condo.

Something most people might not run into....but throwing out there as a thing...
View attachment Recording 2025-05-26 145404.mp4
 
Last edited:
  • Like
Reactions: 105437