# Microdrama Project: Automated Satirical News Videos

## Goal
Create automated pipeline for generating 45-60 second vertical videos (9:16) from satirical news articles (panorama.pub), with consistent characters and professional quality for YouTube Shorts/TikTok.

## First Experiment: Greenland Document Story
Article: "Документы о передаче Гренландии Российской Империи обнаружены на обороте договора по Аляске"

**Confirmed choices:**
- Visual style: **Documentary parody** (deadpan BBC/Discovery style)
- Music: **Skip for now** (focus on video generation first)
- Starting article: **Greenland documents**

---

## Project Structure

```
/home/videobot/dev/microdrama/
├── README.md                      # Project overview (reference from CLAUDE.md)
├── docs/
│   ├── greenland-plan.md          # THIS PLAN → move here after approval
│   ├── character-sheets.md        # How to create character sheets
│   └── checklist.md               # Progress tracking
├── scripts/
│   ├── panorama_fetcher.py        # Playwright-based article scraper
│   ├── microdrama_pipeline.py     # Main pipeline (manual first, then automated)
│   └── video_assembler.py         # FFmpeg clip assembly
├── prompts/
│   └── stages/
│       ├── md_stage1_analysis.md      # Article → narrative structure
│       ├── md_stage2_script.md        # Narrative → scene script
│       ├── md_stage3_characters.md    # Character reference cards
│       ├── md_stage4_frames.md        # NanoBanana scene prompts
│       └── md_stage5_video.md         # Veo3 video prompts
└── news/                          # Per-article working directories
    └── {article-slug}/
        └── {task_id}/
```

Output storage (ALL under /mnt/video/microdrama):
```
/mnt/video/microdrama/{slug}/{task_id}/
├── article.md                     # Source article text
├── article.json                   # Parsed article data
│
├── analysis/                      # Stage 1 outputs
│   ├── prompt.txt                 # Prompt sent to Claude
│   ├── response.json              # Claude's analysis
│   └── narrative.md               # Human-readable summary
│
├── script/                        # Stage 2 outputs
│   ├── prompt.txt
│   ├── script.json                # Full scene breakdown
│   └── script.md                  # Human-readable script
│
├── references/                    # Stage 3: Character/object refs
│   ├── search/                    # Yandex image search results
│   │   ├── query_historian.txt    # Search query used
│   │   ├── historian_01.jpg       # Downloaded references
│   │   └── ...
│   ├── sheets/                    # Generated turnaround sheets
│   │   ├── char_historian.jpg
│   │   ├── char_diplomat.jpg
│   │   └── obj_document.jpg
│   └── prompts/                   # NanoBanana prompts for sheets
│       └── char_historian_prompt.txt
│
├── scenes/                        # Stage 4-5: Per-scene content
│   └── scene_{NNN}/
│       ├── nb_prompt_first.txt    # NanoBanana prompt (first frame)
│       ├── nb_prompt_last.txt     # NanoBanana prompt (last frame)
│       ├── frame_first.jpg        # Generated first frame
│       ├── frame_last.jpg         # Generated last frame
│       ├── veo3_prompt.txt        # Veo3 prompt
│       ├── veo3_response.json     # Veo3 API response
│       └── clip.mp4               # Generated 8s clip
│
├── assembly/                      # Stage 6: Final assembly
│   ├── clips_list.txt             # FFmpeg concat list
│   ├── ffmpeg_cmd.sh              # Exact FFmpeg command used
│   └── final_video.mp4            # Assembled video
│
├── pipeline.log                   # Real-time execution log
└── metadata.json                  # Summary with all paths and timestamps
```

---

## Pipeline Stages

### Stage 0: Article Fetching (Manual → Playwright)
**First iteration:** Copy article text to `article.md` manually
**Later:** `panorama_fetcher.py` with Playwright

```python
# Key data to extract:
{
    "title": "Документы о передаче Гренландии...",
    "author": "Альбина Македонская",
    "date": "вчера, 10:00",
    "category": "Политика",
    "body": "Full text...",
    "image_url": "https://panorama.pub/storage/..."
}
```

### Stage 1: Article Analysis (Claude)
Extract narrative structure:
- Core satirical premise
- Key "characters" (historians, diplomats, Alexander II, Gorchakov)
- Settings (archives, old documents, maps)
- Visual opportunities (document close-ups, sepia photos, maps)
- Tone: deadpan historical satire

### Stage 2: Script Creation (Claude)
5-7 scenes for 45-60 seconds, **documentary parody style** (deadpan serious tone):

| Scene | Duration | Type | Description |
|-------|----------|------|-------------|
| 1 | 8s | Opening | Dramatic slow zoom on archive building exterior |
| 2 | 8s | Establishing | Archive room, dusty folders, dramatic lighting, historian's hands |
| 3 | 8s | Discovery | Close-up: document being unfolded, dramatic music beat implied |
| 4 | 8s | Document | Extreme close-up of 1867 document with seal, Gorchakov signature |
| 5 | 8s | Historical | 1867 scene - diplomats around table, sepia/period style |
| 6 | 8s | Map reveal | Old map animation showing Greenland, Russia, Alaska with routes |
| 7 | 8s | Expert | Modern historian examining document with magnifying glass, nods seriously |

### Stage 3: Character & Object Reference Sheets (NanoBanana)

**Workflow:**
1. **Identify** characters/objects needing consistency across scenes
2. **Search** real-world references via Yandex Images
3. **Generate** professional turnaround sheets with NanoBanana
4. **Use** sheets as `reference_image_data` in all scene generation

**Characters for Greenland article:**
- **Modern historian**: 40s academic, glasses, tweed jacket
- **1867 diplomat/Gorchakov**: Period costume, formal beard, Russian imperial style
- **Archive worker**: Hands with white gloves (for document handling shots)

**Objects needing consistency:**
- **The document**: Old parchment with wax seal, specific handwriting style
- **1867 map**: Greenland, Alaska, Russia marked, period cartography style

**Reference sheet format** (like the example image):
```
┌────────────────────────────────────────────────────┐
│  [FRONT]   [3/4 VIEW]   [SIDE]   [BACK]           │
│                                                    │
│  Full body poses, same clothing, neutral bg        │
│                                                    │
├────────────────────────────────────────────────────┤
│  [FACE FRONT]  [FACE 3/4]  [FACE PROFILE]         │
│                                                    │
│  Close-up details for facial consistency           │
└────────────────────────────────────────────────────┘
```

**NanoBanana character sheet prompts (TESTED):**

**1️⃣ WITH reference image (from Yandex search):**
```
Create a professional character reference sheet based strictly on the uploaded
reference image. Use a clean, neutral plain background and present the sheet
as a technical model turnaround while matching the exact visual style of the
reference (same realism level, rendering approach, texture, color treatment,
and overall aesthetic).

Arrange the composition into two horizontal rows.
Top row: four full-body standing views placed side-by-side in this order:
front view, left profile view (facing left), right profile view (facing right), back view.
Bottom row: three highly detailed close-up portraits aligned beneath the full-body row
in this order: front portrait, left profile portrait (facing left), right profile portrait (facing right).

Maintain perfect identity consistency across every panel. Keep the subject in a
relaxed A-pose and with consistent scale and alignment between views, accurate
anatomy, and clear silhouette; ensure even spacing and clean panel separation,
with uniform framing and consistent head height across the full-body lineup and
consistent facial scale across the portraits. Lighting should be consistent across
all panels (same direction, intensity, and softness), with natural, controlled
shadows that preserve detail without dramatic mood shifts. Output a crisp,
print-ready reference sheet look, sharp details.
```

**2️⃣ WITHOUT reference image (description only):**
```
Create a professional character reference sheet of [CHARACTER DESCRIPTION HERE].
Use a clean, neutral plain background and present the sheet as a technical model
turnaround in a photographic style.

Arrange the composition into two horizontal rows.
Top row: four full-body standing views placed side-by-side in this order:
front view, left profile view (facing left), right profile view (facing right), back view.
Bottom row: three highly detailed close-up portraits aligned beneath the full-body row
in this order: front portrait, left profile portrait (facing left), right profile portrait (facing right).

Maintain perfect identity consistency across every panel. Keep the subject in a
relaxed A-pose and with consistent scale and alignment between views, accurate
anatomy, and clear silhouette; ensure even spacing and clean panel separation,
with uniform framing and consistent head height across the full-body lineup and
consistent facial scale across the portraits. Lighting should be consistent across
all panels (same direction, intensity, and softness), with natural, controlled
shadows that preserve detail without dramatic mood shifts. Output a crisp,
print-ready reference sheet look, sharp details.
```

**3️⃣ WARDROBE CHANGE (keep character, change outfit):**
```
Keep the same character sheet layout. Keep their physical characteristics and
expression the same. Change the outfit to [outfit description or reference to image].
```

**Python call example:**
```python
sheet_data, sheet_mime = call_nanobanana_laozhang(
    image_data=yandex_reference_image,  # Or None for prompt-only
    prompt=PROMPT_WITH_REFERENCE,       # One of the prompts above
    api_key=laozhang_key,
    aspect_ratio="16:9"                 # Wide for turnaround layout
)
```

**Storage:**
```
/mnt/video/microdrama/greenland-documents/{task_id}/
├── references/
│   ├── search/                    # Downloaded Yandex results
│   │   ├── historian_ref_01.jpg
│   │   ├── diplomat_1867_ref_01.jpg
│   │   └── old_document_ref_01.jpg
│   ├── sheets/                    # Generated turnaround sheets
│   │   ├── char_historian_sheet.jpg
│   │   ├── char_diplomat_sheet.jpg
│   │   └── obj_document_sheet.jpg
│   └── prompts/                   # Prompts used for generation
│       ├── char_historian_prompt.txt
│       └── ...
```

### Stage 4: Scene Frames (NanoBanana)
For each scene generate:
- First frame (scene start)
- Last frame (scene end, for Veo3 interpolation)

**Consistency:** Use character reference cards as `reference_image_data`

### Stage 5: Video Generation (Veo3)
Per-scene 8-second clips using:
- `veo-3.1-fl` (vertical 9:16)
- First/last frame guidance
- Motion prompts (camera movement, subtle action)

### Stage 6: Assembly (FFmpeg)
- Concatenate clips with transitions
- Add text overlays (headlines, dates)
- Add music track (Suno - news theme style)

---

## First Manual Iteration Steps

### Step 1: Setup directory structure
```bash
mkdir -p /home/videobot/dev/microdrama/{scripts,prompts/stages,news}
mkdir -p /mnt/video/microdrama/greenland-documents/$(date +%Y%m%d_%H%M%S)
```

### Step 2: Save article content
Create `/mnt/video/microdrama/greenland-documents/{task_id}/article.md`

### Step 3: Create analysis prompt
Write `md_stage1_analysis.md` template, run manually with Claude

### Step 4: Create script prompt
Write `md_stage2_script.md` template, generate script JSON

### Step 5: Generate character references
Use existing `laozhang_proxy.py` directly:
```python
from scripts.laozhang_proxy import call_nanobanana_laozhang
# Generate character sheets
```

### Step 6: Generate scene frames
Loop through scenes, generate first/last frames

### Step 7: Generate video clips
Use existing `laozhang_veo3_async.py`:
```python
from scripts.laozhang_veo3_async import call_veo3_laozhang_async, poll_veo3_laozhang_async
```

### Step 8: Assemble video
FFmpeg concat with transitions

---

## Character Consistency Strategy

```
Character Sheet (Stage 3)
         │
         ▼
Scene 1 Frame 1 ← Uses character sheet as reference
         │
         ▼
Scene 1 Frame 2 ← Uses Frame 1 as reference
         │
         ▼
Scene 2 Frame 1 ← Uses Scene 1 Frame 2 + character sheet
         │
         (cascade continues)
```

**Key:** Always pass `reference_image_data` to NanoBanana

---

## Reusable Components from Existing Pipeline

| Component | Source | Usage |
|-----------|--------|-------|
| NanoBanana API | `scripts/laozhang_proxy.py` | Import directly |
| Veo3 async | `scripts/laozhang_veo3_async.py` | Import directly |
| Claude calls | `scripts/full_pipeline_v2.py` | Copy pattern |
| Logging | `scripts/full_pipeline_v2.py` | Copy `setup_task_logging` |
| Image download | `scripts/full_pipeline_v2.py` | Copy `download_image` |
| Playwright | `scripts/wb_fetcher_enhanced.py` | Adapt for panorama.pub |

## Reference Image Search (Yandex)

User has Yandex Images subscription. For first manual iteration:
1. Search Yandex manually for reference images
2. Download best matches to `references/search/`
3. Save search query to `query_{subject}.txt`

**Search strategy by subject:**
- Historian: "историк архивист портрет мужчина 40 лет"
- 1867 diplomat: "русский дипломат 19 век портрет горчаков"
- Old document: "старинный документ 1867 печать сургуч"
- Period map: "карта гренландия аляска 19 век"

Later: Automate via Yandex Images API if available

---

## Files to Create

1. **`/home/videobot/dev/microdrama/README.md`** - Project documentation
2. **`/home/videobot/dev/CLAUDE.md`** - Add reference to microdrama/
3. **`prompts/stages/md_stage1_analysis.md`** - Article analysis prompt
4. **`prompts/stages/md_stage2_script.md`** - Script generation prompt
5. **`prompts/stages/md_stage3_characters.md`** - Character card prompt
6. **`prompts/stages/md_stage4_frames.md`** - Scene frame prompts
7. **`prompts/stages/md_stage5_video.md`** - Veo3 prompts
8. **`scripts/panorama_fetcher.py`** - Playwright article scraper

---

## Verification Plan

1. **Stage 1-2 test:** Run Claude analysis on Greenland article, verify script makes sense
2. **Stage 3 test:** Generate one character reference card, verify quality
3. **Stage 4 test:** Generate 2 scenes with character consistency, verify same person
4. **Stage 5 test:** Generate one 8-second clip, verify quality
5. **Full test:** Complete pipeline for Greenland article
6. **Second article:** Test with cat-director article to verify generalization

---

## Music Integration (Suno) - DEFERRED

Skip for first iteration. Add later when video pipeline is working.

---

---

## Progress Checklist

### Setup (do first)
- [x] Create `/home/videobot/dev/microdrama/` directory structure
- [x] Create `README.md` with project overview
- [x] Add reference to microdrama in `CLAUDE.md`
- [x] Move this plan to `microdrama/docs/greenland-plan.md`
- [x] Create first task directory: `/mnt/video/microdrama/greenland-documents/20260129_105726_8nwl/`

### Stage 0: Article
- [x] Save Greenland article text to `article.md`
- [x] Create `article.json` with parsed metadata

### Stage 1: Analysis
- [x] Create `prompts/stages/md_stage1_analysis.md` template
- [ ] Run Claude analysis on article
- [ ] Save results to `analysis/` directory

### Stage 2: Script
- [x] Create `prompts/stages/md_stage2_script.md` template
- [ ] Generate 7-scene script
- [ ] Review and adjust scenes
- [ ] Save `script.json` and `script.md`

### Stage 3: Character Sheets
- [x] Create `prompts/stages/md_stage3_character_sheet.md` with tested prompts

### Stage 3: Character/Object References
- [ ] Identify characters: historian, 1867 diplomat
- [ ] Identify objects: document, map
- [ ] Search Yandex for reference images
- [ ] Download references to `references/search/`
- [ ] Generate character sheets with NanoBanana
- [ ] Save sheets to `references/sheets/`

### Stage 4: Scene Frames
- [ ] Generate Scene 1 first/last frames
- [ ] Generate Scene 2 first/last frames (with char reference)
- [ ] ... (repeat for all scenes)
- [ ] Review frame consistency

### Stage 5: Video Clips
- [ ] Generate Scene 1 clip (Veo3)
- [ ] Generate Scene 2 clip
- [ ] ... (repeat for all scenes)
- [ ] Review clip quality

### Stage 6: Assembly
- [ ] Create FFmpeg concat list
- [ ] Assemble clips
- [ ] Add text overlays if needed
- [ ] Export final video

### Documentation
- [ ] Document lessons learned
- [ ] Update prompts based on results
- [ ] Prepare for second article (cat-director)

---

## Estimated Workflow

**Manual first run (Greenland article):**
1. Setup directories and save article
2. Create and test prompts iteratively
3. Generate content step by step
4. Assemble and review
5. Document learnings

**Automation priority:**
1. Article fetching (Playwright)
2. Frame generation loop
3. Video generation loop
4. Assembly script
5. Full pipeline script
