Norns screen capture
| local Screencap = {} | |
| -- requires apng assmebler built from source | |
| -- available here: http://apngasm.sourceforge.net | |
| function Screencap.record(fps, duration, output_path) | |
| local timer = 0 | |
| local delay_s = 1/fps | |
| local frame_count = 0 | |
| local tempDir = "frames" | |
| local tempName = "frame" | |
| local apngasm_path = "/home/we/apgnasm/apngasm" | |
| os.execute("mkdir /tmp/"..tempDir) | |
| clock.run( | |
| function() | |
| -- capture each frame | |
| while timer < duration do | |
| _norns.screen_export_png("/tmp/"..tempDir.."/"..tempName..string.format("%04d",frame_count)..".png") | |
| frame_count = frame_count + 1 | |
| timer = timer + delay_s | |
| clock.sleep(delay_s) | |
| end | |
| -- assemble frames | |
| local s = "/tmp/"..tempDir.."/"..tempName.."*.png" | |
| os.execute(apngasm_path.. " " ..output_path.. " " ..s.. " 1 " ..fps) | |
| os.execute("rm -r /tmp/frames") | |
| end | |
| ) | |
| end | |
| return Screencap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment