This script provides a GUI to create timelapses from UniFi Cameras. It discovers cameras on your local network, captures snapshots based on a specified frequency, and then automagically compiles them into a timelapse video once the capturing session is complete.
Unifi can't help themselves from absolutely fucking their paying customers. Be warned that new cameras (specifically the G5 lineup and possibly new firmware of older models) reduces /snap captures to 640x360 pixels.
Thankfully my G3 Bullet still returns a 1920x1080 image (for how long? WHO KNOWS)
Fix:
- Turn on SSH on your Unifi controller which hosts the Protect instance (you'll have to set a SSH password)
- SSH into your controller with:
ssh [email protected] (insert your IP address here)
- Roll back to a previous Protect version using:
apt-get install --reinstall --allow-downgrades unifi-protect=2.10.11 -y
- Turn off auto-update in OS Settings -> Applications -> Uncheck "Applications" checkbox next to the auto-update heading.
If you know how to use Python, you probably don't need me to explain. Just make sure that you install FFmpeg and pip install requests.
If you're a Windows pleb like me, then read on:
- Extract the folder onto your PC. Preferably somewhere where files can be written. If you burn this to a CD, it probably won't work.
- open the 7z file and located ffmpeg.exe inside the /bin/ folder.
- copy ffmpeg.exe into the same folder as UnifiCameraTimelapse.exe. Double click UnifiCameraTimelapse.exe to run the script - clicking past any Windows security warnings.
That's it!
- Automatically detects your network IP range, then discovers available UniFi Cameras.
- Configure capture settings like snapshot frequency and output video frame rate.
- One-click start for immediate timelapse creation.
- Schedule recordings to automatically create a timelapse during specific intervals.
- View metrics from the previous session, such as elapsed time, total captures, file size of camptures, and estimated video length.
- Convert previously stored snapshots into a timelapse video.
Important
Before using the script, ensure that you've previously logged into each UniFi camera and enabled the Anonymous Snapshots feature. This is crucial for the script to be able to capture snapshots, as this script relies on scraping a snapshot from each Camera from IP ADDRESS/snap.jpeg
- Log into Unifi Protect, click on the Settings Cog in the left-hand menu, click on System then reveal your Recovery Code. Copy this code, we'll use it to log into the cameras in a bit.
- Get the IP address of your camera(s), which can be found in your Camera list in Unifi Protect
- Put this IP address into your web browser address bar, and hit enter. You'll be presented with a sign-in screen - sign into the camera using "ubnt" (username) and your recovery key (password)
- In the Configure tab, enable Anonymous Snapshot, then click Save Changes
- Now, if you append /snap.jpeg to the IP address of your camera, you should see a static jpeg snapshot of what the camera sees.
- Python 3
- Tkinter
- Requests
- FFmpeg - For converting images to video. System-wide or local install (ie, ffmpeg.exe located in script folder) works fine - this script will check for both.
Without any user interaction, this script will detect the IP range your machine is using, then scan that entire IP Range for any IP address which returns an image at IP.ADDRESS/snap.jpeg (indicating that a Unifi camera exists at this IP address).
To make the search process more efficient, you can provide the script with either specific IP addresses of the cameras or an IP range to search within.
-
Create a file named
IP.txt
in the root directory of the script. -
Within this file, list down the IP addresses of the cameras, one address per line.
192.168.1.5 192.168.1.6 192.168.1.7
-
If you'd like the script to search within a specific IP range, create a file named
IP_range.txt
in the root directory of the script. -
Enter the desired IP range in this file.
192.168.1.1/24
This will instruct the script to search for cameras within the 192.168.1.1 to 192.168.1.255 range.
If neither IP.txt
nor IP_range.txt
files are present, the script will default to automatically searching for cameras. It will attempt to detect the local network's IP range and search within that range for any available cameras.
- Run the script.
- Select one or more discovered cameras by clicking the checkboxes next to their IP addresses.
- Change the desired capture rate and output video frames per second (FPS)
- an estimate for frames, storage size, and video output length will be calculated and displayed below.
- Click on:
- "Start capturing" to begin an immediate capture session, or;
- "Start schedule for the capture session to begin and end at a specific time.
- If you start a schedule inside the sheduled times, the capturing will begin immediately.
- There mgiht be a slight delay to the start/end of a scheduled capture session, due to the way the scheduler works.
- To convert previously captured snapshots into a video (perhaps with a different framerate), click on the "Convert Existing Images" button, select the relevant folder of captured snapshots, and the script will handle the rest.
Note
Captures will be stored in /captures/IP ADDRESS/Date_time.
Videos are created and stored in the same folder as the captures.
In testing, 215 images came out to be around 53.7MB, while the rendered timelapse video was only 3.29MB. Do with that information what you will.
Unifi Camera Timelapse Creator © 2023 by Morris Lazootin is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
This software includes FFmpeg licensed under the LGPLv2.1.
The source code of FFmpeg can be found here.
Apologies in advance, I don't really know what I'm doing 💔