-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 14c105e
Showing
11 changed files
with
749 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
__pycache__ | ||
*.py[cod] | ||
*$py.class | ||
_*/ | ||
glsl/* | ||
*.code-workspace | ||
.vscode | ||
config.json | ||
ignore.txt | ||
.env | ||
.venv | ||
.DS_Store | ||
*.egg-info | ||
*.bak | ||
checkpoints | ||
results | ||
backup | ||
node_modules | ||
*-lock.json | ||
*.config.mjs | ||
package.json | ||
_TODO*.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
MIT License | ||
|
||
Copyright (c) 2025 Alexander G. Morano | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
GO NUTS; JUST TRY NOT TO DO IT IN YOUR HEAD. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<div align="center"> | ||
|
||
<picture> | ||
<source srcset="https://github.com/Amorano/Jovi_Spout-examples/blob/master/res/Jovi_Spout.png"> | ||
<img alt="ComfyUI Nodes for using Spout streams" width="256" height="256"> | ||
</picture> | ||
|
||
</div> | ||
|
||
<div align="center"> | ||
|
||
<a href="https://github.com/comfyanonymous/ComfyUI">COMFYUI</a> Nodes for using Spout streams | ||
|
||
</div> | ||
|
||
<div align="center"> | ||
|
||
 | ||
 | ||
|
||
</div> | ||
|
||
<!----------------------------------------------------------------------------> | ||
|
||
## HIGHLIGHTS | ||
|
||
* `SPOUT` streaming support *WINDOWS ONLY* | ||
|
||
## UPDATES | ||
|
||
**2024/01/03** @1.0.0: | ||
* initial release | ||
* reworked [Jovi_Spout](https://github.com/amorano/Jovi_Spout) Spout support into standalone repository | ||
|
||
# INSTALLATION | ||
|
||
## COMFYUI MANAGER | ||
|
||
If you have [ComfyUI Manager](https://github.com/ltdrdata/ComfyUI-Manager) installed, simply search for Jovi_Spout and install from the manager's database. | ||
|
||
## MANUAL INSTALL | ||
Clone the repository into your ComfyUI custom_nodes directory. You can clone the repository with the command: | ||
``` | ||
git clone https://github.com/Amorano/Jovi_Spout.git | ||
``` | ||
You can then install the requirements by using the command: | ||
``` | ||
.\python_embed\python.exe -s -m pip install -r .\ComfyUI\custom_nodes\Jovi_Spout\requirements.txt | ||
``` | ||
If you are using a <code>virtual environment</code> (<code><i>venv</i></code>), make sure it is activated before installation. Then install the requirements with the command: | ||
``` | ||
pip install -r .\ComfyUI\custom_nodes\Jovi_Spout\requirements.txt | ||
``` | ||
## ENVIRONMENT | ||
|
||
|
||
<!----------------------------------------------------------------------------> | ||
|
||
|
||
|
||
<!----------------------------------------------------------------------------> | ||
|
||
# SPONSORSHIP | ||
|
||
Please consider sponsoring me if you enjoy the results of my work, code or documentation or otherwise. A good way to keep code development open and free is through sponsorship. | ||
|
||
<div align="center"> | ||
|
||
[](https://github.com/sponsors/Amorano) | ||
|
||
[](https://www.paypal.com/paypalme/onarom) | ||
|
||
[](https://www.patreon.com/joviex) | ||
|
||
[](https://ko-fi.com/alexandermorano) | ||
|
||
</div> | ||
|
||
<!----------------------------------------------------------------------------> | ||
|
||
# WHERE TO FIND ME | ||
|
||
You can find me on [](https://discord.gg/62TJaZ3Z5r). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
""" | ||
██ ██████ ██ ██ ██ ███ ███ ███████ ████████ ██████ ██ ██ ██ | ||
██ ██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ | ||
██ ██ ██ ██ ██ ██ ██ ████ ██ █████ ██ ██████ ██ ███ | ||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ | ||
█████ ██████ ████ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ | ||
SPOUT support for ComfyUI | ||
http://www.github.com/amorano/Jovi_Spout | ||
@title: Jovi_Spout | ||
@author: amorano | ||
@category: Stream | ||
@reference: https://github.com/Amorano/Jovi_Spout | ||
@tags: Stream, Spout, Media | ||
@description: SPOUT support for ComfyUI. | ||
@node list: | ||
SpoutReaderNode, SpoutWriterNode | ||
@version: 1.0.0 | ||
""" | ||
|
||
import os | ||
import sys | ||
import json | ||
import inspect | ||
import importlib | ||
from pathlib import Path | ||
from typing import Any | ||
|
||
from loguru import logger | ||
|
||
NODE_CLASS_MAPPINGS = {} | ||
NODE_DISPLAY_NAME_MAPPINGS = {} | ||
WEB_DIRECTORY = "./web" | ||
|
||
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"] | ||
|
||
ROOT = Path(__file__).resolve().parent | ||
ROOT_COMFY = ROOT.parent.parent | ||
|
||
JOV_WEB = ROOT / 'web' | ||
|
||
JOV_LOG_LEVEL = os.getenv("JOV_LOG_LEVEL", "INFO") | ||
logger.configure(handlers=[{"sink": sys.stdout, "level": JOV_LOG_LEVEL}]) | ||
|
||
JOV_INTERNAL = os.getenv("JOV_INTERNAL", 'false').strip().lower() in ('true', '1', 't') | ||
|
||
# ============================================================================== | ||
# === THERE CAN BE ONLY ONE === | ||
# ============================================================================== | ||
|
||
class Singleton(type): | ||
_instances = {} | ||
|
||
def __call__(cls, *arg, **kw) -> Any: | ||
# If the instance does not exist, create and store it | ||
if cls not in cls._instances: | ||
instance = super().__call__(*arg, **kw) | ||
cls._instances[cls] = instance | ||
return cls._instances[cls] | ||
|
||
# ============================================================================== | ||
# === CORE NODES === | ||
# ============================================================================== | ||
|
||
class JOVBaseNode: | ||
NOT_IDEMPOTENT = True | ||
CATEGORY = f"JOVI_SPOUT 📺" | ||
RETURN_TYPES = () | ||
FUNCTION = "run" | ||
|
||
@classmethod | ||
def VALIDATE_INPUTS(cls, *arg, **kw) -> bool: | ||
return True | ||
|
||
@classmethod | ||
def INPUT_TYPES(cls, prompt:bool=False, extra_png:bool=False, dynprompt:bool=False) -> dict: | ||
data = { | ||
"required": {}, | ||
"hidden": { | ||
"ident": "UNIQUE_ID" | ||
} | ||
} | ||
if prompt: | ||
data["hidden"]["prompt"] = "PROMPT" | ||
if extra_png: | ||
data["hidden"]["extra_pnginfo"] = "EXTRA_PNGINFO" | ||
|
||
if dynprompt: | ||
data["hidden"]["dynprompt"] = "DYNPROMPT" | ||
return data | ||
|
||
class JOVImageNode(JOVBaseNode): | ||
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK") | ||
RETURN_NAMES = ("RGBA", "RGB", "MASK") | ||
|
||
@classmethod | ||
def INPUT_TYPES(cls) -> dict: | ||
d = super().INPUT_TYPES() | ||
d = deep_merge(d, { | ||
"outputs": { | ||
0: ("IMAGE", {"tooltip":"Full channel [RGBA] image. If there is an alpha, the image will be masked out with it when using this output."}), | ||
1: ("IMAGE", {"tooltip":"Three channel [RGB] image. There will be no alpha."}), | ||
2: ("MASK", {"tooltip":"Single channel mask output."}), | ||
} | ||
}) | ||
return d | ||
|
||
class AnyType(str): | ||
"""AnyType input wildcard trick taken from pythongossss's: | ||
https://github.com/pythongosssss/ComfyUI-Custom-Scripts | ||
""" | ||
def __ne__(self, __value: object) -> bool: | ||
return False | ||
|
||
JOV_TYPE_ANY = AnyType("*") | ||
JOV_TYPE_IMAGE = JOV_TYPE_ANY | ||
|
||
def deep_merge(d1: dict, d2: dict) -> dict: | ||
""" | ||
Deep merge multiple dictionaries recursively. | ||
Args: | ||
*dicts: Variable number of dictionaries to be merged. | ||
Returns: | ||
dict: Merged dictionary. | ||
""" | ||
for key in d2: | ||
if key in d1: | ||
if isinstance(d1[key], dict) and isinstance(d2[key], dict): | ||
deep_merge(d1[key], d2[key]) | ||
else: | ||
d1[key] = d2[key] | ||
else: | ||
d1[key] = d2[key] | ||
return d1 | ||
|
||
# ============================================================================== | ||
# === NODE LOADER === | ||
# ============================================================================== | ||
|
||
def loader(): | ||
node_count = 0 | ||
NODE_LIST_MAP = {} | ||
|
||
global NODE_DISPLAY_NAME_MAPPINGS, NODE_CLASS_MAPPINGS | ||
|
||
for fname in ROOT.glob('core/**/*.py'): | ||
if fname.stem.startswith('_'): | ||
continue | ||
|
||
try: | ||
route = str(fname).replace("\\", "/").split("Jovi_Spout/core/")[1] | ||
route = route.split('.')[0].replace('/', '.') | ||
module = f"Jovi_Spout.core.{route}" | ||
module = importlib.import_module(module) | ||
except Exception as e: | ||
logger.warning(f"module failed {fname}") | ||
logger.warning(str(e)) | ||
continue | ||
|
||
classes = inspect.getmembers(module, inspect.isclass) | ||
for class_name, class_object in classes: | ||
# assume both attrs are good enough.... | ||
if not class_name.endswith('BaseNode') and hasattr(class_object, 'NAME') and hasattr(class_object, 'CATEGORY'): | ||
name = class_object.NAME | ||
NODE_DISPLAY_NAME_MAPPINGS[name] = name | ||
NODE_CLASS_MAPPINGS[name] = class_object | ||
desc = class_object.DESCRIPTION if hasattr(class_object, 'DESCRIPTION') else name | ||
NODE_LIST_MAP[name] = desc.split('.')[0].strip('\n') | ||
node_count += 1 | ||
|
||
logger.info(f"✅ {module.__name__}") | ||
logger.info(f"{node_count} nodes loaded") | ||
|
||
# only do the list on local runs... | ||
if JOV_INTERNAL: | ||
with open(str(ROOT) + "/node_list.json", "w", encoding="utf-8") as f: | ||
json.dump(NODE_LIST_MAP, f, sort_keys=True, indent=4 ) | ||
|
||
loader() |
Empty file.
Oops, something went wrong.