Videos and infographics made from code
Every video and infographic I make is a program. A program gives the same result each time, including the same mistakes.
Infographics: six steps
- Check the data against the source and flag anything uncertain.
- Build one HTML file in one typeface. Color encodes meaning: green for good, red for bad and gray for neutral. Titles are black and the footer holds the full address of the source.
- Serve the file locally.
- Render the file with Playwright at 1080 pixels wide, full page.
- Look at the rendered image. Measure element rectangles in the browser instead of judging spacing by eye.
- Save the image as a dated file named for the topic.
The hero images for articles on my SafeStreets site come from a script. One shared template takes data for each article, and headless Chrome renders the template. A second script uploads each image, and the site picks up the new address at the next build.
Videos: code from start to finish
Nothing is filmed. Text overlays and synthesized sound effects carry each video.
- Remotion is the main renderer. A React composition describes each scene, and one command renders the scene. Product tours are Playwright captures of the live site with a camera move and a caption band on top.
- Blender renders a top-down street before-and-after in the background. I switched to Blender because 3D built from code looked like programmer art.
- Cesium and MapLibre produce city flythroughs, captured frame by frame in headless Chromium.
- ffmpeg joins the frames into an mp4 file.
- Hyperframes is installed for short clips with preset music and effects.
I build each template in 16:9 and 9:16 together, so one render serves every channel.
Quality gates
- A before-and-after of one street must total the same curb-to-curb width. Otherwise "same width, redesigned" is false.
- Map and tile credits stay on screen, and so does the credit for any borrowed artwork.
- I open every rendered image before I call the image finished.
- No click-bait thumbnails and no all-capitals titles.
Three traps
- Headless 3D rendered blank. Rendering with the ANGLE backend and software GL fixed the problem. An SVG used as a texture came out empty, so I convert each SVG to a PNG first. Textures must be created once, and the render must wait until the images decode.
- Dead space under an infographic. Chrome screenshotted a fixed window that was much taller than the card. I now render at double density in a tall window and crop the empty rows by comparing pixels to the background. Inline SVGs also need explicit width and height, or headless Chromium draws each SVG at 300 pixels.
- One bad capture overwrote a good capture. A 502 error from the site once replaced a good screenshot with a blank image. Capture scripts now retry, and no script trusts a single capture.