npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

p5.record.js

v0.3.0

Published

p5.js addon providing functions to record HTML canvas based sketches

Downloads

141

Readme

p5.record.js

Record your p5.js sketch and export it as a video or image sequence.

This p5.js addon library provides a simple interface to record your p5.js sketch into a video or image sequence by using the captureStream() or toBlob APIs of HTMLCanvasElement. No external dependencies is included or required with this library.

p5.record.js starts with a set of default configuration that covers the simplest and likely most common use, while also providing additional customization options to achieve additional functionalities:

  • Recording at specific defined frame rate, and in supported browsers, full control over when individual frame capture should happen.
  • Record canvas backed objects, such as p5.Graphics, and HTML canvas directly.
  • Create multiple recordings at the same time.
  • Record image sequence.

Usage

To add p5.record.js to your sketch, include the following script tag in your HTML file:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/p5.record.min.js"></script>

ESM builds are also available either via CDN at https://cdn.jsdelivr.net/npm/[email protected]/dist/p5.record.esm.js or via NPM:

npm install p5.record.js

For different use cases, please check out the examples/ folder. The available p5.js addon functions are as follow:

  • setRecording(options) - Set a configuration for recording, accepts an options object as argument. All options are optional. The default configuration (already set without needing to call setRecording) is as follow:
    options = {
    	frameRate: getTargetFrameRate(),
    	source: canvas.elt,
    	mimeType: "video/webm;codecs=vp8"
    }
    • frameRate - (Number|"manual") If options.frameRate is set to a string with value "manual", sketch recording will automatically be tied to each call of draw(). This is useful when you have set the sketch to noLoop() and is manually calling redraw(), only available in supported browsers.
    • source - An object containing a property of canvas of type HTMLCanvasElement (eg. p5.Graphics instance) or an HTMLCanvasElement.
    • mimeType - The container and codec to be used for recording. Currently only a very small set of containers and codecs are supported natively, it is recommended to leave the default and reencode the video after downloading the result. Set this to image/png, image/jpeg, or image/webp to capture image sequence instead of video, will download a zip file instead.
  • startRecording() - Start recording at specified frame rate.
  • stopRecording() - Stop recording and download the recording file.
  • pauseRecording() - Pause recording to be resumed later.
  • resumeRecording() - Resume previously paused recording.
  • createRecording(options) - Create an independent recorder instance. See the Recorder class below for usage of its return value. Accepts the same options object as setRecording(options) as argument but frameRate and source are required.

The library also provides a p5.Recorder class for multiple simultaneous recording usage. In p5.js sketches, it is recommended to use createRecording(options) factory function to create instance of this class.

Recorder class

  • Constructor - new Recorder(options) accepts the same options object as createRecording(options), ie. frameRate and source are required.
  • state - Recorder state, can be one of "inactive", "recording", or "paused".
  • start() - Start the recording.
  • stop() - Stop the recording.
  • pause() - Pause the recording.
  • resume() - Resume the recording.
  • frame() - Record a single frame, to be used in conjunction with options.frameRate = "manual"

Limitations

This library is only designed for canvas backed sketches and objects, recording of other inputs (eg. SVG) is not supported.

Currently the video recording output format is limited to VP8 encoded WebM video file, depending on use case you may need to reencode the video to a different format.

For image sequence recording, PNG, JPEG, and WebP formats are supported (except for Safari which does not support WebP). The image sequence will be downloaded as a Zip file with no compression applied. When capturing image sequence, you are more likely to encounter physical limits such as RAM limits or Zip file limits (archive size is currently limited to 4GB and 65,535 entries, I may implement ZIP64 later but it is a little bit less commonly supported, you may run out of RAM first anyway).

Future features

  • Custom output video formats
  • Record as gif