Save a sketch to video with p5.js

Use the CCapture JavaScript library to compile the frames from your p5.js sketch into a webm file, and then convert this webm file to MP4 (or other useful formats) using FFmpeg.

Source