Skip to content

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:

  1. Build narration script — converts conversation messages into readable narration text
  2. TTS synthesis — generates audio with word-level timestamps via TtsService
  3. Frame generation — renders PNG frames for each message bubble state
  4. Duration scaling — maps frame durations to match audio length
  5. FFmpeg composition — muxes frames + audio using concat demuxer
  6. 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

VariableDefaultDescription
MESSAGE_TARGET_COUNT14Target messages per conversation
MESSAGE_FRAMERATE10Video frame rate
MESSAGE_TYPING_DURATION_MS800Typing indicator display time
MESSAGE_MIN_HOLD_MS600Minimum hold time per message

Error Codes

CodeDescription
FRAME_GENERATION_FAILEDPNG frame rendering error
FFMPEG_FAILEDVideo composition error
TEMPLATE_LOAD_FAILEDiMessage template missing
NARRATION_FAILEDTTS synthesis or alignment failure

Built with VitePress