The challenge
Poetry Shorts are cheap to make but awkward to publish: stock music raises licensing questions, and most video tools mishandle right-to-left scripts, so Urdu letters arrive disconnected or reversed.
I wanted one small tool that makes a finished, calm video from plain text, runs on a laptop or a free server, and can be driven by a person, a script or an AI assistant.
How I approached it
- 01
Music built from sine waves
A seeded generator layers slow detuned pad chords, sparse pentatonic bell notes and an FFT-convolved reverb, then low-passes the result. The same seed always gives the same piece, so a channel can have variety without any sample library.
- 02
Right-to-left done properly
Text is laid out word by word with Pillow and Raqm so Nastaliq shaping, joining and spacing come out right, and the font size shrinks until the longest line fits.
- 03
Timing from the text
Stanzas fade in one after another, grouped into pages of at most six lines, with hold times that scale with line count. The planner checks the result fits a 60 second Short before any rendering happens.
- 04
Fast compositing
Each text layer is cropped to its bounding box so ffmpeg composites small images instead of full frames. A typical render went from about a minute to about 30 seconds.
- 05
One engine, four interfaces
The CLI, the Python API, an MCP server (check_environment, plan_poem, render_poem, make_music_bed, fetch_poem) and a Claude Code skill all call the same functions.
- 06
Honest about rights
The Wikisource fetcher returns a licence credit line, the skill makes the assistant check public-domain status first, and the README puts responsibility for what gets published on the user.
Deliberate trade-offs
- Fonts are looked up on the system, not bundled. Urdu needs Noto Nastaliq Urdu installed.
- The music is deliberately simple background ambience, not a composition tool.
- Output is a still-text video. There is no voice-over or per-word highlighting yet.
- Public-domain status of a text is the user's job to confirm. The tool only helps with credit lines.
What I built
- Extracted and rewrote the rendering and music code from scripts that had hard-coded paths, into a tested installable package.
- Replaced the background image dependency with a procedural paper and watercolour generator.
- Wrote a Wikisource fetcher that reads rendered HTML, because raw wikitext fails on transcluded pages, and fixed stanza and drop-cap handling after testing it on a real poem.
- Added the CLI, the MCP server (compatible with both mcp 1.x and 2.x) and the skill, with 10 tests and CI.
- Published to PyPI and verified a clean install in a fresh virtual environment.
What this project demonstrates
- Designing and publishing a Python package and MCP server end to end
- Audio synthesis and ffmpeg pipeline work
- Right-to-left and Urdu text rendering
- Turning a working internal script into a documented, tested open-source tool


