---
title: Script-to-avatar video generation platform
url: https://gurkanozkan.ai/learn/design/applied-llm-sd-05/
markdown: https://gurkanozkan.ai/learn/design/applied-llm-sd-05.md
kind: design
role: Applied LLM
json: https://gurkanozkan.ai/api/learn/design/applied-llm-sd-05.json
---

# Script-to-avatar video generation platform

Design a platform where enterprise users write a script, pick an avatar and language, and receive a rendered talking-presenter video; support previews in seconds and final renders in minutes.

## What to cover

- **Requirements**: video length distribution; concurrency at peak; preview vs final quality; languages; custom avatar onboarding; enterprise compliance; cost targets
- **Estimates**
- **API**
- **Data model**
- **Architecture**: editor; script services (LLM drafting/translation, moderation); TTS per scene; lip-sync/motion generation per segment; render/composite workers; storage/CDN; job orchestration (DAG per video, segment-level parallelism, retries, caching unchanged scenes); progress notifications; consent/identity verification for custom avatars; provenance/watermark; QA checks (sync score, artefact detection)
- **Deep dives**: user edits one sentence — what re-renders?; How do you schedule GPU work fairly between tenants?; How is a harmful script caught?
- **Trade-offs**: segment granularity vs consistency at boundaries; preview fidelity vs cost; GPU pool sizing vs queue time; re-render only changed scenes vs full re-render
- **Evaluation**: asynchronous DAG design with incremental re-rendering; explicit cost per rendered minute; moderation and consent; quality checks before delivery

## Reference design

### Requirements

**Functional**: an editor where users write or generate a script split into scenes, pick an avatar, voice, language, background and layout, preview within seconds, and render a final video within minutes; translate an existing video into other languages; onboard custom avatars of real employees.

**Assumptions to confirm**
- **Video length distribution**: median 3 minutes, p90 10 minutes, cap 30 minutes; training and internal-comms videos dominate.
- **Peak concurrency**: ~20k final renders/day, business-hours peak 3× the average; previews ~10× as frequent as renders.
- **Preview vs final**: preview starts playing in < 5 s at 360p with real audio and approximate lip-sync; final 1080p in < 10 minutes for a 5-minute video at p95.
- **Languages**: 100+ TTS languages, script translation by LLM with human-editable output.
- **Custom avatars**: footage capture (studio or webcam), explicit consent video from the person, identity check, training job measured in hours.
- **Enterprise compliance**: SSO/SCIM, roles, audit logs, EU data residency option, SOC 2 / ISO 27001, retention controls, no training on customer scripts without opt-in.
- **Cost target**: compute well under $0.20 per rendered minute so plan prices carry healthy margins.
- **Safety**: no harmful content, no avatar saying things its owner did not authorise, visible provenance.


### Estimates

- **Rendered minutes**: 20k videos × 4 min average = **80k rendered minutes/day**.
- **Neural rendering**: assume one GPU renders 1 minute of 1080p avatar video in 2 minutes. 80k × 2 = 160k GPU-minutes ≈ **2,670 GPU-hours/day** ≈ 111 GPUs on average; a 3× business-hours peak needs ~330 without smoothing, ~200 with deadline-aware queueing that pushes bulk API jobs overnight.
- **Cost**: 2,670 GPU-hours × an assumed ~$2/GPU-hour (L40S-class) ≈ $5.3k/day ÷ 80k min ≈ **$0.067/min**; TTS, compositing and encoding add ~$0.02 → **~$0.09 per rendered minute**.
- **Final render latency**: a 5-minute video is ~60 segments of 5 s; each takes ~10 s of GPU time, so with 30 GPUs in parallel generation finishes in ~20–40 s, plus compositing and encoding ~30 s → **~1–2 minutes** when capacity is available; queue wait is the real variable.
- **Previews**: ~200k/day, rendered at 360p and only for the scene being edited; roughly a tenth of the GPU cost per second of a final.
- **Storage**: 1080p at ~5 Mbps ≈ 37.5 MB/min × 80k ≈ **3 TB/day**, ~90 TB/month; intermediate segment artefacts kept 30 days for incremental re-renders, finals tiered to cold storage after 90 days.


### API

```
POST   /v1/videos                {title, scenes: [{script, avatar_id, voice_id, language, background, layout, assets[]}]}
                                 → {video_id, version}
PATCH  /v1/videos/{id}/scenes/{scene_id}  {script?, avatar_id?, ...}  → {version}
POST   /v1/videos/{id}/preview   {scene_id}       → {hls_url}  (segments appear as they render)
POST   /v1/videos/{id}/render    {version, resolution: "1080p", priority?}
                                 → {render_id}
GET    /v1/renders/{render_id}   → {status, progress: {scenes_done, segments_done, eta_s}, download_url}
POST   /v1/videos/{id}/translate {target_languages: [...]}  → new video versions per language
POST   /v1/avatars               {footage_upload_ids, consent_video_id}  → {avatar_id, status: "verifying"}
Webhooks / WebSocket events: render.progress, render.completed, render.failed, moderation.blocked
```
Renders reference an immutable video version, so edits during a render never corrupt it.


### Data model

- **Workspace**: plan, quotas, region, retention policy, SSO settings.
- **Video**: id, workspace, current version; **VideoVersion** (immutable): ordered scene ids, settings.
- **Scene**: id, script, avatar_id, voice_id, language, background, layout, assets, script hash, moderation status.
- **Segment** (sentence-level unit of work): scene_id, index, text, content key = hash(text, voice, avatar, model versions, prosody context), audio URI, phoneme/viseme timings, visual URI, status.
- **RenderJob**: version, DAG of tasks with states, priority class, tenant, timings, cost.
- **Avatar**: id, owner, type (stock | custom), consent record, identity verification, model artefacts, allowed-use policy, status.
- **ModerationDecision**: object (script/scene/upload), categories, scores, decision, reviewer, policy version.
- **ProvenanceManifest**: render id, C2PA manifest, watermark id.

Postgres for metadata, object storage plus CDN for media, Redis for progress, the orchestrator's own store for DAG state.


### Architecture

```
Editor (web) ─► API ─► Script service: LLM drafting/translation, moderation gate
   ─► Orchestrator (Temporal): one DAG per render
       per scene:   TTS ─► forced alignment (phonemes/visemes) ─► split into sentence segments
       per segment: cache lookup by content key ─► lip-sync + motion generation (GPU pool)
       per scene:   compositing (background, avatar matte, slides, captions, transitions)
       per video:   concatenate at segment-aligned keyframes ─► encode (NVENC)
       ─► QA checks (sync score, artefact detector, loudness) ─► watermark + C2PA
       ─► object storage ─► CDN
   Scheduler: weighted fair queues per tenant, priority: previews > finals > bulk API
   Progress: task events ─► Redis ─► WebSocket/webhooks/email
Custom avatar onboarding: consent video + identity check ─► training pipeline
   ─► avatar QA (lip-sync, artefacts, likeness) ─► avatar registry
```
Every step's output is content-addressed, which gives incremental re-rendering, resumability and cheap retries for free.


### Deep dives

**A user edits one sentence — what re-renders?** Only segments whose content key changed. The edited sentence gets new TTS; its neighbours keep their audio, with a short crossfade (if prosody across the boundary sounds wrong, regenerate one neighbour with context). Lip-sync and motion run for the changed segment plus a few blend frames at each boundary, conditioned on the previous segment's last frames. That scene is recomposited (cheap), and only the affected group of pictures is re-encoded and spliced. A one-sentence edit costs seconds of GPU time instead of the whole video.

**Fair GPU scheduling between tenants.** Weighted fair queuing (deficit round robin) across tenants, weights by plan, inside priority classes: interactive previews, then paid finals, then bulk API jobs. Per-tenant concurrency caps stop one customer's 500-video batch from starving others. Segments are short (~5 s of video), so work naturally yields between them without preemption. Deadline-aware ordering lets bulk jobs run overnight; autoscale on queue wait time per class.

**Catching a harmful script.** Moderate at save and again at render request: fast classifiers for hate, harassment, sexual content, scams, medical and financial claims, elections and impersonation; an LLM second stage for ambiguous cases; human review before render for high-risk categories. Custom avatars of real people carry an allowed-use policy. After rendering, ASR on the output must match the approved script, catching tricks hidden in phonetic spelling. Decisions are logged; repeat offenders lose access.


### Trade-offs

- **Segment granularity vs boundary consistency**: sentence segments give parallelism and cache hits, but head pose and expression can jump at boundaries; overlap and condition on prior frames, and render whole scenes when a customer flags a seam.
- **Preview fidelity vs cost**: low-resolution, scene-only previews with the real voice are good enough to judge script and timing; full-quality previews would roughly double GPU spend.
- **GPU pool sizing vs queue time**: sizing for peak wastes capacity off-hours; a smaller pool plus deadline-aware scheduling, spot capacity for bulk jobs and an honest ETA in the UI is cheaper.
- **Re-render changed scenes vs full re-render**: incremental re-rendering saves most of the compute on small edits but risks subtle drift; force a full render when model versions change or the customer requests it.


### Evaluation

- **Asynchronous DAG with incremental re-rendering**: measure cache hit rate on re-renders and GPU-seconds per edit.
- **Cost**: GPU cost per rendered minute tracked daily against the ~$0.09 estimate, split by preview, final and translation.
- **Latency**: time to first preview frame p95, render time per output minute p95, queue wait per priority class and tenant.
- **Quality checks before delivery**: lip-sync confidence and audio-visual offset per segment, face-artefact and flicker detectors, loudness and clipping, ASR character error rate of the audio; failures auto re-render once, then go to human QA.
- **Model releases**: blind side-by-side human preference tests on a fixed script set across languages and avatars before rollout.
- **Moderation and consent**: precision and recall on a labelled script set, review turnaround, 100% of custom avatars with verified consent, appeal outcomes.
- **Online**: re-render rate as a dissatisfaction proxy, export and share rates, support tickets about artefacts.


## What a strong design shows

- Models the render as an asynchronous, content-addressed DAG so one-sentence edits re-render seconds, not minutes.
- Puts a number on cost per rendered minute and on GPU fleet size, and separates cheap previews from finals.
- Schedules GPUs fairly across tenants with priority classes and caps, using short segments as natural yield points.
- Treats consent for custom avatars, script moderation and provenance as product requirements.
- Runs automated quality checks before delivery rather than relying on users to report artefacts.

---

*Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.*
