p5snap is a command-line interface that creates and saves snapshots of a p5 sketch.
npx p5snap ./path-to-sketch.js