inertiacreeping / Unifi-Timelapse

Creating a timelapse from your Unifi camera snaps.
11 stars 0 forks source link

UniFi Camera Timelapse Creator (Windows)

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.

Warning

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.

"Expected Behaviour".

Thankfully my G3 Bullet still returns a 1920x1080 image (for how long? WHO KNOWS)

Fix:

  1. Turn on SSH on your Unifi controller which hosts the Protect instance (you'll have to set a SSH password)
  2. SSH into your controller with:
    ssh root@192.168.1.1 (insert your IP address here) 
  3. Roll back to a previous Protect version using:
    apt-get install --reinstall --allow-downgrades unifi-protect=2.10.11 -y
  4. Turn off auto-update in OS Settings -> Applications -> Uncheck "Applications" checkbox next to the auto-update heading.

Download / How to use it?

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:

  1. Click here to download UnifiCameraTimelapse.zip
    • 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.
  2. Click here to download FFmpeg
    • 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!

image

Features:

Prerequisites:

[!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

  1. 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.

image

  1. Get the IP address of your camera(s), which can be found in your Camera list in Unifi Protect

image

  1. 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)

image

  1. In the Configure tab, enable Anonymous Snapshot, then click Save Changes

image

  1. 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.

Required dependencies (if using Python - Windows users only need to download and install FFMpeg):

  1. Python 3
  2. Tkinter
  3. Requests
  4. 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.

Usage:

Specifying IP Addresses or IP Range

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.

1. Specifying IP Addresses:

2. Specifying IP Range:

Automatic Search

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.

Usage

  1. Run the script.
  2. Select one or more discovered cameras by clicking the checkboxes next to their IP addresses.
  3. 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.
  4. 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.
  5. 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.

1

[!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.

License

Creative Commons License

Unifi Camera Timelapse Creator © 2023 by Morris Lazootin is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Acknowledgements

FFmpeg

This software includes FFmpeg licensed under the LGPLv2.1.

The source code of FFmpeg can be found here.

Rafael Sampaio

https://webcache.googleusercontent.com/search?q=cache:mCfoBv8q4lYJ:https://www.rafaelsampaio.net/tech/create-a-timelapse-with-unifi-and-ffmpeg/&hl=en&gl=nz

Apologies in advance, I don't really know what I'm doing 💔