Message Renderer Module
Renders LLM-generated conversations as animated iMessage-style videos with synchronized audio.
MessageRendererService
render(conversation: Conversation, post: RedditPost): Promise<Result<GeneratedVideo, MessageRendererError>>
Orchestrates the full rendering pipeline:
- Build narration script — converts conversation messages into readable narration text
- TTS synthesis — generates audio with word-level timestamps via TtsService
- Frame generation — renders PNG frames for each message bubble state
- Duration scaling — maps frame durations to match audio length
- FFmpeg composition — muxes frames + audio using concat demuxer
- Cleanup — removes intermediate frame images
Sub-components
FrameGenerator
Generates individual PNG frames representing the progressive state of the iMessage conversation. Each new message adds a bubble to the thread.
buildNarrationScript(conversation: Conversation): string
Converts a Conversation into a narration script that reads naturally when spoken by TTS. Includes speaker attributions and message text.
Configuration
| Variable | Default | Description |
|---|---|---|
MESSAGE_TARGET_COUNT | 14 | Target messages per conversation |
MESSAGE_FRAMERATE | 10 | Video frame rate |
MESSAGE_TYPING_DURATION_MS | 800 | Typing indicator display time |
MESSAGE_MIN_HOLD_MS | 600 | Minimum hold time per message |
Error Codes
| Code | Description |
|---|---|
FRAME_GENERATION_FAILED | PNG frame rendering error |
FFMPEG_FAILED | Video composition error |
TEMPLATE_LOAD_FAILED | iMessage template missing |
NARRATION_FAILED | TTS synthesis or alignment failure |