D3 frames to video
This example shows a rotating orthographic globe with countries filled in rainbow colors, rendered as a 600-frame animation that spins smoothly. The visualization displays world geography from TopoJSON data, with each country’s fill color cycling through a rainbow palette based on its index and frame number. The code uses D3’s `geoOrthographic` projection and `geoPath` to draw the globe, countries, and borders onto an HTML5 Canvas via the `canvas` npm package. Frames are piped directly to FFmpeg, which encodes them into an MP4 video at 20 frames per second, demonstrating a headless workflow for creating D3 animations.
AI-generated descriptionThis amazing script by Noah Veltman allows to create videos from d3.
install
npm install canvas topojson d3 rw
run
node draw.js | ffmpeg -y -c:v png -f image2pipe -r 20 -i - -an -c:v libx264 -pix_fmt yuv420p -movflags +faststart myvideo.mp4