This document describes Moonraker-timelapse configuration. As this file
references configuration for both Klipper (printer.cfg
) and Moonraker
(moonraker.conf
), each example contains a commment indicating which
configuration file is being refrenenced.
Include the macro file to your printer.cfg
# printer.cfg
[include timelapse.cfg]
To use the "layermacro" mode which grabs a frame every layerchange you need to
add the TIMELAPSE_TAKE_FRAME
macro to your slicer so that it is added to
the Gcode before or after a layer change. If your slicer does not support adding
Gcode to a layerchange you are limited to the timebased "hyperlapse" mode.
Printer Settings -> Custom G-code -> Before layer change Gcode -> TIMELAPSE_TAKE_FRAME
Extensions -> Post Processing -> Modify G-Code ->
Add a script -> Insert at layer change -> G-code to insert = TIMELAPSE_TAKE_FRAME
Advanced Settings -> Gcode -> Layer Change Gcode -> TIMELAPSE_TAKE_FRAME
(Credits to Vez3d for the screenshot)
# moonraker.conf
[timelapse]
## Following basic configuration is default to most images and don't need
## to be changed in most scenarios. Only uncomment and change it if your
## Image differ from standart installations. In most common scenarios
## a User only need [timelapse] in their configuration.
#output_path: ~/timelapse/
## Directory where the generated video will be saved
#frame_path: /tmp/timelapse/
## Directory where the temporary frames are saved
#ffmpeg_binary_path: /usr/bin/ffmpeg
## Directory where ffmpeg is installed
Configuration offered by the '/machine/timelapse/settings' endpoint
'true' enables or 'false' disables the plugin. In a disabled state gcode macros are ignored and autorender is skipped. This helps if you have macros setup in your slicer but like to manually skip timelapse for a print.
At the moment there are two modes available 'layermacro' and 'hyperlapse'
This mode uses a macro to trigger frame grabbing, but needs the slicer to be setup to add such on layerchange (refer to the 'Slicer setup' below)
This mode takes a frame every x seconds configured by the hyperlapse_cycle setting
Defines the time interval in which a frame gets taken in the hyperlapse mode.
'true' enables or 'false' disables automatic trigger of the render process at the end of the print. Alternatively you can use the 'TIMELAPSE_RENDER' in your end gcode or the Render http Endpoint (which may be integrated into your frontend) to trigger the render process.
'True' enables or 'False' disables packing the frames to a zip file for external use or render.
This setting let you choose which camera should be used to take frames from. It depends on the 'webcam' namespace in the moonraker DB and uses the 'snapshoturl', 'flipX' and 'flipY' associated whith selected camera. Alternatively you can configure 'snapshoturl', 'flip_x' and 'flip_y' in the moonraker.conf if your frontend doesn't support the webcams namespace of moonraker DB.
'true' enables or 'false' disables verbosity of the Macros
'true' enables or 'false' disables parking the printhead before taking a frame.
This defines the position where to park the printhead before taking a frame. Possible configurations are [center, front_left, front_right, back_left, back_right, custom]
If you like to define a custom parkposition of your printhead.
Absolute X coordinates of the custom parkposition (Unit mm)
Absolute Y coordinates of the custom parkposition (Unit mm)
Relative Z coordinates of the custom parkposition (Unit mm)
Speed of the printhead movement while parking (Unit mm/s)
Speed of the retract while parking (Unit mm/s)
Speed of the extrude when resuming the print (Unit mm/s)
Distance to retract the filament to prevent oozing (Unit mm)
Distance to extrude to fill the nozzle before resuming the print (Unit mm)
'true' enables or 'false' disables use of firmware retraction in the macro. Note: Enabling this will disable retract related settings!
add additional idle time when parking (Unit seconds, default 0.1)
delay frame capture (Unit seconds, default 0.05)
This defines how the rendered video should be named. It uses the python datetime format. Default is "%Y%m%d_%H%M". More info about the datetime format can be found here https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes
Defines the Framerate of the video. (Unit frames per second) Note: this will be ignored if variable_fps is enabled.
'true' enables or 'false' disables variable calcuation of the output framerate. This uses the count of taken frames and 'targetlength', but is limited by 'variable_fps_min' and 'variable_fps_max' settings.
Defines the target length of a video (Unit seconds)
Minimum fps for variable_fps (Unit frames per second).
Maximum fps for variable_fps (Unit frames per second).
This configure quality vs filesize of the rendered Video. The range of the CRF scale is 0–51, where 0 is lossless, 23 is the default and 51 is worst quality possible. A lower value generally leads to higher quality and a subjectively sane range is 17–28. Consider 17 or 18 to be visually lossless. more info: https://trac.ffmpeg.org/wiki/Encode/H.264
Defines the pixelformat of the output video. Some older h264 devices like mobiles and others need 'yuv420p' which is default the timelapse component. To get more info which pixelformats are available run 'ffmpeg -pix_fmts' in your system console or refer to the ffmpeg documentation: https://ffmpeg.org/ffmpeg.html
Duplicates the last frame to the end of the output video.
Defines extra output parameters to FFMPEG further info: https://ffmpeg.org/ffmpeg.html Note: Specifing anything here will maybe disable other features! (ffmpeg limitation)
'true' enables or 'false' disables coping the last frame as a preview image to the output directory. This is used so that the frontend can show a preview of the timelapse without needing to open the video.
The Plugin offers configuration via a Http API which is the preferred method to configure Timelapse. How ever if your frontend doesn't support those configuration there is a Fallback to moonraker.conf. However beware adding and uncommenting this in your moonraker.conf will disable the possibility to change the setting in the frontend. Please refer to section above what each setting does.
# moonraker.conf
# [timelapse] section
#enabled: True
#mode: layermacro
#snapshoturl: http://localhost:8080/?action=snapshot
#gcode_verbose: True
#parkhead: False
#parkpos: back_left
#park_custom_pos_x: 0.0
#park_custom_pos_y: 0.0
#park_custom_pos_dz: 0.0
#park_travel_speed: 100
#park_retract_speed: 15
#park_extrude_speed: 15
#park_retract_distance: 1.0
#park_extrude_distance: 1.0
#hyperlapse_cycle: 30
#autorender: True
#constant_rate_factor: 23
#output_framerate: 30
#pixelformat: yuv420p
#time_format_code: %Y%m%d_%H%M
#extraoutputparams:
#variable_fps: False
#targetlength: 10
#variable_fps_min: 5
#variable_fps_max: 60
#flip_x: False
#flip_y: False
#duplicatelastframe: 0
#previewimage: True
#saveframes: False
#wget_skip_cert_check: False
You may want to change your Timelapse to a higher resolution, you need to change the Webcamstream to a higher resolution since the Component will grab the frame of the Streamer. To do so, please refer to the documentation of your Image:
- MainsailOS: https://crowsnest.mainsail.xyz/configuration/cam-section#resolution
- FluiddPI: https://docs.fluidd.xyz/features/cameras
The default is that the macros check every 0.5 sec if the print can continue. This is a good compromise between cpu load and quality. From now one you can change this time. Caution, smaller numbers increase the risk of a klipper "timer to close"
To change it simple, add the following GCODE to your print start:
SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=check_time VALUE=0.5
To get that change at every klipper start:
[delayed_gcode _INIT_TIMELAPSE_CHECK_TIME]
initial_duration: 1
gcode: SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=check_time VALUE=0.5