Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:ALwrity ALwrity BrollComposer

From Leeroopedia
Knowledge Sources
Domains Podcast, Video_Composition, Visualization
Last Updated 2026-10-24 00:00 GMT

Overview

Concrete tool for composing layered B-roll video scenes from generated insights, with chart rendering, avatar circles, text overlays, and crossfade concatenation, provided by the ALwrity podcast subsystem.

Description

The BrollComposer module implements the B-roll composition pipeline (stage 4 of the podcast workflow). It takes Insight dataclass objects (key_insight, supporting_stat, visual_cue, audio_tone, chart_data, duration) and SceneAssets (background, chart, avatar, bullet images) and composes layered video scenes. The visual_cue field selects the chart type: bar_comparison, bar_horizontal, line_trend, pie, stacked_bar, bullet_points, or full_avatar. Charts are rendered with matplotlib to transparent PNGs, then composited over backgrounds with avatar circles and text overlays using moviepy CompositeVideoClip. Scenes are concatenated with crossfade_concat (CrossFadeIn with negative padding for dissolve transitions).

Usage

Import this module when:

  • The podcast pipeline has generated scenes with insights and visual cues.
  • Data-driven charts must be rendered and composited into video scenes.
  • Crossfade transitions between scenes are needed.

Code Reference

Source Location

  • Repository: ALwrity
  • File: backend/services/podcast/broll_composer.py (L1-100+)

Signature

@dataclass
class Insight:
    key_insight: str
    supporting_stat: str
    visual_cue: str          # bar_comparison|bar_horizontal|line_trend|pie|stacked_bar|bullet_points|full_avatar
    audio_tone: str
    chart_data: dict = field(default_factory=dict)
    duration: float = 10.0

@dataclass
class SceneAssets:
    background_img: str
    chart_img: Optional[str] = None
    avatar_video: Optional[str] = None
    bullet_img: Optional[str] = None

def crossfade_concat(scenes: list, fade_dur: float = 0.5):
    """Concatenate scenes with a dissolve transition (CrossFadeIn + negative padding)."""

def make_bar_chart(data: dict, out_path: str, title: str = "", show_legend: bool = True,
                   value_suffix: str = "%", subtitle: str = "") -> str:
    """Render a side-by-side comparison bar chart to PNG."""

Import

from services.podcast.broll_composer import Insight, SceneAssets, crossfade_concat, make_bar_chart

I/O Contract

Inputs

Name Type Required Description
Insight dataclass Yes key_insight, supporting_stat, visual_cue, audio_tone, chart_data, duration
SceneAssets dataclass Yes background_img, chart_img, avatar_video, bullet_img
scenes list Yes (concat) List of moviepy VideoClip scenes
fade_dur float No (concat) Crossfade duration in seconds (default 0.5)

Outputs

Name Type Description
crossfade_concat VideoClip Concatenated video with dissolve transitions
make_bar_chart str Output PNG path of the rendered chart

Usage Examples

Composing scenes with crossfade

from services.podcast.broll_composer import Insight, SceneAssets, crossfade_concat, make_bar_chart

# Render a chart from insight data
chart_path = make_bar_chart(
    data={"labels": ["Before", "After"], "before": [30], "after": [75]},
    out_path="/tmp/chart_1.png",
    title="Conversion Rate",
)

# Build scenes (simplified — real code uses CompositeVideoClip layering)
scenes = [build_scene(insight_1, assets_1), build_scene(insight_2, assets_2)]

# Concatenate with 0.5s crossfade
final_video = crossfade_concat(scenes, fade_dur=0.5)
final_video.write_videofile("/tmp/podcast_broll.mp4", fps=30)

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment