Open JCBrouwer opened 7 months ago
VideoHelperSuite does some hacks to ComfyUI. VHS_VideoCombine
has dynamic inputs depending on what format
is chosen. This is not supported by official ComfyUI and ComfyScript doesn't support it either.
ComfyScript will now ignore any invalid format
values:
ComfyScript: VHS_VideoCombine: Invalid enum value: ['video/av1-webm', [['pix_fmt', ['yuv420p10le', 'yuv420p']], ['crf', 'INT', {'default': 23, 'min': 0, 'max': 100, 'step': 1}], ['input_color_depth', ['8bit', '16bit']], ['save_metadata', 'BOOLEAN', {'default': True}]]]
ComfyScript: VHS_VideoCombine: Invalid enum value: ['video/h264-mp4', [['pix_fmt', ['yuv420p', 'yuv420p10le']], ['crf', 'INT', {'default': 19, 'min': 0, 'max': 100, 'step': 1}], ['save_metadata', 'BOOLEAN', {'default': True}]]]
ComfyScript: VHS_VideoCombine: Invalid enum value: ['video/h265-mp4', [['pix_fmt', ['yuv420p10le', 'yuv420p']], ['crf', 'INT', {'default': 22, 'min': 0, 'max': 100, 'step': 1}], ['save_metadata', 'BOOLEAN', {'default': True}]]]
ComfyScript: VHS_VideoCombine: Invalid enum value: ['video/nvenc_h264-mp4', [['pix_fmt', ['yuv420p', 'yuv420p10le']], ['bitrate', 'INT', {'default': 10, 'min': 1, 'max': 999, 'step': 1}], ['megabit', 'BOOLEAN', {'default': True}], ['save_metadata', 'BOOLEAN', {'default': True}]]]
ComfyScript: VHS_VideoCombine: Invalid enum value: ['video/nvenc_hevc-mp4', [['pix_fmt', ['yuv420p', 'yuv420p10le']], ['bitrate', 'INT', {'default': 10, 'min': 1, 'max': 999, 'step': 1}], ['megabit', 'BOOLEAN', {'default': True}], ['save_metadata', 'BOOLEAN', {'default': True}]]]
ComfyScript: VHS_VideoCombine: Invalid enum value: ['video/webm', [['crf', 'INT', {'default': 20, 'min': 0, 'max': 100, 'step': 1}], ['save_metadata', 'BOOLEAN', {'default': True}]]]
If you want to use these ignore values and dynamic inputs, you can directly use string literals and keyword arguments, for example:
VHSVideoCombine(image, 8, 0, 'AnimateDiff', 'video/av1-webm', False, True, None, None, pix_fmt='yuv420p10le', crf=23, input_color_depth='8bit', save_metadata=True)
Great, thanks, I'll give it a try and report back here!
This issue could be kept open to help other people using VideoHelperSuite.
By the way, ComfyScript: Failed to load node List of any [Crystools]
is now fixed.
I cannot for the life of me figure out how to get output from the VHSVideoCombine node function loaded into my Python code, even as a PIL image. Is there a standard way of doing this?
VHSVideoCombine
is an output node, and every output node will return a dict. In this dict, ui
marks the values to be passed to the web UI, and result
marks the real result. For VHSVideoCombine
, these values are:
previews = [
{
"filename": file,
"subfolder": subfolder,
"type": "output" if save_output else "temp",
"format": format,
}
]
return {"ui": {"gifs": previews}, "result": ((save_output, output_files),)}
If you are using virtual mode, you can get the dict via VHSVideoCombine().wait()._output
. If you are using real mode, the returned value is just the dict. After having the dict, there are two ways to retrieve the non-text results:
Server API.
VideoHelperSuite has added two API:
@server.PromptServer.instance.routes.get("/viewvideo")
async def view_video(request):
...
resp.content_type = 'video/webm'
...
@server.PromptServer.instance.routes.get("/getpath")
async def get_path(request):
...
You can make requests to these API yourself. Or write a class like ImageBatchResult
in src/comfy_script/runtime/data/Images.py
, which is the "standard" way to add result interop.
Directly reading files if using local ComfyUI.
This is an ad hoc solution, but simpler than using the API.
I'll add some interop with VHSVideoCombine
, but may need several days to find some spare time.
I've attempted to get this code to work:
video = VHSVideoCombine(images, 8, 0, 'final_output', 'image/gif', False, True, None, None)
results = video.wait()
return [await results._output()]
but it throws the error AttributeError: 'NoneType' object has no attribute '_output'
Sorry, I missed one line of code. It's now fixed and you can run git pull
to update. Here is an example to read the GIF as a PIL image:
with Workflow():
model, clip, vae = CheckpointLoaderSimple(Checkpoints.v1_5_pruned_emaonly)
conditioning = CLIPTextEncode('whileaf whileaf creepy slime calligraphy graffiti runes', clip)
conditioning2 = CLIPTextEncode('ugly', clip)
latent = EmptyLatentImage(512, 512, 2)
latent = KSampler(model, 0, 5, 8, 'dpmpp_2m_sde_gpu', 'karras', conditioning, conditioning2, latent, 1)
image = VAEDecode(latent, vae)
video = VHSVideoCombine(image, 8, 0, 'AnimateDiff', 'image/gif', False, True, None, None)
import PIL.Image
# {'gifs': [{'filename': 'AnimateDiff_00002.gif', 'subfolder': '', 'type': 'output', 'format': 'image/gif'}]}
filename = video.wait()._output['gifs'][0]['filename']
gif = PIL.Image.open(rf'D:/ComfyUI/output/{filename}')
display(gif)
# Second frame
gif.seek(1)
display(gif)
To display the animation instead of a frame in Jupyter Notebook:
from IPython.display import Image
Image(filename=rf'D:/ComfyUI/output/{filename}')
Another option is to use https://github.com/google/mediapy, which can also display videos but requires FFmpeg to be present in PATH.
It works now, thank you so much!
Hi there, thanks for this super cool repo, this is exactly what I've been waiting for to really dive into comfyUI!
I'm trying to get an animateDiff workflow working, but I'm running into an issue with the node which outputs the video/gif.
It's from https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite
The workflow is here: whileaf-lora-workflow.json
It gets transpiled to:
but running it gives the following errors:
Any idea what might be going on?