Skip to content

Commit

Permalink
Prioritize builtin video_formats:
Browse files Browse the repository at this point in the history
Several other custom nodes have blindly copied VHS code and overwrite
the registered location for video formats. To solve this, the builtin
video_formats folder is checked separately and given priority over
folder_paths formats.

See #375

Bump version
  • Loading branch information
AustinMroz committed Feb 7, 2025
1 parent f470aeb commit 701f7e7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui-videohelpersuite"
description = "Nodes related to video workflows"
version = "1.5.0"
version = "1.5.1"
license = { file = "LICENSE" }
dependencies = ["opencv-python", "imageio-ffmpeg"]

Expand Down
27 changes: 16 additions & 11 deletions videohelpersuite/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@
imageOrLatent, BIGMAX, merge_filter_args, ENCODE_ARGS, floatOrInt
from comfy.utils import ProgressBar

folder_paths.folder_names_and_paths["VHS_video_formats"] = (
[
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "video_formats"),
],
[".json"]
)
if 'VHS_video_formats' not in folder_paths.folder_names_and_paths:
folder_paths.folder_names_and_paths["VHS_video_formats"] = ((),[".json"])
audio_extensions = ['mp3', 'mp4', 'wav', 'ogg']

def gen_format_widgets(video_format):
Expand All @@ -47,12 +43,18 @@ def gen_format_widgets(video_format):
yield item
video_format[k] = item[0]

base_formats_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "video_formats")
def get_video_formats():
formats = []
format_files = {}
for format_name in folder_paths.get_filename_list("VHS_video_formats"):
format_name = format_name[:-5]
video_format_path = folder_paths.get_full_path("VHS_video_formats", format_name + ".json")
with open(video_format_path, 'r') as stream:
format_files[folder_name] = folder_paths.get_full_path("VHS_video_formats", format_name + ".json")
for item in os.scandir(base_formats_dir):
if not item.is_file() or not item.name.endswith('.json'):
continue
format_files[item.name[:-5]] = item.path
formats = []
for format_name, path in format_files.items():
with open(path, 'r') as stream:
video_format = json.load(stream)
if "gifski_pass" in video_format and gifski_path is None:
#Skip format
Expand All @@ -65,7 +67,10 @@ def get_video_formats():
return formats

def apply_format_widgets(format_name, kwargs):
video_format_path = folder_paths.get_full_path("VHS_video_formats", format_name + ".json")
if os.path.exists(os.path.join(base_formats_dir, format_name + ".json")):
video_format_path = os.path.join(base_formats_dir, format_name + ".json")
else:
video_format_path = folder_paths.get_full_path("VHS_video_formats", format_name + ".json")
with open(video_format_path, 'r') as stream:
video_format = json.load(stream)
for w in gen_format_widgets(video_format):
Expand Down

1 comment on commit 701f7e7

@Mattabyte
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke something I think. Getting this error after update:

line 348: extra_options = extra_pnginfo.get('workflow', {}).get('extra', {})

AttributeError: 'NoneType' object has no attribute 'get'

Works in the WebUI, but if I push an update through the API with my workflow it results in the above error.

Rolling back to 1.5.0 fixed the issue.

Raised issue : #377

Please sign in to comment.