Skip to content

Intra-track segment looping: reuse identical sections #70

Description

@rancur

Problem

Currently every phrase in a song generates a unique video segment. A typical 4-minute track has ~15 segments, but many are repeated section types (Drop 1 = Drop 2, Buildup 1 = Buildup 2).

Proposal

Modify _plan_segments() in pipeline.py to detect repeated section types within a single track and reuse the first generated video for subsequent identical sections.

Add a segment_reuse_map keyed by (section_label, energy_bucket, mood_quadrant). When a new segment matches an existing key, copy/symlink the existing video instead of regenerating.

Impact

  • Reduces unique segments per track from ~15 to ~6
  • Saves ~60% of video generation cost per track
  • Zero quality tradeoff for repeated sections

Files to Modify

  • src/pipeline.py -- _plan_segments() and generate_for_track()
  • src/generator/cache.py -- extend cache key for intra-track reuse

Cost Impact

Before After Savings
$23/track $9.60/track 58%
$115,000 / 5K tracks $48,000 / 5K tracks $67,000

Labels: cost-optimization, high-priority

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions