explaingit

spite/ccapture.js

3,758JavaScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

CCapture.js is a JavaScript library that records canvas-based browser animations at a perfectly smooth, fixed frame rate by taking control of the browser's timing, regardless of how slow the rendering actually is.

Mindmap

mindmap
  root((ccapture.js))
    What it does
      Record canvas animations
      Fixed frame rate capture
      Override browser timing
    Output Formats
      WebM video
      Animated GIF
      PNG or JPEG frames
      Server-side ffmpeg
    How it works
      Intercepts timing functions
      Controlled clock per frame
      Decoupled from real time
    Setup
      Script tag include
      npm install
      Wrap animation loop
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Record a computationally expensive Three.js or p5.js canvas animation as a smooth 60fps WebM video, even if each frame takes several seconds to render.

USE CASE 2

Export a canvas animation as a sequence of PNG images packaged in a TAR archive for video editing in post-production.

USE CASE 3

Capture a canvas animation as an animated GIF directly in the browser without any external software.

USE CASE 4

Send high-frame-rate canvas frames to a server-side ffmpeg process for high-quality video encoding.

Tech stack

JavaScriptWebGLHTML Canvas

Getting it running

Difficulty · easy Time to first run · 30min

Your animation must use elapsed-time-based movement rather than fixed per-frame steps, or the recorded output will not be correct.

License terms are not specified in the explanation.

In plain English

CCapture.js is a JavaScript library for recording canvas-based animations in the browser at a fixed, consistent frame rate. The problem it solves is that ordinary screen recording software captures whatever the screen actually shows in real time. If your animation is computationally expensive and runs slower than intended, the recording will also look slow and choppy. CCapture.js works differently: it intercepts the browser's internal timing functions and replaces them with a controlled clock, so each frame is rendered at exactly the right interval regardless of how long it actually takes to compute. This means you can push rendering quality as high as your hardware allows, take as long as needed per frame, and the resulting video will play back at a perfectly smooth 30 or 60 frames per second. You can also capture at higher frame rates like 240fps and then apply motion blur in video editing software afterward. The library supports several output formats. It can produce a WebM video file, an animated GIF, or a collection of PNG or JPEG images packaged in a TAR archive. There is also an option to send frames to a server-side ffmpeg process for video encoding. You add the library to a page via a script tag or install it with npm, then wrap your existing animation loop with three calls: start capturing, pass the canvas element to capture after each frame, and stop and save when done. The configuration options let you set the target frame rate, output quality, a time limit for automatic stopping, and whether to auto-save periodically during long captures. The README notes several limitations. The WebM format depends on browser support for the webp image format, which at the time of writing made it effectively Chrome-only. The GIF encoder has performance constraints and may struggle with long or large captures. Very large output files can also cause issues in some browsers due to memory limits. The library requires that your animation already uses elapsed-time-based movement rather than fixed per-frame increments. If your animation steps by a constant amount each frame rather than by the time that has passed, CCapture.js will not produce correct output.

Copy-paste prompts

Prompt 1
I have a Three.js animation loop. Show me how to wrap it with CCapture.js to record a 10-second WebM video at 60fps.
Prompt 2
Using CCapture.js, how do I capture a p5.js sketch as a sequence of PNG frames and download them as a TAR file?
Prompt 3
What does CCapture.js require my animation to do differently, specifically around elapsed-time-based movement, so that it captures correctly?
Prompt 4
How do I set up CCapture.js to auto-stop and save after recording exactly 5 seconds of a canvas animation?
Open on GitHub → Explain another repo

← spite on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.