-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
I am drawing an animation on canvas.
function setup() {
canvas = createCanvas(400, 450, WEBGL);
frameRate(20);
I see faster speed when my laptop is charging. When I unplug the power cable, the draw on canvas is much slower.
This impacts the saveFrames function. How can I save the certain duration worth of frames if the duration depends on whether the device is plugged in or not? When plugged in, a lot more frames are saved than when not charging, even though the 'duration' is for example 2 seconds.
saveFrames('frame', 'jpg', duration, fps)
So using saveFrames() how can I reliably save the certain amount of frames despite the speed change?
Works fine with saveGif('test', 2);
I get exactly 2 seconds long video, 40 frames total, no matter what device, it does not depend on the device speed. It honors the frameRate() set in setup(), and p5.js pauses the sketch's draw loop during recording.
It will capture exactly the number of frames implied by the duration × framerate, regardless of actual performance.
I need to save the 2 second duration amount of frames also using saveFrames(). Currently it seems to be buggy.
It does not pause or slow down the draw loop, and records frames in real time for the given duration.
If the system is underpowered (on battery), draw() runs slower, resulting in fewer total frames captured than expected.