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:
nvm install 18nvm use 18node -vnpm -v
On Windows, use winget:
winget install OpenJS.NodeJS.LTSnode -vnpm -v
Install FFmpeg:
# macOSbrew install ffmpegffmpeg -version# Debian / Ubuntusudo apt install ffmpegffmpeg -version# Windowswinget install Gyan.FFmpegffmpeg -version
Initialize the project and install Playwright:
mkdir stickman-animator && cd stickman-animatornpm init -ynpm i playwright@^1.44.0npx playwright@1.44.0 install chromium
Recommended directory structure:
skills/stickman-animator/├── SKILL.md├── engine.js├── render.js├── index.html├── frames/├── output/└── 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:
skills/stickman-animator/├── SKILL.md # Specification: skeleton proportions, motion rules, calling conventions├── engine.js # Rendering library: fixed skeleton + keyframes + smooth joint animation├── render.js # Export script: drive the browser for screenshots + encode└── 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:
# Stickman Animator## CharacterA stickman programmer with black glasses.## Skeleton- Head radius: 0.08 of canvas height- Torso: 0.28 of canvas height- Upper arm: 0.16 of canvas height- Forearm: 0.14 of canvas height- Thigh: 0.20 of canvas height- Shin: 0.18 of canvas height## Angle Semantics- shoulder, elbow, hip, knee angles are relative to parent joint.- headTilt is an absolute head rotation in degrees.## Output- FPS: 60- Canvas: 1920x1080- Format: MP4, H.264- 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:
const pose = {headTilt: 0,shoulderLeft: -20,elbowLeft: 10,shoulderRight: 20,elbowRight: -10,hipLeft: -5,kneeLeft: 0,hipRight: 5,kneeRight: 0};
Runnable engine.js:
// engine.jsconst SKELETON = {headRadius: 0.08,torso: 0.28,upperArm: 0.16,foreArm: 0.14,thigh: 0.20,shin: 0.18,jointLimit: {headTilt: [-20, 20],shoulderLeft: [-120, 120],elbowLeft: [0, 150],shoulderRight: [-120, 120],elbowRight: [0, 150],hipLeft: [-80, 80],kneeLeft: [0, 140],hipRight: [-80, 80],kneeRight: [0, 140]}};const KEYFRAMES = [{t: 0,pose: {headTilt: 0,shoulderLeft: -20,elbowLeft: 10,shoulderRight: 20,elbowRight: -10,hipLeft: -5,kneeLeft: 0,hipRight: 5,kneeRight: 0}},{t: 1,pose: {headTilt: 8,shoulderLeft: 60,elbowLeft: 30,shoulderRight: -60,elbowRight: -30,hipLeft: -15,kneeLeft: 20,hipRight: 15,kneeRight: 0}}];const clamp = (v, min, max) => Math.max(min, Math.min(max, v));function easeInOutCubic(t) {return t < 0.5? 4 * t * t * t: 1 - Math.pow(-2 * t + 2, 3) / 2;}function lerp(a, b, t) {return a + (b - a) * t;}function samplePose(keyframes, progress) {let a = keyframes[0];let b = keyframes[keyframes.length - 1];for (let i = 0; i < keyframes.length - 1; i++) {if (progress >= keyframes[i].t && progress <= keyframes[i + 1].t) {a = keyframes[i];b = keyframes[i + 1];break;}}const span = b.t - a.t || 1;const local = easeInOutCubic(clamp((progress - a.t) / span, 0, 1));const out = {};for (const key of Object.keys(b.pose)) {const from = a.pose[key] ?? 0;const to = b.pose[key] ?? 0;out[key] = lerp(from, to, local);}return out;}function clampPose(pose) {const out = {};for (const [key, value] of Object.entries(pose)) {const limit = SKELETON.jointLimit[key] || [-180, 180];out[key] = clamp(value, limit[0], limit[1]);}return out;}function poseAt(keyframes, progress) {return clampPose(samplePose(keyframes, progress));}function rad(deg) {return deg * Math.PI / 180;}function pointFrom(origin, angle, length) {return {x: origin.x + Math.sin(rad(angle)) * length,y: origin.y + Math.cos(rad(angle)) * length};}function drawChain(ctx, origin, angles, lengths, parentAngle = 0) {let current = origin;let absoluteAngle = parentAngle;for (let i = 0; i < angles.length; i++) {absoluteAngle += angles[i];const next = pointFrom(current, absoluteAngle, lengths[i]);ctx.beginPath();ctx.moveTo(current.x, current.y);ctx.lineTo(next.x, next.y);ctx.stroke();current = next;}}function drawStickman(ctx, width, height, pose) {const p = clampPose(pose);const hip = { x: width * 0.5, y: height * 0.58 };const torso = SKELETON.torso * height;const shoulder = { x: hip.x, y: hip.y - torso };const headRadius = SKELETON.headRadius * height;const headCenter = {x: shoulder.x,y: shoulder.y - headRadius * 1.15};ctx.lineWidth = Math.max(4, height * 0.008);ctx.strokeStyle = "#111111";ctx.lineCap = "round";ctx.save();ctx.translate(headCenter.x, headCenter.y);ctx.rotate(rad(p.headTilt));ctx.beginPath();ctx.arc(0, 0, headRadius, 0, Math.PI * 2);ctx.stroke();ctx.restore();ctx.beginPath();ctx.moveTo(shoulder.x, shoulder.y);ctx.lineTo(hip.x, hip.y);ctx.stroke();drawChain(ctx,shoulder,[p.shoulderLeft, p.elbowLeft],[SKELETON.upperArm * height, SKELETON.foreArm * height]);drawChain(ctx,shoulder,[p.shoulderRight, p.elbowRight],[SKELETON.upperArm * height, SKELETON.foreArm * height]);drawChain(ctx,hip,[p.hipLeft, p.kneeLeft],[SKELETON.thigh * height, SKELETON.shin * height]);drawChain(ctx,hip,[p.hipRight, p.kneeRight],[SKELETON.thigh * height, SKELETON.shin * height]);}if (typeof window !== "undefined") {window.SKELETON = SKELETON;window.KEYFRAMES = KEYFRAMES;window.poseAt = poseAt;window.drawStickman = drawStickman;}
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.pngtoframe_000899.png. - Time step:
1 / 60second 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:
// render.jsconst { chromium } = require("playwright");const { execSync } = require("child_process");const fs = require("fs");const path = require("path");const FPS = 60;const WIDTH = 1920;const HEIGHT = 1080;const DURATION = 15;const projectRoot = process.cwd();const requiredFiles = ["package.json", "index.html"];for (const file of requiredFiles) {if (!fs.existsSync(path.join(projectRoot, file))) {throw new Error(file +" not found. Run this from the project root so other directories are not deleted by mistake.");}}const targets = [{ name: "frames", dir: path.resolve("frames") },{ name: "output", dir: path.resolve("output") }];for (const item of targets) {const rel = path.relative(projectRoot, item.dir);if (rel !== item.name) {throw new Error("Only the project's " +item.name +" directory may be deleted; it currently resolves to " +rel +".");}}fs.rmSync("frames", { recursive: true, force: true });fs.rmSync("output", { recursive: true, force: true });fs.mkdirSync("frames", { recursive: true });fs.mkdirSync("output", { recursive: true });(async () => {const browser = await chromium.launch();const page = await browser.newPage({viewport: { width: WIDTH, height: HEIGHT },deviceScaleFactor: 1});await page.goto("file://" + path.resolve("index.html"));const totalFrames = FPS * DURATION;for (let i = 0; i < totalFrames; i++) {const progress = i / (totalFrames - 1);await page.evaluate(({ progress }) => {window.renderStickmanFrame(progress);}, { progress });const frameName ="frames/frame_" + String(i).padStart(6, "0") + ".png";await page.screenshot({path: frameName,type: "png"});}await browser.close();const ffmpegCommand ="ffmpeg -y -start_number 0 -framerate " +FPS +" -i frames/frame_%06d.png" +" -c:v libx264" +" -pix_fmt yuv420p" +" -crf 20" +" -movflags +faststart" +" output/stickman_15s.mp4";execSync(ffmpegCommand, { stdio: "inherit" });})();
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.
<!doctype html><html><head><meta charset="utf-8" /><style>html, body {margin: 0;padding: 0;background: #fff;}canvas {display: block;}</style></head><body><canvas id="canvas" width="1920" height="1080"></canvas><script src="engine.js"></script><script>const canvas = document.getElementById("canvas");const ctx = canvas.getContext("2d");window.renderStickmanFrame = function (progress) {ctx.clearRect(0, 0, canvas.width, canvas.height);const pose = window.poseAt(window.KEYFRAMES, progress);window.drawStickman(ctx, canvas.width, canvas.height, pose);};</script></body></html>
Run it:
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:
marginal cost per video =render time × compute rate+ frame sequence storage cost+ encode time × machine rate+ 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:
const script = {title: "Pain points of a one-person company making short videos for overseas markets",shots: [{ id: "shot-1", text: "Hard to pick topics", pose: "point" },{ id: "shot-2", text: "Hard to shoot", pose: "think" },{ id: "shot-3", text: "Hard to edit", pose: "wave" }]};
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.
