ihrapsa / KlipperWrt

A guide to install Klipper with fluidd, Mainsail or Duet-Web-Control and webcam stream in OpenWrt. Mainly created around the Creality Wi-Fi box but any OpenWrt running device with similar specs will work just fine.
180 stars 39 forks source link

[guide] Add timelapse instructions #7

Open ihrapsa opened 3 years ago

ihrapsa commented 3 years ago

Update guide with instructions to install timelapse moonraker component + dependencies

wget https://github.com/FrYakaTKoP/moonraker/raw/dev-timelapse/moonraker/components/timelapse.py -P /root/moonraker/moonraker/components

moonraker.conf

[timelapse]
enabled: True
##   If this set to False the Gcode macros are ignored and
##   the autorender is disabled at the end of the print.
##   The idea is to disable the plugin by default and only activate 
##   it during runtime via the http endpoint if a timelapse is desired.
autorender: False
##   If this is set to False, the autorender is disabled at the end of the print.
constant_rate_factor: 23
##   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.
##   more info: https://trac.ffmpeg.org/wiki/Encode/H.264
#output_framerate: 30
##   Output framerate of the generated video
output_path: /root/timelapse/
##   Path where the generated video will be saved
frame_path: /tmp/timelapse/
##   Path where the temporary frames are saved
ffmpeg_binary_path: /usr/bin/ffmpeg
##   set location of ffmpeg binary
time_format_code: %Y%m%d_%H%M
##   Manipulates datetime format of the output filename
##   see: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes
snapshoturl: http://localhost:8080/?action=snapshot
##   url to your webcamstream
pixelformat: yuv420p
##   set pixelformat for output video
##   default to yuv420p because eg. yuvj422p will not play on 
##   on most smartphones or older media players
#extraoutputparams: 
##   here you can extra output parameters to FFMPEG 
##   further info: https://ffmpeg.org/ffmpeg.html 
##   eg rotate video by 180° "-vf transpose=2,transpose=2"
##   or repeat last frame for 5 seconds:
##   -filter_complex "[0]trim=0:5[hold];[0][hold]concat[extended];[extended][0]overlay"

this macro is called by the slicer layer change command

[gcode_macro TIMELAPSE_TAKE_FRAME] gcode: {action_call_remote_method("timelapse_newframe")}

#this macro will take snapshots with the printerhead parked. If you want that, add this in your slicer layer cahnge instead
[gcode_macro TIMELAPSE_TAKE_PARKED_FRAME]
gcode:
 SAVE_GCODE_STATE NAME=SNAPSHOT
 G1 E-10 F2100 ;Retract
 G91 ;Relative
 G1 Z5 ;move up 5
 G90 ;Absolute coordinates
 G1 X5 Y205 F6000 ;Move away from the print

 G4 P500 ;Wait for 500ms
 TIMELAPSE_TAKE_FRAME ;Take frame
 G4 P500 ;Wait for 500ms
 G1 E10 F2100 ;Extrude back

 RESTORE_GCODE_STATE NAME=SNAPSHOT MOVE=1 MOVE_SPEED=6000

#this macro allows you to render the timelapse if the print has failed or if `autorender` is set to `False`
[gcode_macro TIMELAPSE_RENDER]
gcode:
 {action_call_remote_method("timelapse_render")}