Code-Driven Stickman Animation: A Low-Cost, High-Control Pipeline for Short-Form Video Production

    This article presents a practical, code-driven pipeline for producing explainer-style short videos using stickman animation. It explains why pure AI video generation struggles with character consistency and repeated revision costs, then shows how to package skeleton rules and motion logic into a reusable `stickman-animator` Skill built around `SKILL.md`, `engine.js`, and `export-mp4.js`. You will see how single-angle joint control, locked RIG parameters, and frame-by-frame interpolation keep proportions stable, how headless browser rendering plus FFmpeg exports a 15-second 720P/60 FPS MP4 in about 52.2 seconds, and how the full workflow costs roughly $0.54 per video with near-zero cost for line edits.

    1. Introduction: The Bottleneck in Short-Form Video Production for Independent Developers

    For independent developers and overseas content teams, budgets are tight and explainer videos often need to be produced at high frequency. Traditional AI video generation models show impressive creativity, but in real production workflows they expose two critical weaknesses. First, characters frequently “break”: because probabilistic diffusion models are hard to control when handling complex motion, faces and bodies deform, distort, or lose proportion between shots. Second, re-rolling is expensive: changing a single line of dialogue or tweaking one motion detail forces you to call the model again, which adds cost and slows iteration dramatically.

    The industry has also long struggled with a lack of standardized AI toolchains. Notably, there is precedent for donating coding agent skills to an open-source foundation; by being integrated across many platforms, such standards are helping solve the “no workflow” problem in AI tasks.

    To address these pain points, this article introduces a fully code-generated Stickman Animation Pipeline. As a typical example of vector graphics and procedural animation, stickman animation uses minimal lines and precise skeletal representation, making it a highly cost-effective visual medium for explainer videos. By dropping video generation models and rendering with code instead, a 15-second video at 60 FPS can be produced for about $0.54, and the “pay again to change a line” cycle disappears entirely.

    2. Environment Setup and a Cautionary Example: Why Writing Raw Model Prompts Fails

    Before building the automated workflow, prepare the base runtime. Core dependencies include the Node.js runtime (for running scripts and calling interfaces), FFmpeg (for video stream processing and encoding), and a local browser (such as a Chromium-based browser for headless rendering).

    Before adopting a standardized approach, consider the cautionary example: what happens when a large model generates animation code with no preset Skill specification.

    1. Randomness and Lack of Control

    Without a Skill, the model relies only on pretrained knowledge and improvises. Lacking explicit mathematical constraints, the generated skeleton proportions are often distorted—for example, arm lengths vary and joint positions are arbitrary.

    2. No Unified Baseline

    Without a standardized RIG (skeletal rigging) specification, parameters such as character height and arm span float in the code. This causes a serious problem: when the camera cuts or the motion changes, the character’s body instantly “warps” (distortion), hurting visual professionalism.

    Therefore, to keep motion from ever breaking, the “skeleton baseline” and “motion rules” must be packaged into a reusable Skill module.

    3. Core Architecture: Building the stickman-animator Skill Module

    To let an AI coding assistant generate animation precisely and reliably, create a local Skill module named stickman-animator. The module is clearly structured around three core files:

    • SKILL.md: Defines the Skill metadata, trigger conditions, and skeleton parameter specification.
    • engine.js: The low-level skeleton rendering library, including coordinate calculation and interpolation logic.
    • export-mp4.js: The fast recording and export script that drives browser rendering and captures frame data.

    1. Low-Level Math: Polylines and Single-Joint Control

    The underlying logic of code-driven animation is simple and efficient. Geometrically, a stickman’s torso and limbs are essentially polylines, where each vertex corresponds to a joint.

    To simplify control, we specify single angle control per joint. This dimensionality reduction turns animation logic from complex 3D skeletal skinning into simple 2D polar-coordinate calculation.

    2. RIG Parameters and Interpolation

    In SKILL.md, lock down the base skeleton parameters (RIG):

    • Bone Length: For example, head radius, torso length, and the thigh-to-shin ratio must be fixed.
    • Visual Parameters: Decorative elements such as glasses must be bound to the head coordinate system and move in sync as the head turns.

    In engine.js, implement frame-by-frame rendering. Through angle interpolation per joint, the system computes intermediate-frame angles from keyframes, then uses fixed bone lengths and trigonometry to derive each joint’s $(x, y)$ coordinates. As long as bone lengths are locked, the character’s proportions stay 100% consistent regardless of camera cuts or intense motion.

    1. // engine.js core pseudocode example
    2. const RIG = { head: 0.5, torso: 1.2, limb: 0.8 };
    3. function calculateJoint(basePos, angle, boneLength) {
    4. return {
    5. x: basePos.x + Math.cos(angle) * boneLength,
    6. y: basePos.y + Math.sin(angle) * boneLength
    7. };
    8. }
    9. // Loop over each frame and update every joint angle
    10. for (let frame = 0; frame < totalFrames; frame++) {
    11. const currentAngle = interpolateAngle(frame, keyframes);
    12. renderStickman(calculateJoint(...), currentAngle);
    13. }

    4. Hands-On: Generating and Iterating a 15-Second Animation

    Using this Skill, build a 15-second animation video with three scenes (v2-skill.html).

    1. Automated Recognition and Generation

    When you instruct a Skill-capable coding tool to “generate a video using the stickman-animator Skill,” the system automatically recognizes and loads the Skill.

    The output is strong: the stickman is well-proportioned, the animation runs stably at 60 FPS, and bilingual Chinese-English subtitles render at the bottom in sync. This shows that with Skill constraints, AI has shifted from “random drawing” to “industrial-grade animation production.”

    2. Extremely Fast Code Iteration

    The biggest advantage of code-driven animation is that changing code changes the video, with no need to re-render a physical world. Suppose you need to:

    • Add a floating “-$” text effect in scene 2;
    • Add a “60FPS / $0” cost badge in scene 3.

    You only need to modify keyframes or add an overlay rendering layer, and the AI tool typically completes the code update within about a minute and a half. Because the low-level skeleton engine is untouched, the character’s skeleton is unaffected—achieving a clean decoupling where “effects vary while the core stays constant.”

    5. Video Export and Rendering Performance

    Once the web animation (HTML5 Canvas or SVG) is built, convert it to a standard video format for uploading to video platforms.

    1. Headless Rendering Architecture

    In export-mp4.js, use headless browser mode. The script loads the page state frame by frame, captures a screenshot stream, and pipes it directly to FFmpeg for encoding. The process uses no cloud GPU resources and consumes only local CPU.

    2. Performance Metrics

    In testing, a 15-second, 720P, 60 FPS video (900 frames total) took only 52.2 seconds from render start to final export, producing an MP4 of just 0.81 MB. This high encoding efficiency makes batch processing feasible.

    6. Cost Breakdown and Comparison

    For an independent developer, cost is a key dimension of feasibility.

    1. Real Expense Accounting

    The entire development round (initial generation, multiple rounds of revision dialogue, and export testing) accumulated a total API spend of only $0.54. This means the per-video cost of the code approach is nearly zero, with the main expense being the large-model token consumption for writing code.

    2. Side-by-Side Comparison

    To show the advantage more clearly, compare the code generation flow with common high-quality video generation offerings on the market (such as a cloud vendor’s Gen-3 video generation service or a video platform’s Ray 3 service):

    Approach Cost per 15s video Monthly cost for 30 videos Cost to change one line Character consistency
    Code generation flow (Skill) $0.54 $16.20 $0 (edit code, re-export in 52s) 100% stable
    Industry option A (Runway-like) $0.75 $22.50 Pay to re-roll (+$0.75) Prone to shot drift
    Industry option B (Luma-like) ~$2.88 $86.40 Pay to re-roll (+$2.88) Prone to face breaks and mix-ups

    Note: Industry options are estimated comparisons based on publicly available pricing.

    3. Conclusion and Recommendation

    The table makes the following clear:

    • Cost advantage: For high-frequency monthly production (30 videos), the code approach saves several times to ten times the cost compared with expensive video generation services.
    • Control advantage: With video generation models, changing one line means paying to re-roll, with random results; with the pure code approach, changing a line only involves editing two lines of code (swapping a string), and export finishes in 52 seconds, with the character skeleton never breaking at the logic level.

    In summary, for cost-effective, high-iteration explainer short-video production, the “Skill + pure code engine” route is the optimal solution today, both economically and in engineering stability.