# 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": "FILM VFI",
"inputs": {
"ckpt_name": "film_net_fp32.pt",
"clear_cache_after_n_frames": 10,
"frames": [
"3",
0
],
"multiplier": 2
},
"_meta": {
"title": "FILM VFI"
}
},
"3": {
"class_type": "VHS_LoadVideo",
"inputs": {
"custom_height": 0,
"custom_width": 0,
"force_rate": 0,
"format": "AnimateDiff",
"frame_load_cap": 0,
"select_every_nth": 1,
"skip_first_frames": 0,
"video": "UPLOADED_video_FILENAME"
},
"_meta": {
"title": "Load Video (Upload) 🎥🅥🅗🅢"
}
},
"4": {
"class_type": "VHS_VideoCombine",
"inputs": {
"crf": 12,
"filename_prefix": "AnimateDiff",
"format": "video/h264-mp4",
"frame_rate": [
"5",
0
],
"images": [
"1",
0
],
"loop_count": 0,
"pingpong": False,
"pix_fmt": "yuv420p",
"save_metadata": True,
"save_output": True,
"trim_to_audio": False
},
"_meta": {
"title": "Video Combine 🎥🅥🅗🅢"
}
},
"5": {
"class_type": "VHS_VideoInfo",
"inputs": {
"video_info": [
"3",
3
]
},
"_meta": {
"title": "Video Info 🎥🅥🅗🅢"
}
}
})
workflow.set_input("3", "video", client.assets.from_url("https://comfy.org/catalog-media/fd8480d5-11c6-45c4-9b03-40130b889e4c/7aae2304-ea01-44b8-b390-50dfcfa16c2d"))
# 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("4"):
output.to_file(output.name)