Skip to content

saveFrames() does not honor frame rate #7958

Description

@peeter2

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions