Created
April 19, 2020 00:57
-
-
Save tlubke/e2c6a6b95bac5817ab2dc7e098906e01 to your computer and use it in GitHub Desktop.
Norns screen capture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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