HyperFrames CLI
所有操作皆透過 npx hyperframes 執行。需要 Node.js >= 22 與 FFmpeg。
工作流程
- 初始化 —
npx hyperframes init my-video - 撰寫 — 編輯 HTML 合成內容 (請參閱
hyperframes技能) - 檢查 —
npx hyperframes lint - 視覺檢查 —
npx hyperframes inspect - 預覽 —
npx hyperframes preview - 渲染 —
npx hyperframes render
在預覽前先執行 lint 和 inspect。lint 會捕捉遺失的 data-composition-id、重疊的軌道及未註冊的時間軸。inspect 會在無頭 Chrome 中開啟渲染後的合成,掃描時間軸,並回報文字溢出對話框/容器或畫布的問題。
初始化
npx hyperframes init my-video # 互動式精靈
npx hyperframes init my-video --example warm-grain # 選擇範例
npx hyperframes init my-video --video clip.mp4 # 搭配影片檔案
npx hyperframes init my-video --audio track.mp3 # 搭配音訊檔案
npx hyperframes init my-video --example blank --tailwind # 搭配 Tailwind v4 瀏覽器執行階段
npx hyperframes init my-video --non-interactive # 跳過提示 (CI/代理)
範本:blank, warm-grain, play-mode, swiss-grid, vignelli, decision-tree, kinetic-type, product-promo, nyt-graph。
init 會建立正確的檔案結構、複製媒體檔案、使用 Whisper 轉錄音訊,並安裝 AI 編碼技能。請使用此指令而非手動建立檔案。
使用 --tailwind 時,請在編輯類別或主題代碼前先呼叫 tailwind 技能。該初始化動作使用 Tailwind v4.2 的瀏覽器執行階段,而非 Studio 的 Tailwind v3 設定。
程式碼檢查
npx hyperframes lint # 目前目錄
npx hyperframes lint ./my-project # 指定專案
npx hyperframes lint --verbose # 顯示資訊層級發現
npx hyperframes lint --json # 機器可讀格式
檢查 index.html 及 compositions/ 目錄中所有檔案。回報錯誤(必須修正)、警告(建議修正)及資訊(搭配 --verbose)。
視覺檢查
npx hyperframes inspect # 檢查時間軸上的渲染佈局
npx hyperframes inspect ./my-project # 指定專案
npx hyperframes inspect --json # 代理可讀的發現結果
npx hyperframes inspect --samples 15 # 更密集的時間軸掃描
npx hyperframes inspect --at 1.5,4,7.25 # 指定主要影格時間戳記
請在 lint 和 validate 之後使用此指令,尤其適用於包含對話框、卡片、字幕或緊湊排版的合成內容。它會回報:
- 文字超出最近的視覺容器或對話框
- 文字被自身的固定寬度/高度框裁切
- 文字超出合成畫布邊界
- 子元素逃逸裁剪容器
錯誤應在渲染前修正。警告則供代理審查;加上 --strict 可讓警告也導致失敗。重複的靜態問題預設會被摺疊,讓 JSON 輸出保持簡潔以利 LLM 內容視窗。若溢出是為了入場/出場動畫而刻意為之,請在元素或祖先標記 data-layout-allow-overflow。若裝飾性元素不應被審計,請標記 data-layout-ignore。
npx hyperframes layout 仍然可作為相同視覺檢查的相容別名使用。
預覽
npx hyperframes preview # 提供目前目錄服務
npx hyperframes preview --port 4567 # 自訂連接埠(預設 3002)
檔案變更時會熱重新載入。瀏覽器會自動開啟 Studio。
將專案交回給使用者時,請使用 Studio 專案網址,而非原始 index.html 路徑:
http://localhost:<port>/#project/<project-name>
請使用預覽輸出中的實際連接埠以及專案目錄名稱。例如,在 codex-openai-video 目錄中執行 npx hyperframes preview --port 3017 後,回報 http://localhost:3017/#project/codex-openai-video。
請將 index.html 僅視為原始程式碼上下文。將其連結為實作檔案是可以的,但不要將其標示為專案或預覽表面。
渲染
npx hyperframes render # 標準 MP4
npx hyperframes render --output final.mp4 # 指定輸出檔名
npx hyperframes render --quality draft # 快速迭代
npx hyperframes render --fps 60 --quality high # 最終交付
npx hyperframes render --format webm # 透明背景 WebM
npx hyperframes render --docker # 位元組一致輸出
| 標記 | 選項 | 預設值 | 備註 |
|---|---|---|---|
--output | 路徑 | renders/name_timestamp.mp4 | 輸出路徑 |
--fps | 24, 30, 60 | 30 | 60fps 渲染時間加倍 |
--quality | draft, standard, high | standard | draft 用於迭代 |
--format | mp4, webm | mp4 | WebM 支援透明背景 |
--workers | 1-8 或 auto | auto | 每個 worker 會啟動一個 Chrome |
--docker | 布林標記 | 關閉 | 可重現的輸出 |
--gpu | 布林標記 | 關閉 | GPU 加速編碼 |
--strict | 布林標記 | 關閉 | 遇到 lint 錯誤即失敗 |
--strict-all | 布林標記 | 關閉 | 遇到錯誤與警告即失敗 |
--variables | JSON 物件 | — | 覆蓋 data-composition-variables 中宣告的變數值 |
--variables-file | 路徑 | — | 包含變數值的 JSON 檔案(--variables 的替代方案) |
--strict-variables | 布林標記 | 關閉 | 遇到 --variables 中未宣告的鍵值或型別不符時渲染失敗 |
品質指引: 迭代時使用 draft,審查時使用 standard,最終交付時使用 high。
參數化渲染: 合成內容在 <html> 根元素上使用 data-composition-variables 宣告變數 — 這是一個 宣告陣列 的 JSON(每個條目包含 {id, type, label, default}),定義了架構。內部的腳本透過 window.__hyperframes.getVariables() 讀取解析後的值。CLI 的 --variables '{"title":"Q4 Report"}' 是一個以 id 為鍵的 JSON 物件,用來覆蓋這些宣告的預設值以進行一次渲染;缺少的鍵會沿用預設值,因此同一個合成可在開發預覽與生產環境中原封不動地執行。(子合成宿主也可以透過 data-variable-values 對每個實例進行覆蓋 — 物件結構相同,作用範圍是子合成的一次掛載。完整模式請參閱 hyperframes 技能。)
資產預處理
npx hyperframes tts, transcribe, 和 remove-background 會產生資產(旁白音訊、逐字稿、透明背景影片),這些資產會被放入合成中。每個指令首次執行時會下載自己的模型。關於語音選擇、Whisper 模型規則(.en 會將非英文翻譯成英文的陷阱)、輸出格式選擇(VP9 Alpha WebM vs ProRes)以及 TTS → 轉錄 → 字幕鏈,請呼叫 hyperframes-media 技能。
疑難排解
npx hyperframes doctor # 檢查環境 (Chrome, FFmpeg, Node, 記憶體)
npx hyperframes browser # 管理內建 Chrome
npx hyperframes info # 版本與環境詳細資訊
npx hyperframes upgrade # 檢查更新
若渲染失敗,請先執行 doctor。常見問題:缺少 FFmpeg、缺少 Chrome、記憶體不足。
其他
npx hyperframes compositions # 列出專案中的合成
npx hyperframes docs # 開啟文件
npx hyperframes benchmark . # 測試渲染效能