Build a Low-Cost Short-Video Pipeline with Reusable AI Skill Packages

    This article explains why generative video models often become the bottleneck in high-volume short-video production, and how to replace random generation with a spec-driven, code-based workflow. It shows how to package skeleton ratios, joint limits, keyframes, and export rules into a reusable skill (SKILL.md, engine.js, render.js, index.html), set up Node.js, FFmpeg, and Playwright, and render a 15-second 1080p 60fps stickman animation as an MP4. It also includes a failure-mode comparison, a marginal-cost breakdown with explicit exclusions, and a troubleshooting table for common rendering and encoding issues.

    Build a Low-Cost Short-Video Pipeline with Reusable AI Skill Packages

    1. Why low-cost short video usually breaks at the toolchain

    Up front: for teams doing high-volume short-video production, overseas content, or low-cost animation, what actually slows delivery is rarely topic selection. It is the randomness that has to be paid for on every run, plus the inability to reproduce a character reliably.

    Many teams start by calling a generative video model directly. It looks effortless at first, but the problems scale fast once you move into stable production. Monthly quotas of a few tens of dollars, or a few hundred credits, are not unusual on pay-per-generation video services — though how many clips that buys depends on the model, resolution, duration, retry count, and how the platform bills. Treat it as a variable, not a fixed fact for every scenario. Any dissatisfaction triggers a regeneration: change one line of dialogue, switch a pose, adjust a shot, and the whole clip may have to be redone.

    Character consistency is the more serious issue. Faces break, identities drift between shots, proportions distort, and the same character cannot be reproduced reliably, which makes scaling post-production nearly impossible. The root cause is that the model is allowed to improvise every time. With no skeleton baseline, no motion constraints, and no output specification, quality is left to chance. Costs become unpredictable and delivery becomes unstable.

    Real cost reduction means changing the creative pipeline from “generate randomly” to “execute against a spec.”

    2. Packaging a repeatable creative workflow as an AI skill

    The key move is to package repeatable, well-specified creative workflows into a reusable skill. This article uses an engineering-style skill convention that is close in spirit to SKILL.md, Agent Skills, and the Model Context Protocol (MCP), but it is not an official certified standard. The idea is to bundle domain specification, scripting tools, and calling conventions together, so an AI coding assistant or an automation script follows defined rules instead of improvising from scratch each time.

    The pipeline built here is a purely code-driven stickman animation pipeline. Instead of relying on a generative video model, it draws the skeleton in code, drives the joints, renders a frame sequence, and then muxes the frames into a final video with an encoder. The marginal cost per clip is therefore closer to local compute, and changing a line of dialogue no longer requires another round of lottery tickets.

    This pipeline fits several kinds of content:

    • Talking-head knowledge explainers
    • Product walkthroughs
    • Process demonstrations
    • Light narrative shorts
    • FAQ animations
    • Batch generation of localized videos for overseas markets

    It is not suited to photoreal humans, complex physics, or film-grade VFX. Stickman and flat code animation win on stability, controllability, and batch output — not photorealism.

    3. Prerequisites: setting up Node, FFmpeg, and Playwright

    Pin the runtime, the browser automation tool, and the video encoder before you start, so rendering and muxing stay consistent later.

    Recommended versions:

    • Node.js: 18 LTS or 20 LTS; 18.20+ recommended.
    • npm: bundled with Node.js.
    • FFmpeg: 6.1+, used to mux the frame sequence into video.
    • Playwright: 1.44+, used to drive Chromium for frame-by-frame screenshots.
    • Chromium: installed by Playwright.

    On macOS or Linux, install Node.js with:

    1. nvm install 18
    2. nvm use 18
    3. node -v
    4. npm -v

    On Windows, use winget:

    1. winget install OpenJS.NodeJS.LTS
    2. node -v
    3. npm -v

    Install FFmpeg:

    1. # macOS
    2. brew install ffmpeg
    3. ffmpeg -version
    4. # Debian / Ubuntu
    5. sudo apt install ffmpeg
    6. ffmpeg -version
    7. # Windows
    8. winget install Gyan.FFmpeg
    9. ffmpeg -version

    Initialize the project and install Playwright:

    1. mkdir stickman-animator && cd stickman-animator
    2. npm init -y
    3. npm i playwright@^1.44.0
    4. npx playwright@1.44.0 install chromium

    Recommended directory structure:

    1. skills/stickman-animator/
    2. ├── SKILL.md
    3. ├── engine.js
    4. ├── render.js
    5. ├── index.html
    6. ├── frames/
    7. ├── output/
    8. └── package.json
    • SKILL.md: the specification document — characters, skeleton proportions, motion rules, output specs.
    • engine.js: the rendering library — skeleton drawing, joint constraints, keyframes.
    • render.js: the export script — frame-by-frame screenshots and video muxing.
    • index.html: the preview page, loading the canvas and the engine script.
    • frames/: the PNG frame sequence.
    • output/: the final MP4.

    4. Counter-example: what goes wrong without a spec

    Without a specification, output can look runnable but is not reusable and cannot be iterated on reliably.

    Suppose you give the model no constraints and simply ask for a single-page stickman explainer animation of roughly 15 seconds on “the pain points of a one-person company making short videos for overseas markets,” with 3 shots at 16:9 landscape.

    The tool may produce a single-file web page that does contain cards for topic selection, shooting, and editing. Once you play it in the browser, the problems surface quickly:

    • The head-to-body proportions are extremely stiff.
    • The arm lines are skewed and the joint positions are unstable.
    • Animation logic, styling, and structure are all mixed into the same file.
    • Change one shot or one pose and the figure immediately deforms.

    Each of these maps to a concrete fix:

    Counter-example problem Corresponding fix
    Stiff head-to-body proportions Fix the skeleton proportions in SKILL.md and engine.js
    Skewed arm lines Constrain joint angles with jointLimit
    Abrupt motion jumps Use easing functions and keyframe interpolation
    Styling and structure mixed together Separate the rendering library, export script, and content data
    No batch generation Extract shots and copy into a parameterized config

    This is the typical symptom of working without a spec: every run is improvisation, and skeleton proportions have no mathematical baseline. Change a shot or a pose and the figure immediately deforms — reuse and scaling are off the table.

    5. Building the stickman animation skill: the actual steps

    To make character motion stable, the skeleton baseline and the motion rules must be baked into a skill package.

    The skill structure:

    1. skills/stickman-animator/
    2. ├── SKILL.md # Specification: skeleton proportions, motion rules, calling conventions
    3. ├── engine.js # Rendering library: fixed skeleton + keyframes + smooth joint animation
    4. ├── render.js # Export script: drive the browser for screenshots + encode
    5. └── index.html # Minimal preview page

    5.1 SKILL.md: fixing the spec in text

    SKILL.md is the constitution of the skill package. It defines four groups of conventions:

    • Protagonist: for example, “a stickman programmer with black-framed glasses.”
    • Skeleton proportions: head-to-body ratio, limb lengths, and joint positions defined as fixed numbers.
    • Motion rules: which joints can move, their rotation ranges, and how easing curves are chosen.
    • Output conventions: frame rate, canvas size, file naming.

    Example:

    1. # Stickman Animator
    2. ## Character
    3. A stickman programmer with black glasses.
    4. ## Skeleton
    5. - Head radius: 0.08 of canvas height
    6. - Torso: 0.28 of canvas height
    7. - Upper arm: 0.16 of canvas height
    8. - Forearm: 0.14 of canvas height
    9. - Thigh: 0.20 of canvas height
    10. - Shin: 0.18 of canvas height
    11. ## Angle Semantics
    12. - shoulder, elbow, hip, knee angles are relative to parent joint.
    13. - headTilt is an absolute head rotation in degrees.
    14. ## Output
    15. - FPS: 60
    16. - Canvas: 1920x1080
    17. - Format: MP4, H.264
    18. - Frame naming: frame_%06d.png

    With this in place, the model or an automation script no longer “imagines” the character — it draws strictly to spec.

    5.2 engine.js: fixing the skeleton, handling headTilt and relative angles

    Making proportions constants, clamping angles, and unifying easing significantly lowers the probability of character breakage — though complex motion still needs tuning.

    A note on angle semantics: fields such as shoulderLeft, elbowLeft, hipLeft, and kneeLeft are angles relative to the parent joint, not absolute world angles. drawChain accumulates the parent joint angle internally, then computes the next limb segment. headTilt is drawn as a rotation of the head.

    To avoid KEYFRAMES being undefined when index.html is loaded, KEYFRAMES is placed in engine.js. That way the page only needs to load engine.js in order and it runs immediately.

    Pose input format:

    1. const pose = {
    2. headTilt: 0,
    3. shoulderLeft: -20,
    4. elbowLeft: 10,
    5. shoulderRight: 20,
    6. elbowRight: -10,
    7. hipLeft: -5,
    8. kneeLeft: 0,
    9. hipRight: 5,
    10. kneeRight: 0
    11. };

    Runnable engine.js:

    1. // engine.js
    2. const SKELETON = {
    3. headRadius: 0.08,
    4. torso: 0.28,
    5. upperArm: 0.16,
    6. foreArm: 0.14,
    7. thigh: 0.20,
    8. shin: 0.18,
    9. jointLimit: {
    10. headTilt: [-20, 20],
    11. shoulderLeft: [-120, 120],
    12. elbowLeft: [0, 150],
    13. shoulderRight: [-120, 120],
    14. elbowRight: [0, 150],
    15. hipLeft: [-80, 80],
    16. kneeLeft: [0, 140],
    17. hipRight: [-80, 80],
    18. kneeRight: [0, 140]
    19. }
    20. };
    21. const KEYFRAMES = [
    22. {
    23. t: 0,
    24. pose: {
    25. headTilt: 0,
    26. shoulderLeft: -20,
    27. elbowLeft: 10,
    28. shoulderRight: 20,
    29. elbowRight: -10,
    30. hipLeft: -5,
    31. kneeLeft: 0,
    32. hipRight: 5,
    33. kneeRight: 0
    34. }
    35. },
    36. {
    37. t: 1,
    38. pose: {
    39. headTilt: 8,
    40. shoulderLeft: 60,
    41. elbowLeft: 30,
    42. shoulderRight: -60,
    43. elbowRight: -30,
    44. hipLeft: -15,
    45. kneeLeft: 20,
    46. hipRight: 15,
    47. kneeRight: 0
    48. }
    49. }
    50. ];
    51. const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
    52. function easeInOutCubic(t) {
    53. return t < 0.5
    54. ? 4 * t * t * t
    55. : 1 - Math.pow(-2 * t + 2, 3) / 2;
    56. }
    57. function lerp(a, b, t) {
    58. return a + (b - a) * t;
    59. }
    60. function samplePose(keyframes, progress) {
    61. let a = keyframes[0];
    62. let b = keyframes[keyframes.length - 1];
    63. for (let i = 0; i < keyframes.length - 1; i++) {
    64. if (progress >= keyframes[i].t && progress <= keyframes[i + 1].t) {
    65. a = keyframes[i];
    66. b = keyframes[i + 1];
    67. break;
    68. }
    69. }
    70. const span = b.t - a.t || 1;
    71. const local = easeInOutCubic(clamp((progress - a.t) / span, 0, 1));
    72. const out = {};
    73. for (const key of Object.keys(b.pose)) {
    74. const from = a.pose[key] ?? 0;
    75. const to = b.pose[key] ?? 0;
    76. out[key] = lerp(from, to, local);
    77. }
    78. return out;
    79. }
    80. function clampPose(pose) {
    81. const out = {};
    82. for (const [key, value] of Object.entries(pose)) {
    83. const limit = SKELETON.jointLimit[key] || [-180, 180];
    84. out[key] = clamp(value, limit[0], limit[1]);
    85. }
    86. return out;
    87. }
    88. function poseAt(keyframes, progress) {
    89. return clampPose(samplePose(keyframes, progress));
    90. }
    91. function rad(deg) {
    92. return deg * Math.PI / 180;
    93. }
    94. function pointFrom(origin, angle, length) {
    95. return {
    96. x: origin.x + Math.sin(rad(angle)) * length,
    97. y: origin.y + Math.cos(rad(angle)) * length
    98. };
    99. }
    100. function drawChain(ctx, origin, angles, lengths, parentAngle = 0) {
    101. let current = origin;
    102. let absoluteAngle = parentAngle;
    103. for (let i = 0; i < angles.length; i++) {
    104. absoluteAngle += angles[i];
    105. const next = pointFrom(current, absoluteAngle, lengths[i]);
    106. ctx.beginPath();
    107. ctx.moveTo(current.x, current.y);
    108. ctx.lineTo(next.x, next.y);
    109. ctx.stroke();
    110. current = next;
    111. }
    112. }
    113. function drawStickman(ctx, width, height, pose) {
    114. const p = clampPose(pose);
    115. const hip = { x: width * 0.5, y: height * 0.58 };
    116. const torso = SKELETON.torso * height;
    117. const shoulder = { x: hip.x, y: hip.y - torso };
    118. const headRadius = SKELETON.headRadius * height;
    119. const headCenter = {
    120. x: shoulder.x,
    121. y: shoulder.y - headRadius * 1.15
    122. };
    123. ctx.lineWidth = Math.max(4, height * 0.008);
    124. ctx.strokeStyle = "#111111";
    125. ctx.lineCap = "round";
    126. ctx.save();
    127. ctx.translate(headCenter.x, headCenter.y);
    128. ctx.rotate(rad(p.headTilt));
    129. ctx.beginPath();
    130. ctx.arc(0, 0, headRadius, 0, Math.PI * 2);
    131. ctx.stroke();
    132. ctx.restore();
    133. ctx.beginPath();
    134. ctx.moveTo(shoulder.x, shoulder.y);
    135. ctx.lineTo(hip.x, hip.y);
    136. ctx.stroke();
    137. drawChain(
    138. ctx,
    139. shoulder,
    140. [p.shoulderLeft, p.elbowLeft],
    141. [SKELETON.upperArm * height, SKELETON.foreArm * height]
    142. );
    143. drawChain(
    144. ctx,
    145. shoulder,
    146. [p.shoulderRight, p.elbowRight],
    147. [SKELETON.upperArm * height, SKELETON.foreArm * height]
    148. );
    149. drawChain(
    150. ctx,
    151. hip,
    152. [p.hipLeft, p.kneeLeft],
    153. [SKELETON.thigh * height, SKELETON.shin * height]
    154. );
    155. drawChain(
    156. ctx,
    157. hip,
    158. [p.hipRight, p.kneeRight],
    159. [SKELETON.thigh * height, SKELETON.shin * height]
    160. );
    161. }
    162. if (typeof window !== "undefined") {
    163. window.SKELETON = SKELETON;
    164. window.KEYFRAMES = KEYFRAMES;
    165. window.poseAt = poseAt;
    166. window.drawStickman = drawStickman;
    167. }

    With this, poseAt(KEYFRAMES, progress) returns a stable pose that has already been angle-clamped and easing-interpolated.

    5.3 render.js: safe export and muxing

    Fix the frame rate, canvas, naming rule, and the encode command in the export script; that is what makes the pipeline genuinely repeatable.

    Export targets:

    • Canvas: 1920×1080, 16:9.
    • Frame rate: 60fps.
    • Duration: 15 seconds.
    • Total frames: 15 × 60 = 900.
    • Frame names: frame_000000.png to frame_000899.png.
    • Time step: 1 / 60 second per frame.
    • Output: output/stickman_15s.mp4.

    Before deleting the frames and output directories, the script checks that the current directory contains package.json and index.html, and it only allows deleting those two fixed project directories, to avoid wiping unrelated data.

    render.js:

    1. // render.js
    2. const { chromium } = require("playwright");
    3. const { execSync } = require("child_process");
    4. const fs = require("fs");
    5. const path = require("path");
    6. const FPS = 60;
    7. const WIDTH = 1920;
    8. const HEIGHT = 1080;
    9. const DURATION = 15;
    10. const projectRoot = process.cwd();
    11. const requiredFiles = ["package.json", "index.html"];
    12. for (const file of requiredFiles) {
    13. if (!fs.existsSync(path.join(projectRoot, file))) {
    14. throw new Error(
    15. file +
    16. " not found. Run this from the project root so other directories are not deleted by mistake."
    17. );
    18. }
    19. }
    20. const targets = [
    21. { name: "frames", dir: path.resolve("frames") },
    22. { name: "output", dir: path.resolve("output") }
    23. ];
    24. for (const item of targets) {
    25. const rel = path.relative(projectRoot, item.dir);
    26. if (rel !== item.name) {
    27. throw new Error(
    28. "Only the project's " +
    29. item.name +
    30. " directory may be deleted; it currently resolves to " +
    31. rel +
    32. "."
    33. );
    34. }
    35. }
    36. fs.rmSync("frames", { recursive: true, force: true });
    37. fs.rmSync("output", { recursive: true, force: true });
    38. fs.mkdirSync("frames", { recursive: true });
    39. fs.mkdirSync("output", { recursive: true });
    40. (async () => {
    41. const browser = await chromium.launch();
    42. const page = await browser.newPage({
    43. viewport: { width: WIDTH, height: HEIGHT },
    44. deviceScaleFactor: 1
    45. });
    46. await page.goto("file://" + path.resolve("index.html"));
    47. const totalFrames = FPS * DURATION;
    48. for (let i = 0; i < totalFrames; i++) {
    49. const progress = i / (totalFrames - 1);
    50. await page.evaluate(({ progress }) => {
    51. window.renderStickmanFrame(progress);
    52. }, { progress });
    53. const frameName =
    54. "frames/frame_" + String(i).padStart(6, "0") + ".png";
    55. await page.screenshot({
    56. path: frameName,
    57. type: "png"
    58. });
    59. }
    60. await browser.close();
    61. const ffmpegCommand =
    62. "ffmpeg -y -start_number 0 -framerate " +
    63. FPS +
    64. " -i frames/frame_%06d.png" +
    65. " -c:v libx264" +
    66. " -pix_fmt yuv420p" +
    67. " -crf 20" +
    68. " -movflags +faststart" +
    69. " output/stickman_15s.mp4";
    70. execSync(ffmpegCommand, { stdio: "inherit" });
    71. })();

    One more note: if Playwright is affected by browser policy under file://, start a local static server — for example npx serve . or python3 -m http.server — and change page.goto() to the corresponding http://127.0.0.1 address.

    5.4 index.html: the minimal runnable page

    index.html must respect script order: load engine.js first, then define renderStickmanFrame. Since KEYFRAMES already lives in engine.js, it does not need to be redefined here.

    1. <!doctype html>
    2. <html>
    3. <head>
    4. <meta charset="utf-8" />
    5. <style>
    6. html, body {
    7. margin: 0;
    8. padding: 0;
    9. background: #fff;
    10. }
    11. canvas {
    12. display: block;
    13. }
    14. </style>
    15. </head>
    16. <body>
    17. <canvas id="canvas" width="1920" height="1080"></canvas>
    18. <script src="engine.js"></script>
    19. <script>
    20. const canvas = document.getElementById("canvas");
    21. const ctx = canvas.getContext("2d");
    22. window.renderStickmanFrame = function (progress) {
    23. ctx.clearRect(0, 0, canvas.width, canvas.height);
    24. const pose = window.poseAt(window.KEYFRAMES, progress);
    25. window.drawStickman(ctx, canvas.width, canvas.height, pose);
    26. };
    27. </script>
    28. </body>
    29. </html>

    Run it:

    1. node render.js

    When it finishes, the final video is at output/stickman_15s.mp4.

    6. How the cost works out: marginal cost and its boundaries

    A pure-code approach lowers the cost of generative lottery tickets, but it does not remove labor, development time, compute, storage, and debugging costs.

    Generative video model cost typically grows linearly with the number of generations. Every unsatisfying result may cost another payment, and poor character consistency multiplies regenerations. The pure-code approach differs: rendering happens locally or on your own server, and the per-clip cost is driven mainly by local compute, frame storage, and encoding time.

    More precisely, the marginal cost can be written as:

    1. marginal cost per video =
    2. render time × compute rate
    3. + frame sequence storage cost
    4. + encode time × machine rate
    5. + retry probability × cost per debugging pass

    For example, a 15-second, 1080p, 60fps video produces 900 PNG frames. At roughly 200KB per PNG, the frame sequence is about 180MB. If local rendering takes 1 minute and the cloud instance rate is an assumed 0.5 per hour, the direct compute cost is about 0.008. That number looks very low, but note what it excludes:

    • It excludes human scriptwriting, copywriting, storyboarding, and editing.
    • It excludes the time spent developing the skill package.
    • It excludes hardware depreciation or monthly cloud instance commitments.
    • It excludes asset licensing, voiceover, subtitles, and distribution costs.
    • It excludes debugging complex motion, model iteration, and failed retries.

    So the more rigorous statement is this: once the specification is fixed, the per-run cost of a pure-code stickman animation pipeline can drop substantially, but the total cost still has to be accounted for at project scope.

    For comparison:

    Dimension Generative video model Pure-code stickman animation
    Cost structure Pay per generation Mostly local rendering and storage
    Consistency Prone to broken faces and identity drift Fixed skeleton, strong consistency
    Cost of a dialogue change Possibly regenerate the whole clip Re-run after editing copy or keyframes
    Controllability Depends on randomness Angles, proportions, frame rate are controllable
    Suitable content Photoreal and complex scenes Flat, talking-head, process demos
    Risk Unpredictable budget Requires development and tuning

    So the approach is not automatically cheaper. It converts unpredictable generative spend into more controllable engineering cost.

    7. Best practices, common mistakes, and a troubleshooting quick reference

    Separating the spec, the engine, the export, and the content configuration is what lets a skill package stay reusable long term.

    7.1 Spec first

    Skeleton proportions, output specs, and naming rules belong in SKILL.md, so every run has a mathematical baseline instead of relying on improvisation.

    7.2 Separate the concerns

    Keep three modules decoupled:

    • Rendering library: only draws the skeleton and motion.
    • Export script: only captures screenshots and muxes video.
    • Content data: only holds shots, copy, and keyframes.

    Editing content should not touch the engine, and editing the engine should not break the export chain.

    7.3 Parameterize the content

    Extract the shot list and copy into configuration:

    1. const script = {
    2. title: "Pain points of a one-person company making short videos for overseas markets",
    3. shots: [
    4. { id: "shot-1", text: "Hard to pick topics", pose: "point" },
    5. { id: "shot-2", text: "Hard to shoot", pose: "think" },
    6. { id: "shot-3", text: "Hard to edit", pose: "wave" }
    7. ]
    8. };

    This makes batch generation easy and makes A/B testing straightforward.

    7.4 Common mistakes and troubleshooting

    Problem Possible cause How to handle
    KEYFRAMES is not defined Keyframes not loaded, or wrong script order Put KEYFRAMES in engine.js, and make sure index.html loads engine.js first
    Blank screenshots Canvas not drawn, or not redrawn per frame Confirm renderStickmanFrame calls clearRect and drawStickman on every frame
    Inconsistent frame rate FPS, the screenshot loop, and the FFmpeg frame rate disagree Fix a single FPS = 60 and pass -framerate 60 to FFmpeg
    FFmpeg not found Not installed or not on PATH Install FFmpeg and verify with ffmpeg -version
    Joints out of range jointLimit does not cover a field Check that every pose field is inside the joint limits
    Audio/video out of sync Voiceover timeline differs from video duration Lock the video duration first, then align the audio timeline frame by frame
    Unnatural motion Too few keyframes, unnatural easing Add keyframes, adjust the easing function, fine-tune joint angles
    Proportion drift Bone lengths use different baselines Compute every bone length from the same canvas height

    7.5 Reusing the framework

    The same skill structure can be reused with different skeleton definitions and themes, and migrated to other flat animation styles. Swap the stickman for a rectangle character, a geometric character, or a simple-line animal: as long as SKILL.md, engine.js, and render.js keep their separate responsibilities, the pipeline copies over quickly.

    8. Summary

    Turning “random generation” into “execution against a skill specification” is the key step toward controlling AI content production costs. By packaging the skeleton spec, the rendering library, and the export tooling, teams can produce consistent, batch-iterable short videos in a more controllable engineering way — and spend the limited budget on creativity, scripts, and distribution instead of repeated lottery tickets.