Rendering a looping animation to video: save each frame and call exit() at a target frameCount
To export a Processing sketch as video, Rodenbröker reuses a portable ‘rec’ snippet (a PDE tab dropped onto the sketch) that saves the sketch window’s output one frame per draw loop, then stops the sketch when frameCount reaches a target. For a 12-second clip at 30fps that target is 360 frames: if (frameCount == 360) exit();. Using a frameCount limit (rather than a wall-clock timer) guarantees an exact frame count regardless of render speed — important because per-pixel CPU rendering can run far slower than real time, so each frame is captured correctly even if the sketch is slow. This decouples authoring the animation from exporting it.
Examples
if (frameCount == 360) { exit(); } // stops after exactly 360 saved frames = 12s at 30fps
Assessment
Why stop the export at a fixed frameCount rather than after a wall-clock duration, given that per-pixel rendering may run slower than real time?