From a feed full of Fable 5.2 demos to a 20-episode Indian epic: how I built "The Eighteen Days"
DEV Community

From a feed full of Fable 5.2 demos to a 20-episode Indian epic: how I built "The Eighteen Days"

कर्मण्येवाधिकारस्ते मा फलेषु कदाचन। मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि॥

You have a right to the work alone, never to its fruits. Do not let the fruit be your motive, and do not cling to inaction. - Bhagavad Gita 2.47

It started with my feed. For a couple of weeks, X and Instagram were a flood of reels and explainers that all carried the same caption: made with Fable 5.2.

Animated explainers, mini documentaries, whole storyboards, and under each one somebody saying they had built it over a weekend. I watched far too many of them before admitting the obvious. I did not want to watch any more. I wanted to try my own hands on Fable 5.2.

The only question was what to make. I am of Indian heritage, so the answer took about four seconds: the Mahabharata, the greatest and the biggest of the Indian epics. It runs to roughly a hundred thousand verses, about ten times the Iliad and the Odyssey put together, and at its centre is an eighteen-day war that I have heard told since I was a child.

If a model was going to be tested on storytelling, I wanted to test it on the story I know best. Go big or go home, and the Mahabharata is as big as it gets.

So I made a 20-episode animated series on that war, about four and a quarter hours of video, and at no point did I drag a clip onto a timeline. There is no Premiere project. There is no After Effects file. There is a folder of Python scripts, some HTML, five music tracks, and a very patient laptop.

The series is called Mahabharata: The Eighteen Days. Episode 1 is the Bhagavad Gita, Krishna's teaching to Arjuna on the morning of the battle. Episodes 2 to 19 are the eighteen days of the war, one day each, and Episode 20 is what came after. Narration is in Hindi, subtitles are in English, and every single thing on screen is drawn by code.

That includes this, from Episode 1: the Vishvarupa, the moment Krishna shows Arjuna his universal form. Every arm, face and planet is SVG written by a Python script.

दिवि सूर्यसहस्रस्य भवेद्युगपदुत्थिता। यदि भाः सदृशी सा स्याद्भासस्तस्य महात्मनः॥

If the light of a thousand suns were to blaze out at once in the sky, that might resemble the splendour of that great being. - Bhagavad Gita 11.12

All twenty episodes are on YouTube. Here is Episode 1, and the full playlist is here. This post is the nerdy version of how it works: the setup, every library and model and what it is for, how each piece gets made, the bugs that ate my evenings, and the episode list at the end.

The code is on GitHub: amananandrai/mahabharata-eighteen-days. It has the whole engine and one complete episode as a worked example, so you can build and render it yourself.

What's in this post

  • The one idea that makes it possible
  • The setup
  • The models, and who does what
  • The libraries, in a bit more detail
  • How each thing is made
  • War stories
  • Where Fable 5.2 needed a human
  • The numbers
  • What I would tell you over chai
  • The twenty episodes

The one idea that makes it possible

A video is just a web page that changes over time. If a frame is HTML, then a character is a function, a chariot duel is a function, and an episode is a list of function calls. Fixing a wrong shot means changing one line and rebuilding. Nothing is redrawn by hand, ever.

That is the only reason one person can ship twenty episodes.

A disclosure, since it matters: I did not hand-write most of this code. I worked with Claude Code as a coding agent. I gave direction, taste and corrections ("chariots always have horses", "the conch is the wrong way round", "why is that elephant underground"), and it wrote the Python, HTML and JavaScript. Think of me as the director and it as a tireless art department that never asks for chai.

The setup

Everything runs on one Windows laptop. Here is the whole stack.

  • Tool Version I used What it does here
  • Claude Code desktop app, on the Max plan The coding agent. Wrote and ran nearly all the code
  • Claude Opus and Claude Fable Opus 5.5, Fable 5.2 The models behind Claude Code
  • HyperFrames 0.9.88 to 0.9.96 Renders HTML + animation timelines to MP4
  • GSAP 3.15.0 The animation timeline inside every scene
  • p5.brush 3.0.0, patched Ink and watercolour brushwork for maps, formations, verses
  • Sarvam Bulbul bulbul:v4-flash Hindi text-to-speech, the narrator
  • Lyria 3 (in the Gemini web app) Generated the five background music tracks, at no cost
  • ffmpeg 9.0 Joins sections, mixes audio, makes contact sheets
  • Python 3.13 Draws characters and props, builds episodes
  • Node.js 24 Runs the HyperFrames CLI
  • numpy + soundfile Stitches the narration audio

Fonts are Rozha One for the big Hindi titles and Tiro Devanagari Sanskrit for verses, both open-licensed.

The project folder is boring on purpose (the repo has the same layout):

Mahabharata-Series/ scripts/the 20 narration scripts, the 20 shot lists, and the build tools shared/ characters, props, backdrops, fonts, music, two small JS libraries episodes/ one folder per episode: voice, sections, final MP4 .envthe TTS API key (never committed, never printed)

The models, and who does what

Four AI models are involved, and they have strictly separate jobs. None of them draws a picture.

Claude Opus 5.5 and Claude Fable 5.2, through Claude Code. This is the engineer. It wrote the drawing code, the episode builder and the shot lists, ran the builds, looked at the review frames, and fixed what was wrong. It also loads skills, which are packaged instructions for a specific tool. The HyperFrames skills (hyperframes, hyperframes-cli) are what taught it the render contract and the CLI, so I never had to paste documentation into a chat.

Sarvam Bulbul v4, for the voice. One narrator for the entire series, the voice Aditya (aditya_hi_conversational), at pace 0.9 and temperature 0.5, 48 kHz. I picked one voice and refused to change it. Twenty episodes in one voice feel like one telling; twenty episodes in five voices feel like a group project.

It is also absurdly cheap. Narrating the entire series, all twenty episodes, came to 169,000 characters and ₹338.01 on my Sarvam bill. That is about ₹2 per thousand characters, roughly ₹17 an episode, or about $3.71 at ₹91 to the dollar, for four and a quarter hours of narration. I have paid more than that for a single disappointing sandwich.

Lyria 3, through Gemini, for the music. I generated five instrumental tracks and gave each a job:

  • Track Used for Call of the Sacred Valley Series theme, title card, divine moments Where the River Bends Storytelling, recaps, backstories, palace scenes Before the Final Charge Battle and duels Where Kings Once Fell Death and grief Lotus Petals on the Current The Gita, Krishna, reflection

Five tracks for four hours sounds stingy. It works because the music sits low under the voice and each track always means the same thing. By Episode 6 you hear the first bars of "Where Kings Once Fell" and you already know someone is not making it to sunset.

No image model at all. Every face, horse and tent is SVG that Python writes. That was a deliberate choice: a generated image of Bhishma looks different every time, and a function called bhishma does not.

The libraries, in a bit more detail

HyperFrames: the renderer HyperFrames is an open-source framework from HeyGen that turns an HTML page with a paused animation timeline into a video. It opens the page in a headless browser, seeks the timeline to frame 0, takes a picture, seeks to frame 1, takes a picture, and so on, then encodes the lot.

The contract is simple: your page must look exactly the same every time it is asked for time t. No wall clock, no Math.random(), no "it'll settle in a moment". In return you get frame-exact video from plain web tech.

I use two commands, over and over:

npx hyperframes snapshot --at 12.5,30 # a PNG of the scene at those seconds
npx hyperframes render --quality looks -o out.mp4

GSAP: the clock Every scene has one paused GSAP timeline, and every movement is added to it at an absolute time. A walk, an arrow, a blink, a camera push: all entries on the same timeline. HyperFrames just seeks it.

p5.brush: the ink p5.brush imitates real brushes and watercolour in the browser. I use it for battle formations, maps and Sanskrit verse cards, drawn stroke by stroke while the narrator speaks. Out of the box it is not deterministic, which the renderer cannot tolerate. So the copy in the project has two small patches: Math.random is replaced by a fixed sequence, and the seed is reset on every frame. Same frame in, same pixels out.

ffmpeg: the glue ffmpeg does four jobs: it joins the rendered sections, mixes narration with music, grabs frames for review, and tiles those frames into contact sheets. The final mix is one filter graph (more on that below).

Two tiny libraries of my own These two are not downloads. They were written for this series, by Claude Code like the rest of the code, and they live in the repo under shared/lib.

rig.js (about 100 lines) moves the jointed characters: pose changes, walking, breathing, blinking, speaking, expressions. It is not even written by hand: draw_characters.py generates it, so the table of poses in the JavaScript always matches the joints in the drawings.

brush-kit.js (about 350 lines) wraps p5.brush with things the series needs: vyuha("krauncha") for a formation, moveArrow, underline, titleBloom, inkWipe. It also holds the stroke lists for all fifteen formations.

How each thing is made

An episode goes from a text file to an MP4 in seven steps.

  1. Write the Hindi script.
  2. Voice it and get the timing of every line.
  3. Write the shot list.
  4. Build the scenes.
  5. Review one frame of every shot.
  6. Render.
  7. Merge with narration and music.

Steps 4 to 7 are one command each.

1. The script

All twenty scripts were written before the first frame existed, so the series has one arc and each episode can tease the next. A script is a plain text file of about 1,600 Hindi words:

# भीम की प्रतिज्ञा [ADITYA] भीम ने गदा उठाई, और रथ से कूद पड़े। एक ही युद्ध में, धृतराष्ट्र के आठ पुत्र भीम की गदा के आगे धराशायी हो गए। [PAUSE 1.5] # starts a section, [ADITYA] names the speaker, each line is one narration line, and [PAUSE n] is where the music gets to breathe.

2. The voice, and the timing file

narrate.py sends each line to Sarvam, stitches the returned audio with short gaps, and writes two files: one WAV, and a segments.json like this:

{ "start" : 252.4 , "end" : 262.1 , "speaker" : "ADITYA" , "section" : "भीम की प्रतिज्ञा" , "text" : "..." }

That timing file is the spine of everything. Shots and subtitles are placed from those numbers, so the pictures cannot drift from the voice. I have never manually synced anything, and I intend to die that way.

3. Characters, drawn from a description

Every character is a small Python dict:

dict ( id = "bhagadatta" , hi = "भगदत्त" , en = "Bhagadatta" , role = "old king of Pragjyotisha · rider of Supratika" , skin = "#C29A78" , hair = "#EDEAE3" , hair_back = "long" , beard = "long" , crown = "royal" , armour = "#2C4F8C" , cloth = "#8E2A1E" , weapon = "spear" , age = "old" )

draw_characters.py reads that and writes SVG. There are functions for each part (hair_back, crown, beard, features, body, weapon), and each one looks at the dict and draws accordingly. A crown of type "royal" is one path, "sun" is another, and Karna gets rays.

From one description the script draws three views: a close-up bust, a front-view full figure, and a side-view figure for chariots and duels. The cast ended at about 180.

That sounds like a lot of drawing until you see how a minor character is made:

_variant ( "susharma" , id = "sudakshina" , hi = "सुदक्षिण" , en = "Sudakshina" , role = "king of Kamboja" , cloth = "#6A2A4A" , armour = "#4A3A4A" )

A king who appears for eleven seconds before Arjuna ends his career is one line. The eight sons of Dhritarashtra who die on Day 4 took a few minutes in total.

4. Making them move

The figures are jointed. Shoulders, elbows, hips, knees, head, weapon and eyelids are separate SVG groups with predictable ids, so a figure can glide from one pose to another. There are fifteen front poses and about ten side poses, plus five expressions (usual, anger, grief, joy, awe).

The rig library puts all of it on the GSAP timeline:

Rig . to ( tl , "arjuna-rig-" , "aim" , 2.0 , 0.8 ) ; // at 2.0 s, move into the aim pose over 0.8 s
Rig . idle ( tl , "arjuna-rig-" , 0 , 12 ) ; // breathing and blinking
Rig . walk ( tl , "krishna-rig-" , 1.4 , 4.6 ) ; // legs step while the figure slides across
Rig . face ( tl , "bhima-rig-" , "anger" , 3.0 ) ;
Rig . speak ( tl , "krishna-rig-" , 5.0 , 9.5 ) ; // mouth moves while his line is narrated

5. Props, chariots and backdrops

Props come from a second script, draw_assets.py, in the same style: horses in three coats, a chariot per hero with his own banner, war elephants, cavalry, foot soldiers, swords, shields, tents, torches, a throne, a dice board.

A manned chariot is assembled on demand. Ask for Karna with Shalya driving and the builder puts both side-view figures into Karna's chariot behind four horses, and caches the result.

Pandava-side warriors get white horses and Kaurava-side warriors get brown, because by Episode 13 I had been corrected on that exactly once and once was enough.

Full scenes (the two camps, the throne room, the dice hall, the palace, a river bank, a forest) are also code. They are drawn once and baked to flat PNGs, so the renderer is not redrawing four hundred tiny soldiers on every frame.

6. Brush scenes

Formations, maps and verses are painted live with p5.brush on a parchment card. Each day's battle arrays get their own brush drawing, and name tags mark who stood at the beak, the eyes and the wings. Here are two of them being painted, a few seconds of Episode 17:

In a scene it is a few calls:

const layer = BrushKit . layer ( "paper-host" , { paper : "#E9D3A0" } ) ;
layer . add ( BrushKit . vyuha ( "krauncha" , { x : 620 , y : 560 , size : 330 , start : 1 , end : 4 } ) ) ;
layer . add ( BrushKit . moveArrow ( [ [ 700 , 560 ] , [ 1000 , 540 ] ] , { start : 4.5 , en
Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.