# 13 — Video & Reel Generation

## Context
Fogbreak adds AI video creation — none of the 6 replaced platforms offer this. Auto-generate property tour videos from listing photos, add AI voiceover, and post to social media.

## What to Build

### 1. Video Generation Pipeline
Create `app/api/video.php`:

Pipeline: Photos → Runway API (video) → ElevenLabs (voiceover) → Combine → Post

```
POST /api/video.php?action=generate             # Start video generation
GET  /api/video.php?action=status&job_id=X      # Check status
GET  /api/video.php?action=result&job_id=X      # Get completed video
POST /api/video.php?action=generate_voiceover   # Generate narration
POST /api/video.php?action=generate_reel         # Short-form reel
GET  /api/video.php?action=history&prop=X        # Videos for property
```

### 2. Runway API Integration
- Submit listing photos → get cinematic video clips
- Camera movements: orbit, push-in, pull-out, pan
- $0.78 per 10-second clip (1080p)
- Concatenate clips for full property tour (30-90 seconds)

### 3. ElevenLabs Voiceover
- AI generates narration script from listing data
- Script is market-aware and brand-voiced
- ElevenLabs converts script to natural speech
- Multiple voice options (male, female, different styles)
- Agent can use their own voice (voice cloning with permission)

### 4. Video Types
- **Full property tour** (60-90 sec): All rooms, exterior, neighborhood
- **Instagram Reel** (15-30 sec): Fast-paced highlights, trending music placeholder
- **TikTok video** (15-60 sec): Hook-first format, text overlays
- **Open house promo** (15 sec): Date, time, address, preview
- **Just sold celebration** (15 sec): Sold price, congrats, agent branding
- **Market update** (30-60 sec): Stats with visual charts

### 5. Auto-Generation Triggers
- New listing → auto-generate full tour + reel
- Open house scheduled → auto-generate promo
- Sold → auto-generate just sold video
- All auto-posted via social automation (instruction 11)

### 6. Video Editor (Light)
- Reorder clips
- Add/remove photos from video
- Change voiceover script
- Add text overlays
- Add agent branding (logo, contact info)
- Select background music category

### 7. Cost Tracking
```sql
CREATE TABLE video_costs (
    id SERIAL PRIMARY KEY,
    tenant_id INT NOT NULL,
    job_id INT REFERENCES video_generation_jobs(id),
    provider VARCHAR(50),
    cost DECIMAL(8,2),
    created_at TIMESTAMPTZ DEFAULT NOW()
);
```

## Acceptance Criteria
- [ ] Runway API integration for video generation from photos
- [ ] ElevenLabs voiceover with AI-generated scripts
- [ ] Multiple video types (tour, reel, promo, just sold, market update)
- [ ] Auto-generation on listing events
- [ ] Light video editor for customization
- [ ] Agent branding on all videos
- [ ] Cost tracking per video
- [ ] Auto-post to social platforms via instruction 11
