Skip to main content Switch to mobile version penshot 0.3.12 剧本分镜,动漫分镜,电影分镜,短剧分镜,视频分镜,剧本解析,文生视频提示词。AI agent that converts screenplays to consistent Text-to-Video prompts. Supports Sora, Runway, Kling, Veo via LangGraph & LLMs.
pip install penshot==0.3.12 Copy PIP instructions
____ _____ _ _ ____ _ _ ___ _____ | _ \| ____| \ | / ___|| || |/ _ \|_ _| | |_) | _| | \| \___ \| || | | | | | | | __/| |___| |\ |___) | __ | |_| | | | |_| |_____|_| \_|____/|_||_|\___/ |_| 🎬 剧本分镜智能体 (PenShot) 基于 LangChain + LangGraph 多智能体协作的剧本转分镜系统,确保叙事连续性与镜头级提示词生成。
English • 官网演示 • 官方文档 • 集成指南 • MCP 服务 • PyPI
🚀 一键转换:支持任意格式剧本(电影、短剧、动漫、小说等) → 镜头级描述 → Sora / Veo / Runway / 可灵 Ready Prompt 🧠 连续性保障:三视图 + RAG 知识库+ 三级记忆 + Chroma 向量检索 + 快照机制 + 多维召回,确保角色/场景/剧情跨片段一致 🔌 多端生态支持:开箱即用 Python SDK、MCP 服务、Function Calling、REST API 及 LangGraph 节点 ⚡ 5 分钟上手:pip install penshot + 3 行代码集成。或者 docker pull neotems/penshot 启动服务
flowchart TD subgraph Input [输入层] A1[客户端 / 上游智能体] --> A2[REST API / MCP / A2A] A2 --> A3[任务管理器] end subgraph Core [LangGraph 多智能体核心工作流] direction TB P1[剧本解析智能体] --> P2[分镜生成智能体] P2 --> P3[视频分割智能体] P3 --> P4[提示词转换智能体] P4 --> P5[质量审计智能体] P5 --> P6[连续性守护智能体] P6 --> P7[辅助生成智能体
三视图/背景图/关键帧] subgraph Control [控制节点] C1[循环检查] --> C2[错误处理] C2 --> C3[人工干预] C3 --> C4[结果生成] end P1 -.->|重试/修复| Control P2 -.->|重试/修复| Control P3 -.->|重试/修复| Control P4 -.->|重试/修复| Control P5 -.->|重试/修复| Control P6 -.->|重试/修复| Control Control -.->|路由决策| P1 end subgraph Memory [记忆层] M1[(短期记忆)] M2[(中期记忆)] M3[(长期记忆)] M4[(向量数据库
Chroma)] M1 Core M2 Core M3 Core M4 Core end subgraph Output [输出层] O1[Workflow Output Fixer
片段序列修复] --> O2[结果格式化] O2 --> O3[JSON / SDK / MCP / A2A] end subgraph Downstream [下游渲染] D1[多模型适配器] --> D2[Sora/Veo/Runway/可灵/SVD] D2 --> D3[FFmpeg 合成] D3 --> D4[最终成片] end A3 --> P1 P7 --> O1 O3 --> D1
该系统为典型的自然语言处理(NLP)应用场景,通过多智能体协作与记忆机制实现端到端的分镜转码。详细架构设计、记忆池实现与一致性保障机制请参考:《架构设计与实现》
# 直接安装 PyPI 包 pip install penshot 2. 环境配置
cp .env.example .env 编辑 .env 文件,配置必要的 LLM 与 Embedding 参数:
########################## LLM 模型配置 ######################### PENSHOT_LLM__DEFAULT__BASE_URL=https://dashscope-intl.aliyuncs.com/api/v1 PENSHOT_LLM__DEFAULT__API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx PENSHOT_LLM__DEFAULT__MODEL_NAME=qwen-plus ########################## 嵌入模型配置 ######################### PENSHOT_EMBED__DEFAULT__BASE_URL=https://dashscope-intl.aliyuncs.com/api/v1 PENSHOT_EMBED__DEFAULT__API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx PENSHOT_EMBED__DEFAULT__MODEL_NAME=text-embedding-v4 ########################## Redis 配置 ########################## PENSHOT_REDIS_URL=redis://:123456@localhost:6379/0 3. 使用方式
from penshot.api import create_penshot_agent agent = create_penshot_agent(max_concurrent=5) script = "早晨,一个女孩在咖啡馆读书,阳光透过窗户..." task_id = agent.breakdown_script_async( script, callback=lambda r: print(f"任务 {r.task_id} 已完成") ) status = agent.get_task_status(task_id) result = await agent.wait_for_result_async(task_id) 完整示例:sdk/01_sync_breakdown.py
from fastapi import FastAPI, HTTPException from penshot.api import create_penshot_agent app = FastAPI(title="Penshot API", version="0.1.0") agent = create_penshot_agent(max_concurrent=5) @app.post("/api/generate") async def generate(script_text: str): task_id = agent.breakdown_script_async(script_text) return {"task_id": task_id, "status": "PENDING"} 完整示例:integrations/fastapi_web_app.py
支持作为独立 Node 接入 LangChain/LangGraph 工作流,实现端到端自动化流水线。 完整示例:workflow/01_langgraph_integration.py
支持与上游剧本创作 Agent、下游文生视频/剪辑 Agent 进行上下文传递与任务编排。 完整示例:integrations/a2a_integration.py
5. MCP (Model Context Protocol) 支持
python -m penshot.mcp_server --max-concurrent 5 --queue-size 500 客户端调用工具 breakdown_script 与 get_task_result 即可无缝接入支持 MCP 的 IDE 或 Agent 框架。 完整示例:mcp/mcp_client.py
系统返回标准化的 JSON 格式,包含视频提示词、负面提示词、时长估算、风格参数及配套的音频提示词:
{ "fragments": [ { "fragment_id": "frag_001", "prompt": "wide shot, late night 11 PM, dim city apartment living room, heavy rain outside window, rain muffled by glass, Lin Ran wrapped in gray worn wool blanket curled on gray sofa, TV playing silent black-and-white old movie, light and shadows flickering on wall, half-drunk cold tea on coffee table with condensation, brown old photo album with worn leather cover and faded photos, black phone with dark screen on corner of table, Fujifilm ETERNA grading, natural overcast lighting, 35mm lens, static camera\n\n全景镜头:深夜11点,昏暗的城市公寓客厅,窗外大雨滂沱,雨声被玻璃隔绝,林然裹着灰色旧羊毛毯蜷在灰色沙发上,电视静音播放黑白老电影,光影在墙上晃动,茶几上半杯凉茶凝出水雾,旁边摊开一本棕色旧相册,封面皮革磨损,内页照片褪色,手机黑色屏幕暗着放在茶几一角,富士ETERNA色调,阴天自然光,35mm镜头,静态镜头", "negative_prompt": "bright lighting, sunny, dry room, modern decor, colorful, cartoon style, blurry details, wrong blanket color, wrong phone color", "main_character": "", "duration": 4.63, "model": "runway_gen2", "style": "cinematic realism, Fujifilm ETERNA, dim interior", "audio": { "audio_id": "audio_001", "prompt": "heavy rain against window, muffled thunder, distant city hum, silence of TV static, occasional creak of old sofa, condensation drip\n\n窗外大雨滂沱,雷声低沉,远处城市嗡鸣,电视静音静电声,旧沙发偶尔吱嘎,水雾凝结滴落", "negative_prompt": "noisy, low quality, distorted, robotic, bad audio", "model_type": "AudioLDM_3", "voice_type": "narration", "audio_style": "cinematic", "voice_character": "", "voice_description": "deep, resonant, calm, slightly melancholic", "speed": 1, "pitch_shift": 0, "emotion": "melancholic", "stability": 0.7, "duration_seconds": 4.63, "sound_attributes": { "intensity": 0.8, "reverb": 0.3 }, "format": "wav", "sample_rate": 24000, "seed": 751512420, "scene_context": "late night, dim apartment living room, heavy rain outside, silent TV, old photo album, condensation on glass", "previous_audio_id": null } }, { "fragment_id": "frag_002", "prompt": "medium shot, cinematic lighting, heavy rain outside window, Lin Ran wrapped in gray worn wool blanket, curled up on sofa, phone screen lights up showing 'Unknown Number', staring at screen for three seconds, finger hovering over answer button, throat moving slightly, finally pressing answer button, bringing phone to ear, tense atmosphere, Fujifilm ETERNA grading, natural overcast, 35mm lens\n\n中景镜头:窗外大雨,林然裹着灰色旧羊毛毯蜷在沙发上,手机屏幕亮起显示'未知号码',盯着屏幕看了三秒,指尖悬停在接听键上方,喉头轻轻滚动,终于按下接听,将手机贴到耳边,紧张氛围,富士ETERNA色调,阴天自然光,35mm镜头", "negative_prompt": "blurry screen, wrong blanket color, smiling, bright lighting, cartoon style", "main_character": "", "duration": 2, "model": "runway_gen2", "style": "cinematic realism, Fujifilm ETERNA", "requires_special_attention": false, "audio": { "audio_id": "audio_002", "prompt": "continuous heavy rain outside window, phone vibrating, brief silence, soft breathing, rain pattering on glass\n\n窗外持续的大雨声,手机震动声,短暂沉默,轻柔的呼吸声,雨点打在玻璃上的声音", "negative_prompt": "noisy, low quality, distorted, robotic, bad audio", "model_type": "AudioLDM_3", "voice_type": "narration", "audio_style": "cinematic", "voice_character": "Lin Ran", "voice_description": "soft female voice, slightly trembling, tense", "speed": 1, "pitch_shift": 0, "emotion": "tense", "stability": 0.7, "duration_seconds": 2, "sound_attributes": { "intensity": 0.8, "reverb": 0.3 }, "format": "wav", "sample_rate": 24000, "seed": 751512420, "scene_context": "Lin Ran in dark living room, heavy rain outside, phone vibrating with unknown caller", "previous_audio_id": "audio_001" } }, { "fragment_id": "frag_003", "prompt": "extreme close-up, cinematic lighting, dim apartment, Lin Ran pressing black smartphone to ear, rain against window, tense atmosphere, shallow depth of field, Fujifilm ETERNA grading, natural overcast, 35mm lens\n\n极端特写镜头:林然将黑色手机贴紧耳边,窗外大雨,紧张氛围,浅景深,富士ETERNA色调,阴天自然光,35mm镜头", "negative_prompt": "blurry phone, wrong phone color, smiling, bright lighting, cartoon style", "main_character": "", "duration": 3, "model": "runway_gen2", "style": "cinematic realism, Fujifilm ETERNA", "requires_special_attention": false, "audio": { "audio_id": "audio_003", "prompt": "continuous heavy rain, faint static from phone, low male voice whispering 'It's me', tense silence\n\n持续的大雨声,手机微弱的静电声,低沉男声低语'是我',紧张的沉默", "negative_prompt": "noisy, low quality, distorted, robotic, bad audio", "model_type": "AudioLDM_3", "voice_type": "character_dialogue", "audio_style": "cinematic", "voice_character": "陈默", "voice_description": "low, husky male voice, tense and mysterious", "speed": 1, "pitch_shift": -2, "emotion": "tense", "stability": 0.7, "duration_seconds": 3, "sound_attributes": { "intensity": 0.8, "reverb": 0.3 }, "format": "wav", "sample_rate": 24000, "seed": 751512420, "scene_context": "close-up of Lin Ran holding phone to ear in dim apartment, heavy rain outside", "previous_audio_id": "audio_002" } } ] } Docker 快速部署
# Docker Compose 配置文件 wget https://raw.githubusercontent.com/neopen/story-shot-agent/main/docker-compose.yml # penshot 配置文件 wget https://raw.githubusercontent.com/neopen/story-shot-agent/main/.env.example -O .env 2. 配置环境变量
修改 .env 文件,填入你的 OpenAI API Key 及相关模型配置:vim .env
如果不想下载 Compose 文件,只希望直接执行 docker run 命令启动容器,可以通过 -e 参数直接将配置注入容器内部。
密码为 123456,host.docker.internal 表示自动映射的宿主机IP
############ Linux 版 docker run -d \ --name penshot \ -p 8000:8000 \ -e PENSHOT_LLM__DEFAULT__BASE_URL="https://api.deepseek.com" \ -e PENSHOT_LLM__DEFAULT__API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxx" \ -e PENSHOT_LLM__DEFAULT__MODEL_NAME="deepseek-v4-flash" \ -e PENSHOT_EMBED__DEFAULT__BASE_URL="https://dashscope-intl.aliyuncs.com/api/v1" \ -e PENSHOT_EMBED__DEFAULT__API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxx" \ -e PENSHOT_EMBED__DEFAULT__MODEL_NAME="text-embedding-v4" \ -e PENSHOT_REDIS_URL="redis://123456:@host.docker.internal:6379/0" \ ghcr.io/neopen/penshot:latest ############ Windows 版 docker run -d ` --name penshot ` -p 8000:8000 ` -e PENSHOT_LLM__DEFAULT__BASE_URL="https://api.deepseek.com" ` -e PENSHOT_LLM__DEFAULT__API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxx" ` -e PENSHOT_LLM__DEFAULT__MODEL_NAME="deepseek-v4-flash" ` -e PENSHOT_EMBED__DEFAULT__BASE_URL="https://dashscope-intl.aliyuncs.com/api/v1" ` -e PENSHOT_EMBED__DEFAULT__API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxx" ` -e PENSHOT_EMBED__DEFAULT__MODEL_NAME="text-embedding-v4" ` -e PENSHOT_REDIS_URL="redis://:@host.docker.internal:6379/0?protocol=2" ` neotems/penshot:latest 系统说明与注意事项
针对 Sora、Pika 等模型的提示词格式专项适配
角色/场景参考图接入与多格式导出(XML/EDL/JSON)
专业剪辑软件插件(Premiere/FCP/DaVinci)
欢迎通过 Issue 或 Pull Request 参与项目共建:
git clone https://github.com/neopen/story-shot-agent.git cd story-shot-agent pip install -e ".[dev]" pytest tests/ 许可证
本项目采用 MIT 开源协议,详见 LICENSE 文件。
MIT © 2025 HiPeng (NeoPen)
本项目采用 MIT 开源协议,您可以自由使用、修改和分发,只需保留原始版权声明。
GitHub:https://github.com/neopen/story-shot-agent
文档:https://shot.helpenx.com/docs/
感谢 LangChain、LangGraph、Chroma、Ollama 及开源社区的技术支持。如本项目对您的工作有帮助,欢迎 Star 关注与反馈。
Both files in this release have provenance metadata.
text-to-video script-to-prompt langgraph llm-agent prompt-engineering video-consistency ai-video-generation screenplay-parser mcp-protocol rest-api function-calling sora runway kling stable-video-diffusion 文生视频 剧本解析 剧本分镜 视频分镜 分镜生成 提示词工程 AI视频
Development Status 4 - Beta
Intended Audience Developers
License OSI Approved :: MIT License
Operating System OS Independent
Programming Language Python :: 3
Scientific/Engineering :: Artificial Intelligence
Software Development :: Libraries :: Python Modules
Release files for penshot 0.3.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 1.7 MB
Release files / penshot-0.3.12.tar.gz
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Release files / penshot-0.3.12-py3-none-any.whl
Security for penshot 0.3.12
Both files in this release have been uploaded with provenance metadata.
With provenance penshot-0.3.12.tar.gz Nov 1, 2026
With provenance penshot-0.3.12-py3-none-any.whl Nov 1, 2026
Attestation for penshot-0.3.12.tar.gz
Attestation for penshot-0.3.12-py3-none-any.whl
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Nov 26, 2026 2 release files Full provenance
Nov 21, 2026 2 release files Full provenance
Nov 20, 2026 2 release files Full provenance
Nov 17, 2026 2 release files Full provenance
Nov 14, 2026 2 release files Full provenance
Nov 11, 2026 2 release files Full provenance
Nov 9, 2026 2 release files Full provenance
Nov 6, 2026 2 release files Full provenance
Nov 5, 2026 2 release files Full provenance
Nov 3, 2026 2 release files Full provenance
Nov 1, 2026 2 release files Full provenance
Oct 14, 2026 2 release files Full provenance
Oct 13, 2026 2 release files Full provenance
Sep 19, 2026 2 release files Full provenance
Sep 2, 2026 2 release files Full provenance
Jul 23, 2026 2 release files Full provenance
Jul 17, 2026 2 release files Full provenance
May 21, 2026 2 release files Full provenance
May 15, 2026 2 release files Full provenance
May 5, 2026 2 release files Full provenance
May 3, 2026 2 release files Full provenance
Apr 27, 2026 2 release files Full provenance
Apr 8, 2026 2 release files Full provenance
Apr 6, 2026 2 release files Full provenance
Apr 1, 2026 2 release files Full provenance
Mar 29, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation




