介绍
# AI Video Generation Skill
使用 AI 从文本描述生成完整的视频。
## 功能
1. **图像生成** - DALL-E 3, Stable Diffusion, Flux 2. **视频生成** - LumaAI, Runway, Replicate 模型 3. **旁白** - OpenAI TTS, ElevenLabs 4. **视频剪辑** - FFmpeg 组装、转场、覆盖
## 快速开始
```bash # Generate a complete video python skills/ai-video-gen/generate_video.py --prompt "A sunset over mountains" --output sunset.mp4
# Just images to video python skills/ai-video-gen/images_to_video.py --images img1.png img2.png --output result.mp4
# Add voiceover python skills/ai-video-gen/add_voiceover.py --video input.mp4 --text "Your narration" --output final.mp4 ```
## 设置
### 必需的 API 密钥
添加到您的环境变量或 `.env` 文件中:
```bash # Image Generation (pick one) OPENAI_API_KEY=sk-... # DALL-E 3 REPLICATE_API_TOKEN=r8_... # Stable Diffusion, Flux
# Video Generation (pick one) LUMAAI_API_KEY=luma_... # LumaAI Dream Machine RUNWAY_API_KEY=... # Runway ML REPLICATE_API_TOKEN=r8_... # Multiple models
# Voice (optional) OPENAI_API_KEY=sk-... # OpenAI TTS ELEVENLABS_API_KEY=... # ElevenLabs
# Or use FREE local options (no API needed) ```
### 安装依赖
```bash pip install openai requests pillow replicate python-dotenv ```
### FFmpeg
已通过 winget 安装。
## 使用示例
### 1. 文本生成视频(完整流程)
```bash python skills/ai-video-gen/generate_video.py \ --prompt "A futuristic city at night with flying cars" \ --duration 5 \ --voiceover "Welcome to the future" \ --output future_city.mp4 ```
### 2. 多场景
```bash python skills/ai-video-gen/multi_scene.py \ --scenes "Morning sunrise" "Busy city street" "Peaceful night" \ --duration 3 \ --output day_in_life.mp4 ```
### 3. 图像序列生成视频
```bash python skills/ai-video-gen/images_to_video.py \ --images frame1.png frame2.png frame3.png \ --fps 24 \ --output animation.mp4 ```
## 工作流选项
### 预算模式(免费) - 图像:Stable Diffusion(本地或免费 API) - 视频:开源模型 - 语音:OpenAI TTS(便宜)或免费 TTS - 剪辑:FFmpeg
### 质量模式(付费) - 图像:DALL-E 3 或 Midjourney - 视频:Runway Gen-3 或 LumaAI - 语音:ElevenLabs - 剪辑:FFmpeg + 特效
## 脚本参考
- `generate_video.py` - 主端到端生成器 - `images_to_video.py` - 将图像序列转换为视频 - `add_voiceover.py` - 为现有视频添加旁白 - `multi_scene.py` - 创建多场景视频 - `edit_video.py` - 应用特效、转场、覆盖
## API 成本估算
- **DALL-E 3**: 每张图约 $0.04-0.08 - **Replicate**: 每次生成约 $0.01-0.10 - **LumaAI**: 每 5 秒 $0-0.50(有免费层级) - **Runway**: 每秒约 $0.05 - **OpenAI TTS**: 每 1K 字符约 $0.015 - **ElevenLabs**: 每 1K 字符约 $0.30(质量更好)
## 示例
查看 `examples/` 文件夹以获取示例输出和提示词。