Kosinkadink / ComfyUI-VideoHelperSuite

Nodes related to video workflows
GNU General Public License v3.0
524 stars 92 forks source link

[SOLVED] Support for VP8 Codec - Linux does not seem to load "main_pass" properly - video formats clash with ComfyUI-AnimateDiff-Evolved/video_formats/ #87

Closed philmaas closed 9 months ago

philmaas commented 9 months ago

For some reason on Ubuntu 20.04 no matter what i change in the video formats folder it always seems to load the default values anyway. Adding a new json to the folder does not show it in the node (it works on windows however) Reproduce:

  1. change webm.json to:

{ "main_pass": [ "-n", "-pix_fmt", "yuv420p", "-vcodec", "libvpx" ], "extension": "webm" }

  1. Restart Comfy
  2. Convert a video with webm output.

Result: Windows outputs correct vp8 codec Linux still outputs vp9 codec

I can change the node.py and hard code the codec like so:

nodes.py Line 173:

args = [ffmpeg_path, "-v", "error", "-f", "rawvideo", "-pix_fmt", "rgb24", "-s", dimensions, "-r", str(frame_rate), "-i", "-", "-crf", str(crf), "-n", "-pix_fmt", "yuv420p", "-vcodec", "libvpx"]

image showing vp9 although the web.json was changed to use libvpx image

AustinMroz commented 9 months ago

You certainly appear to be going about things the right way and I can confirm that on my machine running Arch Linux, replacing webm.json as described produces a vp8 output as expected.

Could you:

Your hard coded args is fairly conclusive that it's not a problem with ffmpeg, so I would like to further narrow if this is formatting error or something preventing the file itself from loading.

Edit: I missed your note that adding a new config to the folder didn't work. This leads me to believe that there is an error in where the config files are loaded from. Could you try a print(folder_paths.folder_names_and_paths["video_formats"])

AustinMroz commented 9 months ago

Upon further consideration, I have a fairly confident guess for what is happening here. On your Ubuntu setup, VideoHelperSuite is loading after AnimateDiff-Evolved which still includes deprecated video_format code from before VideoHelperSuite was moved to a standalone project. When this happens, the 'video_formats' folder path registration is overwritten with a path to the legacy video_formats directory in AnimateDiff-Evolved. Thus, if you instead edit ComfyUI-AnimateDiff-Evolved/video_formats/webm.json, or instead create a new format at ComfyUI-AnimateDiff-Evolved/video_formats/vp8-webm.json, things will work as expected.

I will add a fix for this to the developement branch.

Kosinkadink commented 9 months ago

Let me know if I need to change anything on AnimateDiff-Evolved side of things, the AnimateDiff Combine node there is deprecated anyway, so I wanna make sure VHS works fine.

AustinMroz commented 9 months ago

Of course. There's a quick fix in AnimateDiff-Evolved to simply check that "video_formats" not in folder_paths.folder_names_and_paths before setting, but I think the better longterm solution would be to add a namespace here as "VHS_video_formats" since the proposed new format options would be incompatible with the (deprecated) AnimateDiff Combine when the reverse occurs.

In either case, I'd like to wait for confirmation that I'm not barking up the wrong tree first.

philmaas commented 9 months ago

Upon further consideration, I have a fairly confident guess for what is happening here. On your Ubuntu setup, VideoHelperSuite is loading after AnimateDiff-Evolved which still includes deprecated video_format code from before VideoHelperSuite was moved to a standalone project. When this happens, the 'video_formats' folder path registration is overwritten with a path to the legacy video_formats directory in AnimateDiff-Evolved. Thus, if you instead edit ComfyUI-AnimateDiff-Evolved/video_formats/webm.json, or instead create a new format at ComfyUI-AnimateDiff-Evolved/video_formats/vp8-webm.json, things will work as expected.

I will add a fix for this to the developement branch.

Really appreciate the help! Yeah, I probably would've noticed this eventually, I didn't know there is another video_formats folder in AnimateDiff Evolved.

Confirming that changing or adding new .json files to ComfyUI-AnimateDiff-Evolved/video_formats/ does the trick. And my windows machine doesn't actually have AnimateDiff installed so why it worked there.

Kosinkadink commented 9 months ago

I also went ahead and changed the video_formats internal key in AnimateDiff-Evolved just now to have a prefix, so that it would not clash with any other extension in the past/future that might use "video_formats" as the key; going to save some headaches in the long run.