Repository navigation
feat: add Motion Studio (motion-graphics Shorts with a talking host) - #1783
ashifhusainoo7 wants to merge 8 commits into
Conversation
Adds an opt-in studio at /studio/ that turns a title, topic, key points and a character (.glb model, image or none) into a 1080x1920 motion-graphics Short: word-timed text, numbers and cards with an animated host, instead of stock-footage stitching. - Script writer via LiteLLM with a per-request key (OpenAI, Anthropic, Gemini, OpenRouter, DeepSeek, Ollama, OpenAI-compatible). The key is never stored, logged or echoed, and never falls back to server env keys. - Storyboard JSON validated with pydantic, with one repair round. - Edge TTS per beat for exact timing; headless Chrome frames piped into ffmpeg in a killable subprocess (optional extra: motion = playwright). - YouTube upload kit: opens YouTube Studio, copies description and hashtags, downloads the MP4 (YouTube accepts no prefilled uploads). - React + Vite source in webui-studio/; built output committed to resource/public/studio/ so Python-only users need no Node. - Docs in docs/motion-studio.md; tests in test/services/test_motion.py.
- Join spoken tokens the script writes without spaces, so captions show
"cybercrime.gov.in" instead of "cybercrime . gov . in".
- Split long caption phrases into even chunks instead of capping at six
words, which could leave one word alone ("follow करना मत | भूलें").
- Tell the writer to use digits in the outro label and YouTube description;
number words are for narration only.
The prompt now asks for 90 to 115 words, never more than 120. A script that still runs over 120 words gets one round asking for about 105; if that answer is invalid, longer or the provider fails, the original script is kept, so length never fails a job. A real run of the same brief went from 182 words (77 s) to 108 words (48 s).
Every video used the same lilac/lime/coral look. Now each job gets the palette the latest jobs used longest ago (lilac, peach, sky, bubblegum, mint, butter, aqua), so back-to-back videos never share one, including after a server restart. Ink, paper, type and shapes stay fixed, and every palette keeps the same OKLCH lightness structure, so the videos still read as one channel. Checked: ink on stage >= 10:1, muted text >= 5:1, ink on accent >= 12:1. The hard-coded "good" card colour is now var(--accent-deep).
Edge TTS records each beat separately, which resets the intonation every few seconds. OpenAI voices read the whole script in one directed take with gpt-4o-mini-tts; whisper-1 then returns word times, which are matched back to the script's words (spelling variants such as आवाज़/आवाज or call/कौल included), so captions keep the script's spelling and beats stay timed. OpenAI voices reuse the script writer's OpenAI key: the API rejects them with another provider, the key now lives in the job frame until the voice is recorded, it is passed explicitly (never the server's env key), and OpenAI errors become plain messages without the key.
…s word A hook whose emphasis word came 9.5 s into the scene showed no number for 9 seconds. The main visual now pops on the emphasis word but no later than 1.6 s into the scene (compare: the second card by half-way).
… another An English brief produced English cards and an English disclaimer in a Hindi video.
|
Thanks for putting this together. I tried the renderer locally with a small three-beat storyboard, real Edge TTS, Chrome and FFmpeg. It produced a valid 1080x1920 video with audio, and the frontend build passed too. That run used no character and no paid LLM, so it doesn't cover the full feature set. One installation issue needs fixing: This blocks using Motion Studio through the frozen dependency workflow. Installing Playwright manually let my render run, but that bypasses the project's lockfile and doesn't fix the reproducible install path. I haven't found this to break the existing video workflow. Please update the lockfile and check both the default frozen install and the install with |
uv lock with the motion optional dependency: adds playwright 1.65.0 and greenlet 3.5.6 and the motion extra; no other package changes. uv lock --check passes, and uv sync --frozen works with and without --extra motion.
|
Thanks for testing it. Fixed in 1895c34: |
|
|
Hi @harry0703 i have done the changes and validated everything. Now if you can have a look and merge it, would be really hepful. I can understand that you would be occupied with lots of other things, still i would request to have a look at it if possible. |
Summary
Adds Motion Studio, an opt-in way to make vertical Shorts as word-timed motion graphics (big text, numbers and cards) with an animated character, instead of stock-footage stitching. It runs inside the existing API server at
/studio/..glb(rigged models get jaw/eye/brow/wing animation; any other model bobs, turns and talks) or an image, or use none.gpt-4o-mini-ttsMarin/Cedar for a more natural single take. The OpenAI voices use the creator's OpenAI key from the request (never the server's); word times come fromwhisper-1and are matched back to the script, so captions keep the script's spelling.Changes
app/controllers/v1/motion.py,app/models/motion.py,app/services/motion/,resource/motion/(scene engine, three.js r178 MIT, Baloo 2 OFL),webui-studio/(React + Vite source),resource/public/studio/(built UI, committed so Python-only users need no Node),docs/motion-studio.md,scripts/motion_smoke.py, tests.app/router.py(+1 router),app/asgi.py(static mount/motion-engine,.jsMIME fix, and validation errors on/api/v1/motion/*no longer echo request input),pyproject.toml(optional extramotion = ["playwright>=1.49"];resource/motionadded to the wheel and sdist),README.mdandREADME-en.md(one feature line each).verify_token.Notes for maintainers
uv.lockincludes the newmotionextra (playwright and greenlet only; no other package changes).uv lock --checkpasses, anduv sync --frozenworks with and without--extra motion./api/v1/motion/optionsreportsrenderer.installed: falseand the studio shows the install command.Test plan
pytest -q test/services/test_motion.py: 49 tests covering storyboard schema, writer repair, script length cap, palette rotation, OpenAI voice alignment and key handling, key never echoed, env-key fallback blocked, uploads and path traversal, voice timing, renderer loop (with a stand-in Playwright), job runner, cancel and timeout, API routes and auth. New code: 85% branch coverage.ruff checkandcompileallsteps are clean (also checked with a Python 3.11 syntax target)scripts/motion_smoke.pyrenders the fixture storyboard end to endgpt-5-mini, Hindi voice, two full videos (about 2.5 min each); the key was not found in job files, the server log or API responses. The first run showed three issues, fixed in 9d24aa0: URL tokens split in captions, a word orphaned by the caption length cap, and number words in the descriptionuv lock --check,uv export --frozen --extra motion, and freshuv sync --frozen --python 3.11with and without--extra motion