Render CSS keyframe animations with Takumi and encode them into an H.265 (HEVC) MP4 file using ffmpeg.
-
A scene is built once and exports structured
keyframesobjects alongside the JSX. -
For each frame
ithe renderer is called with:timeMs = (i / fps) * 1000;
This advances the animation clock by exactly one frame period, so
animation-duration,animation-delay,animation-iteration-count, etc. all work as expected. -
render()is called withformat: "raw"which returns raw RGBA pixels. -
Each frame buffer is written directly to ffmpeg's stdin.
-
ffmpeg encodes the stream to H.265 (
libx265) and writes the output MP4.
bun install
bun src/index.tsThe output video will be written to output/animation.mp4.
Photo by Martin Martz on Unsplash