KlipperWrt icon indicating copy to clipboard operation
KlipperWrt copied to clipboard

[guide] Add timelapse instructions

Open ihrapsa opened this issue 3 years ago • 0 comments

Update guide with instructions to install timelapse moonraker component + dependencies

  • Download packages from packages/ffmpeg in my repo (make sure you don't clone into /tmp)
  • ❗ reboot the box -> DO NOT DO opkg update
  • cd to that folder and do opkg install *ipk
  • install wget-ssl with opkg update && opkg install wget-ssl
  • download timelapse.py into /root/moonraker/moonraker/components:
wget https://github.com/FrYakaTKoP/moonraker/raw/dev-timelapse/moonraker/components/timelapse.py -P /root/moonraker/moonraker/components
  • Put this inside moonraker.conf. Uncomment
# 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"
  • macros into your printer.cfg:
#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")}
  • Follow instructions from here to configure your slicer for timelapse
  • To disable autorendering of the video (that is done immediately after the print finishes) set autorender: False undermoonraker.conf [timelapse] block. You'll be able to render it with TIMELAPSE_RENDER macro afterwards or you can copy the frames from /tmp/timelapse to your pc (with WinSCP) and render them there faster.
  • ❗ If you reboot the box frames from /tmp/timelase will be erased so copy them before rebooting.

ihrapsa avatar Jun 18 '21 08:06 ihrapsa