# Auto Life Plan Video Generator A hybrid Python/Node.js system that automatically generates financial advice videos from PDF reports and interview footage. ## ๐ŸŽฏ Project Overview This system transforms static Life Plan reports (PDF) and raw interview videos into dynamic, personalized 3-5 minute explanatory videos combining: - **Animated Charts** (Asset depletion, cash flow analysis) - **AI-Generated Narration** (Natural Japanese scripts) - **B-Roll Footage** (Contextual stock footage) - **Interview Clips** (Synchronized with content) ## ๐Ÿ—๏ธ Architecture ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Python โ”‚ โ† Director (Orchestration, AI, Data Processing) โ”‚ Backend โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ generates โ†“ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚render_props.jsonโ”‚ โ† Data Contract โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ consumed by โ†“ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Remotion โ”‚ โ† Engine (Video Rendering) โ”‚ Frontend โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### Tech Stack **Backend (Python 3.10+)** - Google Gemini 1.5 Pro (PDF parsing, script generation) - OpenAI Whisper (Audio transcription) - FFmpeg (Video processing) - Pexels API (B-Roll footage) **Frontend (Node.js/TypeScript)** - Remotion (Programmatic video rendering) - React 19 + TypeScript - Recharts (Dynamic charts) - Zod (Schema validation) ## ๐Ÿ“ Directory Structure ``` auto-life-plan-video/ โ”œโ”€โ”€ main.py # CLI entry point โ”œโ”€โ”€ requirements.txt # Python dependencies โ”œโ”€โ”€ package.json # Node.js dependencies โ”œโ”€โ”€ remotion.config.ts # Remotion configuration โ”œโ”€โ”€ .env # API keys (create from .env.example) โ”œโ”€โ”€ assets/ # Shared storage โ”‚ โ”œโ”€โ”€ 0_input/ # Raw inputs (PDF, MP4) โ”‚ โ”œโ”€โ”€ 1_processed/ # Intermediate files โ”‚ โ””โ”€โ”€ 2_output/ # Final rendered videos โ”œโ”€โ”€ backend/ # Python modules โ”‚ โ”œโ”€โ”€ __init__.py โ”‚ โ”œโ”€โ”€ extractor.py # PDF/Video parsing โ”‚ โ”œโ”€โ”€ scripter.py # Script generation โ”‚ โ”œโ”€โ”€ media_fetcher.py # B-Roll fetching โ”‚ โ””โ”€โ”€ data_builder.py # Chart data simulation โ””โ”€โ”€ frontend/ # Remotion source โ””โ”€โ”€ src/ โ”œโ”€โ”€ index.ts # Remotion entry โ”œโ”€โ”€ Root.tsx # Composition registry โ”œโ”€โ”€ render-props-types.ts # TypeScript schema โ”œโ”€โ”€ types.ts # Component types โ””โ”€โ”€ components/ # React components โ”œโ”€โ”€ LifePlanChart.tsx โ”œโ”€โ”€ CashFlowChart.tsx โ””โ”€โ”€ ... ``` ## ๐Ÿš€ Quick Start ### 1. Install Dependencies **Python:** ```bash pip install -r requirements.txt ``` **Node.js:** ```bash npm install ``` ### 2. Configure API Keys Copy `.env.example` to `.env` and add your API keys: ```bash cp .env.example .env # Edit .env with your actual keys ``` Required keys: - `GEMINI_API_KEY` - Google Gemini API - `OPENAI_API_KEY` - OpenAI (for Whisper) - `PEXELS_API_KEY` - Pexels (for B-Roll) ### 3. Run the Pipeline **Basic usage:** ```bash python main.py --pdf assets/0_input/life_plan_report.pdf ``` **With interview video:** ```bash python main.py --pdf report.pdf --video interview.mp4 ``` **Dry run (generate data only, skip rendering):** ```bash python main.py --pdf report.pdf --dry-run ``` ## ๐Ÿ“Š Data Flow 1. **Input** โ†’ PDF + optional video 2. **Extract** โ†’ Gemini parses PDF structure 3. **Transcribe** โ†’ Whisper extracts audio/timestamps (if video provided) 4. **Generate** โ†’ Gemini creates narration script 5. **Fetch** โ†’ Pexels downloads B-Roll based on keywords 6. **Simulate** โ†’ Python calculates financial projections 7. **Build** โ†’ Create `render_props.json` 8. **Render** โ†’ Remotion generates final MP4 ## ๐Ÿ”ง Development ### Run Remotion Studio (Frontend Development) ```bash npm run dev ``` ### Test Python Backend ```bash python -m pytest ``` ### Type Check ```bash npm run type-check ``` ### Lint ```bash npm run lint ``` ## ๐Ÿ“ Data Contract The `render_props.json` file bridges Python and Remotion: ```json { "meta": { "title": "ๅฑฑ็”ฐๅคช้ƒŽๆง˜ใฎไบบ็”Ÿ่จญ่จˆ", "currencyUnit": "ไธ‡ๅ††", "duration": 180 }, "charts": { "assetDepletion": { "timeline": [ /* YearlySnapshot[] */ ], "meta": { "currencyUnit": "ไธ‡ๅ††", "startYear": 2025 } }, "cashFlow": { "timeline": [ /* CashFlowData[] */ ], "meta": { "currencyUnit": "ไธ‡ๅ††" } } }, "script": [ { "id": 1, "text": "ใ“ใ‚Œใ‹ใ‚‰ใ‚ใชใŸใฎๅฐ†ๆฅ่จญ่จˆใซใคใ„ใฆ...", "duration": 3.5, "type": "narration" } ], "assets": { "broll": { "retirement": "path/to/video.mp4" }, "videoClips": [] } } ``` See `frontend/src/render-props-types.ts` for full TypeScript schema. ## ๐ŸŽจ Adding New Components 1. Create component in `frontend/src/components/` 2. Import in `frontend/src/Root.tsx` 3. Register as `` with props from `render_props.json` ## ๐Ÿ› Troubleshooting **"API key not found"** - Ensure `.env` file exists and contains valid keys **"Remotion render failed"** - Check that `npm install` completed successfully - Verify `frontend/src/` structure is correct **"PDF extraction failed"** - Ensure PDF is readable and not password-protected - Check Gemini API quota/limits ## ๐Ÿ“š Documentation - [Remotion Documentation](https://www.remotion.dev/) - [Google Gemini API](https://ai.google.dev/) - [Copilot Instructions](.github/copilot-instructions.md) ## ๐Ÿค Contributing See project structure guidelines in `.github/copilot-instructions.md` ## ๐Ÿ“„ License UNLICENSED - Private project