Utility Merge Video
使用 Utility Merge Videos(子圖)串接兩段影片。
工作流程內部
來源範本的唯讀預覽。請在 Cloud 中開啟,以探索節點並進行變更。
Loading the graph
Open full-size workflow preview- 輸出
- 影片
- 作者
- ComfyUI
從您的程式碼呼叫此模型
以下請求使用與 Playground 相同的已準備節點圖和設定。每次提交都可能啟動付費執行;若提交結果不明,請勿自動重試提交。
What you need
- Runs on
- Comfy Cloud
- 金鑰
- COMFY_API_KEY
- 您的檔案
- 由程式碼透過其 URL 上傳
需要付費 Cloud 方案與點數。
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"2": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_2_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"3": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_1_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"13": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_2_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"14": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_1_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"27": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"498:482",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"498:482": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"498:496",
0
],
"on_true": [
"498:491",
0
],
"switch": False
},
"_meta": {
"title": "If/Else Switch"
}
},
"498:483": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"14",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"498:484": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"13",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"498:485": {
"class_type": "BatchImagesNode",
"inputs": {
"images.image0": [
"498:483",
0
],
"images.image1": [
"498:484",
0
]
},
"_meta": {
"title": "Batch Images"
}
},
"498:486": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"498:487",
0
],
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"498:483",
2
],
"images": [
"498:485",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"498:487": {
"class_type": "AudioConcat",
"inputs": {
"audio1": [
"498:483",
1
],
"audio2": [
"498:484",
1
],
"direction": "after"
},
"_meta": {
"title": "Concatenate Audio"
}
},
"498:488": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"498:496",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"498:489": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"498:486",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"498:490": {
"class_type": "BatchImagesNode",
"inputs": {
"images.image0": [
"498:488",
0
],
"images.image1": [
"498:489",
0
]
},
"_meta": {
"title": "Batch Images"
}
},
"498:491": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"498:492",
0
],
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"498:488",
2
],
"images": [
"498:490",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"498:492": {
"class_type": "AudioConcat",
"inputs": {
"audio1": [
"498:488",
1
],
"audio2": [
"498:489",
1
],
"direction": "after"
},
"_meta": {
"title": "Concatenate Audio"
}
},
"498:493": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"3",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"498:494": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"2",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"498:495": {
"class_type": "BatchImagesNode",
"inputs": {
"images.image0": [
"498:493",
0
],
"images.image1": [
"498:494",
0
]
},
"_meta": {
"title": "Batch Images"
}
},
"498:496": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"498:497",
0
],
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"498:493",
2
],
"images": [
"498:495",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"498:497": {
"class_type": "AudioConcat",
"inputs": {
"audio1": [
"498:493",
1
],
"audio2": [
"498:494",
1
],
"direction": "after"
},
"_meta": {
"title": "Concatenate Audio"
}
}
})
workflow.set_input("3", "file", client.assets.from_url("https://comfy.org/catalog-media/5e42bcb0-8679-4b9f-b107-58361ec35ea2/6e6eede3-7e1c-49a8-8c5c-185adbd776d7"))
workflow.set_input("14", "file", client.assets.from_url("https://comfy.org/catalog-media/5e42bcb0-8679-4b9f-b107-58361ec35ea2/6e6eede3-7e1c-49a8-8c5c-185adbd776d7"))
workflow.set_input("2", "file", client.assets.from_url("https://comfy.org/catalog-media/ac1f2ff9-3684-4eb3-90b6-f3878432cf5c/41471c67-b27d-4508-83d6-600a29306fbe"))
workflow.set_input("13", "file", client.assets.from_url("https://comfy.org/catalog-media/ac1f2ff9-3684-4eb3-90b6-f3878432cf5c/41471c67-b27d-4508-83d6-600a29306fbe"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("27"):
output.to_file(output.name)試試範例
關於此工作流程
Utility Merge Video 是一個簡單可靠的 ComfyUI 工作流程,用於將多段影片首尾串接。流程使用兩個或四個 LoadVideo 節點將來源檔案解碼為影格批次,傳入 Utility Merge Videos(子圖)節點(ID: fbb76376-8768-4ece-9b41-a646f5e46ac3),依序串接這些影格序列。合併後的影格會用 SaveVideo 寫入磁碟。
技術上,子圖是將批次串接(非合成),所以結果會依序播放每段影片。Utility Merge Videos 子圖內有開關可選 2 輸入或 4 輸入模式。所有輸入必須解析度一致,否則合併時會出錯。SaveVideo 節點可設定輸出路徑、副檔名(如 .mp4)、播放 FPS,最終 FPS 以此為準。流程內的 MarkdownNote 節點提供操作提醒。
問答
所有輸入的解析度必須一致。最終播放 FPS 以 SaveVideo 節點為準。若來源 FPS 不同,影格仍會被串接,但輸出會以你在 SaveVideo 選擇的 FPS 播放。
依你想要的順序,將 LoadVideo 的輸出連到 Utility Merge Videos 的輸入(A、B、C、D)。子圖會依輸入順序進行串接。
此工作流程以視覺影格為主。許多 SaveVideo 設定不會封裝音訊。若需要音訊,可在匯出後用外部工具重新封裝,或在你的環境可用時擴充圖形加入支援音訊的節點。
可以。你可以多次執行工作流程串接合併(例如先合併四段,再把結果與更多片段合併),或複製子圖建立更長的串接鏈。