I tried to make it so that even if you have never used Node/Electron, you should be able to use this boilerplate. This is the first app I made using Node or Electron, so if you have any suggestions or comments, please let me know.
- Save unlimited number of frames from your p5js sketch. (p5 by default can save up to 15 frames. see here)
- Export image sequence and video files in a single app.
- No need to use screen capture software. (No frame drops)
- No need to use video editing software.
- It uses ffmpeg for video encoding which adds a lot of customizability.
- Ffmpeg is included as static binary. No need to install separately. A downside is that each project will have its own binary file which makes the whole project significantly bigger.
- Once packaged, no need to use command line at all.
- Recording demonstration video - it only records what's on HTML5 canvas, so any sliders on HTML DOM won't be recorded.
- Real time interaction - the frame rate may drop while recording depending on the complexity of your sketch.
- download or clone this repo.
- install node for your system. The simplest way is to go to https://nodejs.org and download/install the package.
- open Terminal app.
- Change directory to the downloaded folder. If you have downloaded to desktop,
cd desktop/p5js-electron-canvas-saver-boilerplate
- install dependencies
npm install
- run it
npm run electron
- You can write p5js and other html/css/js code as usual inside
public
folder. Take a look atindex.js
as well. - All the Chrome keyboard shortcuts work. Refresh by
Cmd+R
, toggle console byCmd+Opt+I
. - When you press
start recording
button, it will start recording PNG images, and when you press the button again, it will stop saving images and start converting the images to video file. You can check the progress from the browser console (or Terminal). - By default, files rendered are saved to
downloads
folder. - When you are done and want to package as app
npm run dist
- press
Ctrl+C
in Terminal to quit at any point.
Refer to fluent-ffmpeg documentation for different options you can add to video.
p5.js
library is loaded from CDN - if you need to load from a local file, include thep5.js
(or any other library files) inpublic
folder and link it inpublic/index.html
- tested only on Mac.
- If you want to use ffmpeg-included app commercially, be sure to check out their licensing terms.
- p5js
- electron
- electron-builder
- fluent-ffmpeg
- ffmpeg-static: Mac binary comes from here
MIT