影片長寬比延展
將任意影片延展為自訂長寬比。可將直式影片轉為橫式,反之亦然。內建應用模式,操作簡便。
關於
本 ComfyUI 工作流程可將直式影片轉為橫式(或反向),透過外繪新增畫布區域,保留原始內容。流程以 LoadVideo 與 GetVideoComponents 取得畫格、FPS 與音訊,再用 JWImageResizeByShorterSide 正規化畫格尺寸,使短邊符合目標解析度。遮罩階段由 masquerade-nodes-comfyui 與自訂節點(UUID: 7594b5c0-2b90-4aeb-846b-e3eb8fa89f33)定義需合成新內容與保留來源的位置。核心轉換由 KlingOmniProEditVideoNode 執行,運行 Kling O3 模型,針對新增邊帶進行內容感知外繪,達到目標長寬比。Video Slice 支援分片處理,提升穩定性與 VRAM 效率,CreateVideo + SaveVideo 組合並輸出最終影片,GetVideoComponents 可選擇音訊直通。
此流程最大優勢是無需裁切重要畫面,而是透過橫/直偏移重構主體並延展場景,維持動作連貫與主體完整。流程分為三組:輸入影片、影片縮放與延展、影片外繪,並內建應用模式簡化 UI:設定目標長寬比、微調偏移,直接執行。注意:本流程最佳化於 9:16 ↔ 16:9 轉換。若僅需微幅調整或 1:1,建議改用基本裁切/填補。
您提供的內容
- 正在讀取工作流程
在 ComfyUI 中執行。 此工作流程無法在此頁面上執行。請在已載入所有內容的 Comfy Cloud 中開啟,或下載到您自己的 ComfyUI。
在 Cloud 中試用工作流程內部
節點圖的唯讀預覽。請在 Comfy Cloud 中開啟,或下載後編輯節點。
Loading the graph
Open full-size workflow preview- 作者
- ComfyUI
需要自訂節點
- 正在讀取工作流程
從程式碼使用此工作流程
可行時會根據工作流程圖和輸入內容產生;否則會顯示儲存的範例。執行可能產生費用的程式碼前,請檢查認證資訊和端點。
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({
"245": {
"class_type": "KlingOmniProEditVideoNode",
"inputs": {
"keep_original_sound": True,
"model_name": "kling-v3-omni",
"prompt": "remove and outpaint the white borders of the video",
"resolution": "1080p",
"seed": 1652002455,
"video": [
"249",
0
]
},
"_meta": {
"title": "Kling 3.0 Omni Edit Video"
}
},
"247": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"248": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"254",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"249": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"248",
1
],
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"248",
2
],
"images": [
"252:162",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"254": {
"class_type": "Video Slice",
"inputs": {
"duration": 0,
"start_time": 0,
"strict_duration": False,
"video": [
"247",
0
]
},
"_meta": {
"title": "Trim Video"
}
},
"270": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/9x16",
"format": "auto",
"format.codec": "auto",
"video": [
"245",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"302": {
"class_type": "JWImageResizeByShorterSide",
"inputs": {
"image": [
"248",
0
],
"interpolation_mode": "bicubic",
"size": 1080
},
"_meta": {
"title": "Image Resize by Shorter Side"
}
},
"252:152": {
"class_type": "Paste By Mask",
"inputs": {
"image_base": [
"252:230",
0
],
"image_to_paste": [
"252:229",
0
],
"mask": [
"252:229",
0
],
"resize_behavior": "keep_ratio_fit"
},
"_meta": {
"title": "Paste By Mask"
}
},
"252:153": {
"class_type": "ImageToMask",
"inputs": {
"channel": "red",
"image": [
"252:152",
0
]
},
"_meta": {
"title": "Convert Image to Mask"
}
},
"252:162": {
"class_type": "ImageRemoveAlpha+",
"inputs": {
"image": [
"252:165",
0
]
},
"_meta": {
"title": "🔧 Image Remove Alpha"
}
},
"252:163": {
"class_type": "Get Image Size",
"inputs": {
"image": [
"302",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"252:165": {
"class_type": "Paste By Mask",
"inputs": {
"image_base": [
"252:231",
0
],
"image_to_paste": [
"302",
0
],
"mask": [
"252:152",
0
],
"resize_behavior": "keep_ratio_fit"
},
"_meta": {
"title": "Paste By Mask"
}
},
"252:229": {
"class_type": "LayerUtility: ColorImage V2",
"inputs": {
"color": "#ffffff",
"custom_height": [
"252:163",
1
],
"custom_width": [
"252:163",
0
],
"size": "custom"
},
"_meta": {
"title": "LayerUtility: ColorImage V2"
}
},
"252:230": {
"class_type": "LayerUtility: ColorImage V2",
"inputs": {
"color": "#000000",
"custom_height": [
"252:285",
1
],
"custom_width": [
"252:285",
0
],
"size": "custom"
},
"_meta": {
"title": "LayerUtility: ColorImage V2"
}
},
"252:231": {
"class_type": "LayerUtility: ColorImage V2",
"inputs": {
"color": "#ffffff",
"custom_height": [
"252:285",
1
],
"custom_width": [
"252:285",
0
],
"size": "custom"
},
"_meta": {
"title": "LayerUtility: ColorImage V2"
}
},
"252:285": {
"class_type": "ResolutionSelector",
"inputs": {
"aspect_ratio": "9:16 (Portrait Widescreen)",
"megapixels": 2,
"multiple": 8
},
"_meta": {
"title": "Resolution Selector"
}
}
})
# Replace each example.com URL with a public URL of your file.
workflow.set_input("247", "file", client.assets.from_url("https://example.com/replace-with-a-url/video"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)問答
會—若將 GetVideoComponents 音訊接至 CreateVideo,音軌會直通。未接則輸出為無聲。
本流程最佳化於 9:16 ↔ 16:9 轉換。微調或 1:1 請改用基本裁切/填補/縮放流程,不建議用 KlingOmniProEditVideoNode。
減少延展寬度、優化主體遮罩(加寬並微羽化),並用偏移控制主體置中。若有一致性參數,請提高,分片大小建議中等。
1080p 建議 12–16 GB 顯示卡。若 VRAM 不足,請降低 JWImageResizeByShorterSide、減少外繪寬度、縮短分片長度。GetVideoComponents 傳遞原始 FPS 可維持流暢度。