影片風格化 - 逐格處理 - FLUX.2 Klein 4b
用 FLUX.2 Klein 4b Distilled 圖像編輯模型,將輸入影片逐格風格化。
工作流程內部
來源範本的唯讀預覽。請在 Cloud 中開啟,以探索節點並進行變更。
Loading the graph
Open full-size workflow preview從您的程式碼呼叫此模型
以下請求使用與 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({
"1": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"2",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"2": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"28": {
"class_type": "VHS_SelectEveryNthImage",
"inputs": {
"images": [
"1",
0
],
"select_every_nth": [
"157",
0
],
"skip_first_images": 0
},
"_meta": {
"title": "Select Every Nth Image 🎥🅥🅗🅢"
}
},
"104": {
"class_type": "ImpactImageBatchToImageList",
"inputs": {
"image": [
"28",
0
]
},
"_meta": {
"title": "Image Batch to Image List"
}
},
"116": {
"class_type": "FL_PromptMulti",
"inputs": {
"name_prefix": "prompt_",
"negative_text": "",
"positive_text": [
"130",
0
]
},
"_meta": {
"title": "FL Prompt Multi"
}
},
"130": {
"class_type": "GeminiNode",
"inputs": {
"model": "gemini-3-1-flash-lite",
"prompt": [
"173",
0
],
"seed": 131495485131261,
"system_prompt": [
"150",
0
]
},
"_meta": {
"title": "Google Gemini"
}
},
"147": {
"class_type": "CreateVideo",
"inputs": {
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": 8,
"images": [
"165",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"148": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "mp4",
"format.codec": "h264",
"video": [
"147",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"150": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "Return exactly the requested number of newline-separated prompts.\nNo bullets, numbering, JSON, quotes, or commentary.\n\nEach line is a style-transfer prompt for the corresponding source video frame.\nDo not invent subjects or scene details.\nRefer to the image only as “the source frame”.\n\nEach prompt must preserve source frame depth, outlined edges composition and geometry.\n\nEach prompt must be 35 to 55 words.\n"
},
"_meta": {
"title": "System Prompt"
}
},
"155": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"28",
1
]
},
"_meta": {
"title": "Int to String"
}
},
"157": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 4
},
"_meta": {
"title": "Select Every 'Nth' Image"
}
},
"165": {
"class_type": "ImageListToImageBatch",
"inputs": {
"images": [
"146:144",
0
]
},
"_meta": {
"title": "Image List to Image Batch"
}
},
"168": {
"class_type": "RegexReplace",
"inputs": {
"case_insensitive": True,
"count": 0,
"dotall": False,
"multiline": False,
"regex_pattern": "{COUNT}",
"replace": [
"155",
0
],
"string": "Create exactly {COUNT} style-transfer prompts, one per line. Use “the source frame” instead of describing the subject. Assign treatments strictly by prompt number using this repeating cycle:\n\n{FRAME_PROMPTS}\n\nRepeat the cycle after the final prompt."
},
"_meta": {
"title": "Replace Text (Regex)"
}
},
"170": {
"class_type": "RegexReplace",
"inputs": {
"case_insensitive": True,
"count": 0,
"dotall": False,
"multiline": False,
"regex_pattern": "{FRAME_PROMPTS}",
"replace": [
"172",
0
],
"string": [
"168",
0
]
},
"_meta": {
"title": "Replace Text (Regex)"
}
},
"172": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "Each Prompt # should appear 1x before incrementing to the next Prompt #.\n\ntheme: hand-painted gouache animation cels\nPrompt 1: flat opaque gouache fills, visible bristle strokes, warm cream paper showing at the edges, soft pencil underdrawing, muted teal and coral palette.\nPrompt 2: thick ink outlines with slight wobble, chalky pastel washes, dry-brush texture in the sky, sun-faded yellows, tiny paint speckles.\nPrompt 3: layered cut-paper shapes, gentle drop shadows between layers, matte gouache surface, deep ultramarine shadows, sparse white highlights.\nPrompt 4: loose watercolour bleed under the gouache, warm ochre light, soft blooming edges, granulated pigment in the darker areas.\nPrompt 5: bold limited palette of rust, sage and navy, waxy crayon grain over flat colour, rough torn-paper edges, slightly misregistered layers.\nPrompt 6: dusky lilac evening tones, glowing peach highlights, smudged charcoal accents, visible canvas weave, painterly sparkle on the water."
},
"_meta": {
"title": "Frame Prompts"
}
},
"173": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"170",
0
]
},
"_meta": {
"title": "Preview Prompt"
}
},
"146:123": {
"class_type": "ReferenceLatent",
"inputs": {
"conditioning": [
"146:140",
0
],
"latent": [
"146:143",
0
]
},
"_meta": {
"title": "Set Reference Latent"
}
},
"146:135": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "flux-2-klein-4b-fp8.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"146:136": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_3_4b.safetensors",
"device": "default",
"type": "flux2"
},
"_meta": {
"title": "Load CLIP"
}
},
"146:137": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "flux2-vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"146:138": {
"class_type": "EmptyFlux2LatentImage",
"inputs": {
"batch_size": 1,
"height": [
"146:99",
1
],
"width": [
"146:99",
0
]
},
"_meta": {
"title": "Empty Flux 2 Latent"
}
},
"146:139": {
"class_type": "ImageScaleToTotalPixels",
"inputs": {
"image": [
"104",
0
],
"megapixels": 1,
"resolution_steps": 1,
"upscale_method": "nearest-exact"
},
"_meta": {
"title": "Scale Image to Total Pixels"
}
},
"146:140": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"146:136",
0
],
"text": [
"116",
0
]
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"146:141": {
"class_type": "ConditioningZeroOut",
"inputs": {
"conditioning": [
"146:140",
0
]
},
"_meta": {
"title": "Conditioning Zero Out"
}
},
"146:142": {
"class_type": "ReferenceLatent",
"inputs": {
"conditioning": [
"146:141",
0
],
"latent": [
"146:143",
0
]
},
"_meta": {
"title": "Set Reference Latent"
}
},
"146:143": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"146:139",
0
],
"vae": [
"146:137",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"146:144": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"146:64",
0
],
"vae": [
"146:137",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"146:145": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 300402371121536
},
"_meta": {
"title": "RandomNoise"
}
},
"146:61": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"146:62": {
"class_type": "Flux2Scheduler",
"inputs": {
"height": [
"146:99",
1
],
"steps": 4,
"width": [
"146:99",
0
]
},
"_meta": {
"title": "Flux2Scheduler"
}
},
"146:63": {
"class_type": "CFGGuider",
"inputs": {
"cfg": 1,
"model": [
"146:135",
0
],
"negative": [
"146:142",
0
],
"positive": [
"146:123",
0
]
},
"_meta": {
"title": "CFG Guider"
}
},
"146:64": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"146:63",
0
],
"latent_image": [
"146:138",
0
],
"noise": [
"146:145",
0
],
"sampler": [
"146:61",
0
],
"sigmas": [
"146:62",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"146:99": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"146:139",
0
]
},
"_meta": {
"title": "Get Image Size"
}
}
})
workflow.set_input("2", "file", client.assets.from_url("https://comfy.org/catalog-media/3c68d8e2-08ce-417c-bfe6-4c67a357c7c6/c7a288d9-bb67-4b98-b8e0-7e16dfc7086e"))
# 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("148"):
output.to_file(output.name)試試範例
關於此工作流程
此工作流程使用 FLUX.2 Klein 4b Distilled 影像編輯模型,對任何輸入影片進行逐影格、風格一致的風格轉換。它先用 LoadVideo 解碼影片,並透過 GetVideoComponents 讀取解析度/FPS,接著用 VHS_SelectEveryNthImage 決定影格處理密度(每一格都處理,或每 N 格處理一次以加快速度)。影格會用 ImpactImageBatchToImageList 整理,讓每張圖片都能對應到一段逐影格提示。
風格提示會透過一個小型提示管線生成並與影格對齊:GeminiNode 可依 Author Notes 草擬風格轉換的句子,RegexReplace 負責清理與正規化文字(例如移除編號、統一成「the source frame」的表述),FL_PromptMulti 會以循環方式把每段提示分配到各個影格。每個影格與其對應提示會送入 FLUX.2 Klein 4b 編輯節點(FLUX.2 Klein 4b Distilled 影像編輯模型),在保留原始影格結構的前提下產生風格化結果。處理後的圖片會用 ImageListToImageBatch 重新打包,透過 CreateVideo(匹配 GetVideoComponents 的原始 FPS)轉回影片,需要時用 PreviewAny 預覽,最後以 SaveVideo 寫入磁碟。
問答
可貼入多行風格提示詞,或用 GeminiNode 依 Author Notes 模式產生。FL_PromptMulti 會將提示詞一一分配給每格,清單結束後自動循環,確保全片風格規律。
不用。可手動貼入 PrimitiveStringMultiline。GeminiNode 只是輔助草擬,RegexReplace 會自動正規化(如移除編號、強制「the source frame」)。
本流程僅處理逐格視覺風格化。若 CreateVideo/SaveVideo 未保留音訊,可用影片編輯軟體或 ffmpeg 將原音重新合併。
請保持提示詞簡潔一致,並固定提及「the source frame」。避免重複描述主體,風格詞彙要穩定,且建議每格都處理(Nth=1)以提升時間一致性。N 值越大雖加速測試,但跳動感也會增加。
相關工作流程
- Seedance 2.5
Change a video’s background
- LTX-2.3
Remove an object from a video
- LTX-2.3
Expand a video’s frame
- SSCAIL-2
Replace a character in a video
- SSeedVR2
Upscale a video
- LTX-2.3
Restore archival footage
- 合作夥伴節點
AI on the Lot 2026_LTX-2.3_IC LoRA(Union Control)
- Wan2.2, Z-Image-Turbo
AIrt MAchIne
- 合合作夥伴節點
Beeble SwitchX:影片編輯
- BRIA
Bria:去除影片背景
- CCapybara
Capybara:影片編輯
- 合合作夥伴節點
Comfy 廣告用 B-Roll 片段製作