Taking time lapse videos from Prusa prints using esp32 camera and Node-RED.
Current v2 version is on master branch and uses custom gcode to trigger images.
For previous version see branch v1, but notice this is not maintained anymore.
Tested with Prusa Mini+ v4.4.1 and v5.1.2, so it should probably work with any newer Prusa printer API (or may need slight adjustment).
Using custom gcode printer triggers button with every new layer. Pressing the button sends message from esp32 to MQTT topic. When message from specific topic is received then it triggers flow in Node-RED. In the flow there is a check if the printer is printing, and thus it takes picture via web from esp32 camera, and stores it in local directory. If the print of the printer stops then it triggers rendering images into a mp4 video.
See docs/README.md for detailed instructions
2023-11-11_2_720p.mp4
-
trigger button via custom gcode
-
trigger flow when button is pressed
-
trigger video render if printer was printing and stopped printing
-
Node-RED + mqtt in containers (docker), can also run directly on host
-
logic flow - capturing images to directory if printer is printing
-
rendering images into a movie using ffmpeg within node-red container
-
now whole process is within single flow, and you can run multiple flows if you have different printers/cameras
-
you can define default values per flow such as destination directory, printer address, camera address
-
if day change is detected (via UTC) then print counter is reset to zero after current print is finished
-
fetch image from camera only once
-
ffmpeg in container + shell script to merge images into a mp4 file
-
basic web ui dashboard, it's crap but provides core info :)
-
default docker-compose spawns fake prusa api and fake esp32 camera, this is great to test flows and adjust them without need of using real hardware
-
fixed issues with out of order frames
- due to using custom gcode it takes a bit time to tune button triggering, but you can manually trigger flow in Node-RED.
- if you have print in the bed corner close to where power connector is attached to bed, then it can trigger button presses and thus extra image captures, that's why it is better to adjust print area to avoid movements in that space, if possible.
- if you deploy node-red flow then counter for daily print is reset, which results in files to be saved in already existing directories and video may not be rendered because it already exists, or it will be merged from old and new images (depends on the timelapse script options)
- you MUST configure node
general config
underon Startup
and set vars there
- screenshot taking/stopping and video render have some delay, this is intentional, first, it allows to add 'final' frame when printer head is away from print, second, it allows to not trigger actions on failed messages
- before rendering videos there is not much info on the dashboard
- video progress is showing yellow dot on the dashboard only if ffmpeg runs for over 10s
- can not get rendered video from the dashboard - out of scope - use other flows for that, there is one that allows to browse files via web ui, or just mount data dir as samba share etc, see below
- if camera fetch error occurs there is no retry to fetch it, this is rather not an issue because ffmpeg will automatically detect incorrect images and will not add them to video
- rendered images and videos are not cleaned up, you must manage data dir on your own
Things that will not going to happen:
- adding code to list files for render videos/images in web ui; there are other better solutions there such as Csongor Varga code
-
save daily print counter state to avoid writing to existing directories
-
detect camera errors + add retry
-
detect bad camera captures + add retry
-
how to deal with the corner case when printing very close to the button - use gcode to trigger on-board pins, is is supported by Prusa Mini?
Currently project fulfills the needs I wanted.