Communitygithub.com

Capy 影片生成技能 - 腳本轉影片流程

多重鏡頭 AI 影片生成流程,具備臉部身份一致性。可將腳本或點子轉換成完整影片,包含角色提取、分鏡設計、影格生成與影片組合。經過 300 次實驗驗證,臉部距離改善 70%。

Capy 影片生成技能 - 腳本轉影片流程 是什麼?

此技能提供一個完整的自動化流程,可將文字腳本或簡短點子轉換為多鏡頭影片,並確保所有場景中的角色臉部身份一致。它專為 HappyCapy AI Gateway 構建,經過 300 次實驗驗證,臉部距離指標改善了 70%。流程包含角色提取(包含詳細的身體特徵)、正/側/背面肖像生成、逐鏡頭分鏡設計、關鍵影格與動作描述生成、攝影機關係樹建立、基於參考影像(以臉部身份為最高優先級)的影格生成、影片片段生成及最終拼接。支援透過 HappyCapy API 使用 Gemini 進行影像生成與 Veo 進行影片生成,並可透過使用者提供的參考照片跳過 AI 肖像生成。程式化 API 允許自定義腳本、需求與風格,並提供詳細的輸出結構便於檢查。

相容平台~Claude Code✓Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/happycapy-ai/Happycapy-skills/capy-video-gen-skill

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Capy 影片生成技能 - 腳本轉影片流程 是做什麼的?

從腳本或點子生成完整的多鏡頭影片,且所有場景中角色臉部保持一致。專為 HappyCapy AI Gateway 構建。經過 300 次實驗驗證,臉部距離改善 70%。

概述

ViMax 透過自動化流程將文字腳本轉換為完整影片:

  1. 從腳本中提取角色,包含詳細的身體特徵
  2. 為每個角色生成正面、側面、背面肖像
  3. 設計逐鏡頭的分鏡表
  4. 將每個鏡頭分解為第一影格、最後影格與動作描述
  5. 建立鏡頭關係的攝影機樹
  6. 使用參考影像選擇(臉部身份為最高優先級)生成影格
  7. 從影格生成影片片段
  8. 拼接成最終影片

安裝位置

ViMax 流程代碼位於:/home/node/a0/workspace/527fb591-1439-4b5b-ad5d-90f972773f95/workspace/tmp/ViMax/

所有指令都必須從此目錄使用 venv 執行:

cd /home/node/a0/workspace/527fb591-1439-4b5b-ad5d-90f972773f95/workspace/tmp/ViMax

先決條件

  • AI_GATEWAY_API_KEY 環境變數(在 HappyCapy 中自動設定)
  • Python venv 位於 .venv/(已設定完成)

快速開始

腳本轉影片

編輯入口腳本中的腳本、需求與風格,然後執行:

cd /home/node/a0/workspace/527fb591-1439-4b5b-ad5d-90f972773f95/workspace/tmp/ViMax
.venv/bin/python main_happycapy_script2video.py

點子轉影片

從簡短點子生成(先自動產生腳本):

cd /home/node/a0/workspace/527fb591-1439-4b5b-ad5d-90f972773f95/workspace/tmp/ViMax
.venv/bin/python main_happycapy_idea2video.py

程式化使用

import asyncio
from langchain.chat_models import init_chat_model
from tools.render_backend import RenderBackend
from utils.config_loader import load_config
from pipelines.script2video_pipeline import Script2VideoPipeline

config = load_config("configs/happycapy_script2video.yaml")
chat_model = init_chat_model(**config["chat_model"]["init_args"])
backend = RenderBackend.from_config(config)

pipeline = Script2VideoPipeline(
    chat_model=chat_model,
    image_generator=backend.image_generator,
    video_generator=backend.video_generator,
    working_dir=config["working_dir"],
)

# 執行流程
asyncio.run(pipeline(
    script="在此輸入您的腳本...",
    user_requirement="總共不超過 8 個鏡頭。",
    style="電影風格,溫暖燈光"
))

流程

Script2VideoPipeline

  • 輸入:格式化的劇本/腳本,包含角色對話與場景描述
  • 輸出:拼接完成的影片,位於 {working_dir}/final_video.mp4
  • 設定檔:configs/happycapy_script2video.yaml

Idea2VideoPipeline

  • 輸入:簡短的點子/概念(1-3 段落)
  • 輸出:自動產生腳本,然後生成影片
  • 設定檔:configs/happycapy_idea2video.yaml

設定

HappyCapy 設定檔位於 configs/happycapy_script2video.yaml:

chat_model:
  init_args:
    model: gpt-4.1
    model_provider: openai
    api_key: ${AI_GATEWAY_API_KEY}
    base_url: https://ai-gateway.happycapy.ai/api/v1/openai/v1

image_generator:
  class_path: tools.ImageGeneratorHappyCapyAPI
  init_args:
    api_key: ${AI_GATEWAY_API_KEY}
    model: google/gemini-3.1-flash-image-preview

video_generator:
  class_path: tools.VideoGeneratorHappyCapyAPI
  init_args:
    api_key: ${AI_GATEWAY_API_KEY}
    model: google/veo-3.1-generate-preview

working_dir: .working_dir/script2video

關鍵元件

代理器(AI 處理)

代理器檔案用途
CharacterExtractoragents/character_extractor.py從腳本中提取角色,包含靜態/動態特徵
CharacterPortraitsGeneratoragents/character_portraits_generator.py為每個角色生成正面/側面/背面肖像
StoryboardArtistagents/storyboard_artist.py設計逐鏡頭分鏡表,包含第一/最後影格與動作
ReferenceImageSelectoragents/reference_image_selector.py為每個影格選擇最佳參考影像(臉部身份為第一優先)
CameraImageGeneratoragents/camera_image_generator.py建立攝影機樹並生成轉場影片
BestImageSelectoragents/best_image_selector.py從候選影像中選擇最佳生成的影像
Screenwriteragents/screenwriter.py從點子生成腳本

工具(生成後端)

工具檔案用途
ImageGeneratorHappyCapyAPItools/image_generator_happycapy_api.py透過 HappyCapy Gateway 進行影像生成(Gemini)
VideoGeneratorHappyCapyAPItools/video_generator_happycapy_api.py透過 HappyCapy Gateway 進行影片生成(Veo)
RenderBackendtools/render_backend.py用於從設定實例化生成器的工廠

介面(資料模型)

  • CharacterInScene - 包含識別碼、靜態特徵、動態特徵的角色
  • ShotDescription - 包含第一影格描述、最後影格描述、動作描述、變化類型的鏡頭
  • Camera - 包含父子關係的攝影機
  • Frame - 包含鏡頭索引、影格類型、可見角色的影格
  • ImageOutput / VideoOutput - 包含儲存方法的生成輸出

臉部身份一致性(關鍵)

此流程包含經 257 次實驗驗證的臉部身份改善(臉部距離改善 70%,從 0.74 降至 0.22):

內建保護機制

  1. 參考影像選擇器:選擇參考影像時,臉部身份為第一優先。當角色臉部可見時,正面肖像始終包含在內。

  2. 角色肖像:增強的提示詞可生成身份關鍵細節(確切的鼻形、眼距、下巴線條、區別標記),利於跨場景辨識。

  3. 影片提示臉部鎖定:每個影片生成提示詞前綴都會加上臉部身份指令,要求角色臉部在整個片段中與起始影格保持一致。

使用 ViMax 的最佳實務

  • 超詳細角色描述:在腳本的角色介紹中包含種族、年齡、髮質/髮型/髮色、眼睛形狀、鬍鬚、眼鏡、膚色、體型與區別標記
  • 極特寫鏡頭:至少為每個角色包含一個極特寫鏡頭,以鎖定身份
  • 一致的燈光:指定跨場景相似的燈光,防止臉部偏移
  • 使用者提供的參考照片:將照片放入工作目錄,並作為 character_portraits_registry 傳入,跳過 AI 肖像生成

無效的方法

  • 複雜的提示工程(viseme 變形、音素錨定)無法改善臉部身份
  • 簡單直接的提示詞搭配詳細身體描述,效果優於花俏的提示詞
  • 無法對外部音訊進行唇形同步(Veo 會生成自己的內部音訊)

詳情請參閱 ViMax 目錄中的 FACE_IDENTITY_GUIDE.md。

輸出結構

執行後,工作目錄包含:

.working_dir/script2video/
  characters.json                      # 提取的角色
  character_portraits_registry.json    # 肖像路徑註冊表
  character_portraits/                 # 生成的肖像
    0_CharacterName/
      front.png
      side.png
      back.png
  storyboard.json                     # 鏡頭描述
  camera_tree.json                    # 攝影機關係
  shots/
    0/
      shot_description.json
      first_frame.png
      last_frame.png (如果是中/大變化)
      video.mp4
    1/
      ...
  final_video.mp4                     # 最終拼接輸出

自訂

使用您自己的參考照片

若要使用真實照片而非 AI 生成的肖像:

# 建立指向您照片的肖像註冊表
character_portraits_registry = {
    "Alice": {
        "front": {"path": "/path/to/alice_front.png", "description": "Alice 正面"},
        "side": {"path": "/path/to/alice_side.png", "description": "Alice 側面"},
        "back": {"path": "/path/to/alice_back.png", "description": "Alice 背面"},
    }
}

# 傳入流程(跳過肖像生成)
await pipeline(
    script=script,
    user_requirement=user_requirement,
    style=style,
    character_portraits_registry=character_portraits_registry,
)

更換模型

編輯 YAML 設定以使用不同模型:

  • 影像:google/gemini-3.1-flash-image-preview(建議用於臉部身份)
  • 影片:google/veo-3.1-generate-preview(建議)或 openai/sora-2
  • 對話:gpt-4.1(建議)或任何 OpenAI 相容模型

疑難排解

「No module named 'tools'」或類似匯入錯誤

從 ViMax 根目錄執行:

cd /home/node/a0/workspace/527fb591-1439-4b5b-ad5d-90f972773f95/workspace/tmp/ViMax
.venv/bin/python main_happycapy_script2video.py

API 速率限制錯誤

在 YAML 設定中降低 max_requests_per_minute。

生成影片中臉部身份偏移

  • 在腳本的角色描述中加入更多身體細節
  • 使用使用者提供的參考照片而非 AI 生成的肖像
  • 為重要角色包含極特寫鏡頭
  • 保持跨場景燈光一致

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

相關技能