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.
What it tries to do
- 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 rate 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.
How to use
- 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,
- install dependencies
- run it
npm run electron
- You can write p5js and other html/css/js code as usual inside
publicfolder. Take a look at
- All the Chrome keyboard shortcuts work. Refresh by
Cmd+R, toggle console by
- When you press
start recordingbutton, 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
- When you are done and want to package as app
npm run dist
Ctrl+Cin Terminal to quit at any point.
Refer to fluent-ffmpeg documentation for different options you can add to video.
- tested only on Mac.
- If you want to use ffmpeg-included app commercially, be sure to check out their licensing terms.
Copyright © 2019 Dae In Chung
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.