PrusaConnect Timelapse "Plugin" (Early-beta release!)
Prusa Connect Timelapse Creator
This Python script automates the process of creating a timelapse video from images downloaded from Prusa Connect. It performs the following steps:
Automated Clicking: The script simulates mouse clicks at a specified screen position. This can be used to trigger the downloading of images from Prusa Connect.
Image Organization: The script moves the downloaded images from the Downloads folder to a specified folder. It only moves images that have a filename starting with a specified prefix.
Timelapse Creation: The script creates a timelapse video from the moved images. The video is saved with a filename based on the common prefix of the image filenames.
Usage:
Specify the coordinates of the point to click in the x, y variables.Specify the number of clicks and the interval between clicks in the num_clicks and interval variables.
Call:
move_images_with_prefix
with the path to your Downloads folder, the path to the folder where you want to move the images, and the common prefix of the image filenames.
Call:
create_timelapse
with the path to the folder containing the images and the desired frames per second for the timelapse video.Dependencies
This script requires the pyautogui, opencv-python, os, and shutil Python libraries. You can install them using pip:
pip install pyautogui opencv-python
Disclaimer: This script interacts with the screen and file system. Please use it responsibly and ensure that it does not interfere with your normal computer usage. Always test the script in a controlled environment before running it unattended.
Examples of Usage:
IMPORTANT NOTE: To get the correct X, Y position of the "download snapshot" button do this:
- Install the pyautogui library: If you haven’t already, you’ll need to install the pyautogui library. You can do this by opening your command prompt or terminal and typing the following command:
pip install pyautogui
-
Import the pyautogui library: In the Python shell, type the following command and press enter:
import pyautogui
- Display the mouse position: Now, you can display the real-time position of your mouse cursor by typing the following command and pressing enter:
pyautogui.displayMousePosition()
Best Answer by Fortnite Gamer:
VERSION 0.2 IS OUT NOW!
Changelog:
- Added Security Feautres
- Added Auto-Creation of Dependent Folders
- Added Inputs so there is NO NEED TO EDIT CODE! HOORAY👌👌👌✔✔✔!
New Usage AND FULL TUTORIAL:
Step 1:
Login to your Prusa connect account, and set it in a split screen on the left or right.
Next, navigate to your camera page, and ensure you are scrolled ALL THE WAY UP!
Step 2: Getting the X,Y Coords of your download button
In the future(V0.4), both of the scripts I will turn into a .exe, but for now it is manual:
Open Command Prompt, then cd into your python311 scripts folder, RUN:
pip install pyautogui
Then, in your shell, run:
import pyautogui
Then type:
pyautogui.displayMousePosition()
Hover over your download snapshot button, and note down the coords.
INPUT THEM INTO THE SCRIPT!
Step 3: Running the script
Now, for the last step, simply run the script, preferably try to run it right after the camera updates.
SUPER IMPORTANT NOTE: If your camera settings are set to update every 30 seconds(Won't work as well for timelapse), set them to 10 or, update the interval variable.
Hope this helps everyone! Have a good day, and post any of your issues in the replies!
PS: I was in a hurry to get this published in time before the moderators in the Czech Republic(Czechia) wake up in order to gain the most traction to this post, if I made any critical errors, please lmk.
import pyautogui import time import os import shutil import cv2 # specify coordinates of the point to click x, y = 1140, 1099 # specify number of clicks and interval between clicks num_clicks = int(int(input(r'How long is your print?(Format in seconds long please!)'))/10) us=input('What is your computer username? (To check the one to use, go to your downloads folder, copy the address and check what name is after C:\\)') print(num_clicks) interval = 10 # seconds for _ in range(num_clicks): pyautogui.click(x, y) print(f'Click {_}/{num_clicks}') time.sleep(interval) def delete_and_move_images_with_prefix(source_folder, destination_folder, prefix): # Create the destination folder if it doesn't exist os.makedirs(destination_folder, exist_ok=True) # Delete all files in the destination folder for filename in os.listdir(destination_folder): file_path = os.path.join(destination_folder, filename) try: if os.path.isfile(file_path) or os.path.islink(file_path): os.unlink(file_path) elif os.path.isdir(file_path): shutil.rmtree(file_path) except Exception as e: print('Failed to delete %s. Reason: %s' % (file_path, e)) # Get a list of all files in the source folder files = os.listdir(source_folder) # Filter the list for files that start with the prefix and end with .jpg images = [f for f in files if f.startswith(prefix) and f.endswith('.jpg')] # Sort the images by their creation time (most recent first) images.sort(key=lambda img: os.path.getctime(os.path.join(source_folder, img)), reverse=True) # Move the images to the destination folder for image in images: shutil.move(os.path.join(source_folder, image), os.path.join(destination_folder, image)) # Usage delete_and_move_images_with_prefix(fr'C:\\Users\\{us}\\Downloads', fr'C:\\Users\\{us}\\AppData\\Local\\Programs\\Python\\Python311\\SnapShots', 'snapshot-PrusaConnect Webcam-') def create_timelapse(input_folder, output_folder, fps): images = [img for img in os.listdir(input_folder) if img.endswith(".jpg")] # Check if there are any images in the folder if not images: print("No images found in the folder.") return # Determine the common prefix of the image filenames common_prefix = os.path.commonprefix(images) # Use the common prefix as the output filename, or default to 'output.avi' if there's no common prefix output_file = f"{common_prefix or 'output'}(TimeLapse).avi" # Create the output folder if it doesn't exist os.makedirs(output_folder, exist_ok=True) # Full path to the output file output_path = os.path.join(output_folder, output_file) frame = cv2.imread(os.path.join(input_folder, images[0])) height, width, layers = frame.shape video = cv2.VideoWriter(output_path, cv2.VideoWriter_fourcc(*'DIVX'), fps, (width,height)) for image in images: video.write(cv2.imread(os.path.join(input_folder, image))) cv2.destroyAllWindows() video.release() # Usage create_timelapse(fr'C:\\Users\\{us}\\AppData\\Local\\Programs\\Python\\Python311\\SnapShots', fr'C:\\Users\\{us}\\AppData\\Local\\Programs\\Python\\Python311\\TimeLapser', 60)
This Setup Works amazing for me:
RE:
VERSION 0.2 IS OUT NOW!
Changelog:
- Added Security Feautres
- Added Auto-Creation of Dependent Folders
- Added Inputs so there is NO NEED TO EDIT CODE! HOORAY👌👌👌✔✔✔!
New Usage AND FULL TUTORIAL:
Step 1:
Login to your Prusa connect account, and set it in a split screen on the left or right.
Next, navigate to your camera page, and ensure you are scrolled ALL THE WAY UP!
Step 2: Getting the X,Y Coords of your download button
In the future(V0.4), both of the scripts I will turn into a .exe, but for now it is manual:
Open Command Prompt, then cd into your python311 scripts folder, RUN:
pip install pyautogui
Then, in your shell, run:
import pyautogui
Then type:
pyautogui.displayMousePosition()
Hover over your download snapshot button, and note down the coords.
INPUT THEM INTO THE SCRIPT!
Step 3: Running the script
Now, for the last step, simply run the script, preferably try to run it right after the camera updates.
SUPER IMPORTANT NOTE: If your camera settings are set to update every 30 seconds(Won't work as well for timelapse), set them to 10 or, update the interval variable.
Hope this helps everyone! Have a good day, and post any of your issues in the replies!
PS: I was in a hurry to get this published in time before the moderators in the Czech Republic(Czechia) wake up in order to gain the most traction to this post, if I made any critical errors, please lmk.
import pyautogui import time import os import shutil import cv2 # specify coordinates of the point to click x, y = 1140, 1099 # specify number of clicks and interval between clicks num_clicks = int(int(input(r'How long is your print?(Format in seconds long please!)'))/10) us=input('What is your computer username? (To check the one to use, go to your downloads folder, copy the address and check what name is after C:\\)') print(num_clicks) interval = 10 # seconds for _ in range(num_clicks): pyautogui.click(x, y) print(f'Click {_}/{num_clicks}') time.sleep(interval) def delete_and_move_images_with_prefix(source_folder, destination_folder, prefix): # Create the destination folder if it doesn't exist os.makedirs(destination_folder, exist_ok=True) # Delete all files in the destination folder for filename in os.listdir(destination_folder): file_path = os.path.join(destination_folder, filename) try: if os.path.isfile(file_path) or os.path.islink(file_path): os.unlink(file_path) elif os.path.isdir(file_path): shutil.rmtree(file_path) except Exception as e: print('Failed to delete %s. Reason: %s' % (file_path, e)) # Get a list of all files in the source folder files = os.listdir(source_folder) # Filter the list for files that start with the prefix and end with .jpg images = [f for f in files if f.startswith(prefix) and f.endswith('.jpg')] # Sort the images by their creation time (most recent first) images.sort(key=lambda img: os.path.getctime(os.path.join(source_folder, img)), reverse=True) # Move the images to the destination folder for image in images: shutil.move(os.path.join(source_folder, image), os.path.join(destination_folder, image)) # Usage delete_and_move_images_with_prefix(fr'C:\\Users\\{us}\\Downloads', fr'C:\\Users\\{us}\\AppData\\Local\\Programs\\Python\\Python311\\SnapShots', 'snapshot-PrusaConnect Webcam-') def create_timelapse(input_folder, output_folder, fps): images = [img for img in os.listdir(input_folder) if img.endswith(".jpg")] # Check if there are any images in the folder if not images: print("No images found in the folder.") return # Determine the common prefix of the image filenames common_prefix = os.path.commonprefix(images) # Use the common prefix as the output filename, or default to 'output.avi' if there's no common prefix output_file = f"{common_prefix or 'output'}(TimeLapse).avi" # Create the output folder if it doesn't exist os.makedirs(output_folder, exist_ok=True) # Full path to the output file output_path = os.path.join(output_folder, output_file) frame = cv2.imread(os.path.join(input_folder, images[0])) height, width, layers = frame.shape video = cv2.VideoWriter(output_path, cv2.VideoWriter_fourcc(*'DIVX'), fps, (width,height)) for image in images: video.write(cv2.imread(os.path.join(input_folder, image))) cv2.destroyAllWindows() video.release() # Usage create_timelapse(fr'C:\\Users\\{us}\\AppData\\Local\\Programs\\Python\\Python311\\SnapShots', fr'C:\\Users\\{us}\\AppData\\Local\\Programs\\Python\\Python311\\TimeLapser', 60)
RE: PrusaConnect Timelapse "Plugin" (Early-beta release!)
i'm sorry, that's way to complicated to me. And, if my understanding is right, i have to have a PC running while printing.
RE: PrusaConnect Timelapse "Plugin" (Early-beta release!)
If there is any specific thing you need help with, let me know, and yes unfortunately you need a pc or raspberry pi running while it prints, electricity is extremely cheap where I live, but I understand the costs of timelapsing a long print elsewhere.
RE: PrusaConnect Timelapse "Plugin" (Early-beta release!)
Any update on the progress of this script? I'm definitely interested in trying to get it to work, but I'm still really new to using Python and my folder locations for things are quite different than what you have written into the script as it stands right now. I hope to see an easy-to-use .exe soon! 😀
RE: PrusaConnect Timelapse "Plugin" (Early-beta release!)
So sorry I never got back to you! I have officially marked this as a dead project as of now, but if you have a discord, I can help you get it running with my personal .exe(I will never release one to the public due to security concerns.)
RE: PrusaConnect Timelapse "Plugin" (Early-beta release!)
Apparently my account is "too new" or something because it says I cannot reply to your private message directly. Haha!
My Discord username is the same as my profile name here, just without the 2025. 🙂
RE: PrusaConnect Timelapse "Plugin" (Early-beta release!)
Welcme to the Group,
Unfortunately we have to try and reduce Spammers...
I Hope you understand,
regards Joan
I try to make safe suggestions,You should understand the context and ensure you are happy that they are safe before attempting to apply my suggestions, what you do, is YOUR responsibility. Location Halifax UK
RE: PrusaConnect Timelapse "Plugin" (Early-beta release!)
Oh yeah, not a problem at all. I've had a Prusa account for literal years, but this is the first time I'm actually posting to any of the forums. I'm sure I'll reach the minimum soon enough. Haha!
Thank you for taking the time to let me know though! It is much appreciated. 🙂
RE: PrusaConnect Timelapse "Plugin" (Early-beta release!)
Cheers,
regards Joan
I try to make safe suggestions,You should understand the context and ensure you are happy that they are safe before attempting to apply my suggestions, what you do, is YOUR responsibility. Location Halifax UK