processing/p5.js

saveFrames() does not honor frame rate

Open

#7,958 建立於 2025年7月8日

在 GitHub 查看
 (9 留言) (0 反應) (1 負責人)JavaScript (3,178 fork)batch import
BugHelp Wanted

倉庫指標

Star
 (20,784 star)
PR 合併指標
 (平均合併 9天 8小時) (30 天內合併 56 個 PR)

描述

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.

貢獻者指南