couple of fixes

This commit is contained in:
TashaSkyUp
2025-05-27 15:23:46 -06:00
parent 8c3ef3618c
commit 8ce06ca357
2 changed files with 59 additions and 2 deletions
+53 -2
View File
@@ -1,10 +1,11 @@
import shutil
import struct
import io
import copy
import imageio_ffmpeg as ffmpeg
import joblib
from comfy_extras.nodes_audio import insert_or_replace_vorbis_comment
from .config import config_settings
temp_dir = config_settings["tmp_dir"]
@@ -14,9 +15,59 @@ from . import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
# NODE_CLASS_MAPPINGS = {}
# NODE_DISPLAY_NAME_MAPPINGS = {}
def create_vorbis_comment_block(comment_dict, last_block):
vendor_string = b'ComfyUI'
vendor_length = len(vendor_string)
comments = []
for key, value in comment_dict.items():
comment = f"{key}={value}".encode('utf-8')
comments.append(struct.pack('<I', len(comment)) + comment)
user_comment_list_length = len(comments)
user_comments = b''.join(comments)
comment_data = struct.pack('<I', vendor_length) + vendor_string + struct.pack('<I', user_comment_list_length) + user_comments
if last_block:
id = b'\x84'
else:
id = b'\x04'
comment_block = id + struct.pack('>I', len(comment_data))[1:] + comment_data
return comment_block
# Create a memory object for caching
# memory = joblib.Memory(temp_dir, verbose=0)
def insert_or_replace_vorbis_comment(flac_io, comment_dict):
if len(comment_dict) == 0:
return flac_io
flac_io.seek(4)
blocks = []
last_block = False
while not last_block:
header = flac_io.read(4)
last_block = (header[0] & 0x80) != 0
block_type = header[0] & 0x7F
block_length = struct.unpack('>I', b'\x00' + header[1:])[0]
block_data = flac_io.read(block_length)
if block_type == 4 or block_type == 1:
pass
else:
header = bytes([(header[0] & (~0x80))]) + header[1:]
blocks.append(header + block_data)
blocks.append(create_vorbis_comment_block(comment_dict, last_block=True))
new_flac_io = io.BytesIO()
new_flac_io.write(b'fLaC')
for block in blocks:
new_flac_io.write(block)
new_flac_io.write(flac_io.read())
return new_flac_io
def ETK_audio_base(cls):
cls.CATEGORY = "ETK/audio"
+6
View File
@@ -206,6 +206,12 @@ if not TEST:
"client_id": None,
"git_io": "HMG"
},
"API": {
"password": "[REDACTED]",
"security": None,
"client_id": None,
"git_io": "HMG"
},
}
tmp_dir = config_settings["tmp_dir"]
user_data_file = os.path.join(tmp_dir, 'user_data_tmp.json')