AI 影片導演技能 (v3 — 沙箱與雲端就緒)
概述
此技能可直接根據 說話者的內容,將原始談話頭影片轉化為緊湊且引人入勝的影片。在 v3 版本中,預設管道 無需安裝任何 Python 套件——僅使用 Python 標準函式庫 + FFmpeg,因此可直接在 Gemini、Claude 或任何沙箱化的代理環境中執行。
核心工作流程 (零相依性模式 — 預設)
步驟 1:偵測語音與修剪靜音
執行 scripts/auto_cut_ffmpeg.py 以自動偵測靜音間隙並產生乾淨的 suggested_cuts:
python3 scripts/auto_cut_ffmpeg.py --input raw_video.mp4 --output work/cuts.json --noise -30dB --min-silence 0.5
步驟 2:分析語音與建立 work/edit_plan.json
利用你對影片原生的多模態理解(或使用者提供的逐字稿)來:
- 審閱
work/cuts.json中的suggested_cuts,並移除任何錯誤開始或重拍的片段。 - 識別關鍵的口語視覺提示(產品、技術術語、優點、步驟),並將其對應到同步於修剪後時間軸的
overlays(image或text)。
寫入 work/edit_plan.json:
{
"source_video": "raw_video.mp4",
"cuts": [
{ "start": 0.4, "end": 8.2 },
{ "start": 10.1, "end": 22.5 }
],
"overlays": [
{
"type": "image",
"asset_path": "assets/overlay.png",
"start": 3.5,
"end": 6.0,
"position": "top_right",
"scale_width": 320
},
{
"type": "text",
"text": "關鍵重點",
"start": 8.5,
"end": 11.0,
"position": "bottom_center"
}
]
}
步驟 3:渲染最終影片
執行 scripts/render_video.py 以套用修剪、合成疊層、標準化音訊 (-14 LUFS),並匯出最終的 MP4 檔案:
python3 scripts/render_video.py --plan work/edit_plan.json --output final_video.mp4
可選的本地端強化功能
當在已安裝 requirements.txt 的本地機器上執行時:
- 逐字轉錄: 使用
scripts/transcribe_and_cut.py(faster-whisper) 來取代步驟 1。 - 背景更換: 在步驟 3 之前執行
scripts/swap_background.py(rembg+u2net_human_seg),並將source_video指向work/swapped.mp4。
保護措施
- 沙箱優先: 在聊天沙箱內一律預設使用
auto_cut_ffmpeg.py+render_video.py,以確保技能不會因缺少 pip 套件而失敗。 - 非破壞性: 絕不覆寫
raw_video.mp4。 - 優雅降級: 如果
image疊層檔案不存在,則跳過該疊層或回退為乾淨的text標註。