Mirror from https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite
Browse files- .github/workflows/publish.yml +24 -0
- .gitignore +162 -0
- LICENSE +674 -0
- README.md +110 -0
- __init__.py +9 -0
- pyproject.toml +15 -0
- requirements.txt +2 -0
- testframework/README.md +5 -0
- testframework/__init__.py +6 -0
- testframework/server.py +60 -0
- testframework/web/js/testRunner.js +96 -0
- tests/README.md +1 -0
- tests/audio.json +313 -0
- tests/batch4x4.json +535 -0
- tests/converted-format-input.json +253 -0
- tests/converted-input.json +307 -0
- tests/loop.json +178 -0
- tests/old-prores.json +423 -0
- tests/old-vae-conversion.json +229 -0
- tests/simple.json +134 -0
- video_formats/16bit-png.json +9 -0
- video_formats/8bit-png.json +7 -0
- video_formats/ProRes.json +22 -0
- video_formats/av1-webm.json +16 -0
- video_formats/ffmpeg-gif.json +8 -0
- video_formats/ffv1-mkv.json +17 -0
- video_formats/gifski.json +12 -0
- video_formats/h264-mp4.json +15 -0
- video_formats/h265-mp4.json +17 -0
- video_formats/nvenc_av1-mp4.json +15 -0
- video_formats/nvenc_h264-mp4.json +15 -0
- video_formats/nvenc_hevc-mp4.json +16 -0
- video_formats/webm.json +16 -0
- videohelpersuite/batched_nodes.py +56 -0
- videohelpersuite/documentation.py +616 -0
- videohelpersuite/image_latent_nodes.py +554 -0
- videohelpersuite/latent_preview.py +111 -0
- videohelpersuite/load_images_nodes.py +206 -0
- videohelpersuite/load_video_nodes.py +671 -0
- videohelpersuite/logger.py +36 -0
- videohelpersuite/nodes.py +1111 -0
- videohelpersuite/server.py +294 -0
- videohelpersuite/utils.py +426 -0
- web/js/VHS.core.js +0 -0
- web/js/videoinfo.js +101 -0
.github/workflows/publish.yml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Publish to Comfy registry
|
| 2 |
+
on:
|
| 3 |
+
workflow_dispatch:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- main
|
| 7 |
+
paths:
|
| 8 |
+
- "pyproject.toml"
|
| 9 |
+
|
| 10 |
+
permissions:
|
| 11 |
+
issues: write
|
| 12 |
+
|
| 13 |
+
jobs:
|
| 14 |
+
publish-node:
|
| 15 |
+
name: Publish Custom Node to registry
|
| 16 |
+
runs-on: ubuntu-latest
|
| 17 |
+
if: ${{ github.repository_owner == 'Kosinkadink' }}
|
| 18 |
+
steps:
|
| 19 |
+
- name: Check out code
|
| 20 |
+
uses: actions/checkout@v4
|
| 21 |
+
- name: Publish Custom Node
|
| 22 |
+
uses: Comfy-Org/publish-node-action@v1
|
| 23 |
+
with:
|
| 24 |
+
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} ## Add your own personal access token to your Github Repository secrets and reference it here.
|
.gitignore
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Byte-compiled / optimized / DLL files
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
|
| 6 |
+
# C extensions
|
| 7 |
+
*.so
|
| 8 |
+
|
| 9 |
+
# Distribution / packaging
|
| 10 |
+
.Python
|
| 11 |
+
build/
|
| 12 |
+
develop-eggs/
|
| 13 |
+
dist/
|
| 14 |
+
downloads/
|
| 15 |
+
eggs/
|
| 16 |
+
.eggs/
|
| 17 |
+
lib/
|
| 18 |
+
lib64/
|
| 19 |
+
parts/
|
| 20 |
+
sdist/
|
| 21 |
+
var/
|
| 22 |
+
wheels/
|
| 23 |
+
share/python-wheels/
|
| 24 |
+
*.egg-info/
|
| 25 |
+
.installed.cfg
|
| 26 |
+
*.egg
|
| 27 |
+
MANIFEST
|
| 28 |
+
|
| 29 |
+
# PyInstaller
|
| 30 |
+
# Usually these files are written by a python script from a template
|
| 31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
| 32 |
+
*.manifest
|
| 33 |
+
*.spec
|
| 34 |
+
|
| 35 |
+
# Installer logs
|
| 36 |
+
pip-log.txt
|
| 37 |
+
pip-delete-this-directory.txt
|
| 38 |
+
|
| 39 |
+
# Unit test / coverage reports
|
| 40 |
+
htmlcov/
|
| 41 |
+
.tox/
|
| 42 |
+
.nox/
|
| 43 |
+
.coverage
|
| 44 |
+
.coverage.*
|
| 45 |
+
.cache
|
| 46 |
+
nosetests.xml
|
| 47 |
+
coverage.xml
|
| 48 |
+
*.cover
|
| 49 |
+
*.py,cover
|
| 50 |
+
.hypothesis/
|
| 51 |
+
.pytest_cache/
|
| 52 |
+
cover/
|
| 53 |
+
|
| 54 |
+
# Translations
|
| 55 |
+
*.mo
|
| 56 |
+
*.pot
|
| 57 |
+
|
| 58 |
+
# Django stuff:
|
| 59 |
+
*.log
|
| 60 |
+
local_settings.py
|
| 61 |
+
db.sqlite3
|
| 62 |
+
db.sqlite3-journal
|
| 63 |
+
|
| 64 |
+
# Flask stuff:
|
| 65 |
+
instance/
|
| 66 |
+
.webassets-cache
|
| 67 |
+
|
| 68 |
+
# Scrapy stuff:
|
| 69 |
+
.scrapy
|
| 70 |
+
|
| 71 |
+
# Sphinx documentation
|
| 72 |
+
docs/_build/
|
| 73 |
+
|
| 74 |
+
# PyBuilder
|
| 75 |
+
.pybuilder/
|
| 76 |
+
target/
|
| 77 |
+
|
| 78 |
+
# Jupyter Notebook
|
| 79 |
+
.ipynb_checkpoints
|
| 80 |
+
|
| 81 |
+
# IPython
|
| 82 |
+
profile_default/
|
| 83 |
+
ipython_config.py
|
| 84 |
+
|
| 85 |
+
# pyenv
|
| 86 |
+
# For a library or package, you might want to ignore these files since the code is
|
| 87 |
+
# intended to run in multiple environments; otherwise, check them in:
|
| 88 |
+
# .python-version
|
| 89 |
+
|
| 90 |
+
# pipenv
|
| 91 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
| 92 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
| 93 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
| 94 |
+
# install all needed dependencies.
|
| 95 |
+
#Pipfile.lock
|
| 96 |
+
|
| 97 |
+
# poetry
|
| 98 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
| 99 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
| 100 |
+
# commonly ignored for libraries.
|
| 101 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
| 102 |
+
#poetry.lock
|
| 103 |
+
|
| 104 |
+
# pdm
|
| 105 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
| 106 |
+
#pdm.lock
|
| 107 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
| 108 |
+
# in version control.
|
| 109 |
+
# https://pdm.fming.dev/#use-with-ide
|
| 110 |
+
.pdm.toml
|
| 111 |
+
|
| 112 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
| 113 |
+
__pypackages__/
|
| 114 |
+
|
| 115 |
+
# Celery stuff
|
| 116 |
+
celerybeat-schedule
|
| 117 |
+
celerybeat.pid
|
| 118 |
+
|
| 119 |
+
# SageMath parsed files
|
| 120 |
+
*.sage.py
|
| 121 |
+
|
| 122 |
+
# Environments
|
| 123 |
+
.env
|
| 124 |
+
.venv
|
| 125 |
+
env/
|
| 126 |
+
venv/
|
| 127 |
+
ENV/
|
| 128 |
+
env.bak/
|
| 129 |
+
venv.bak/
|
| 130 |
+
|
| 131 |
+
# Spyder project settings
|
| 132 |
+
.spyderproject
|
| 133 |
+
.spyproject
|
| 134 |
+
|
| 135 |
+
# Rope project settings
|
| 136 |
+
.ropeproject
|
| 137 |
+
|
| 138 |
+
# mkdocs documentation
|
| 139 |
+
/site
|
| 140 |
+
|
| 141 |
+
# mypy
|
| 142 |
+
.mypy_cache/
|
| 143 |
+
.dmypy.json
|
| 144 |
+
dmypy.json
|
| 145 |
+
|
| 146 |
+
# Pyre type checker
|
| 147 |
+
.pyre/
|
| 148 |
+
|
| 149 |
+
# pytype static type analyzer
|
| 150 |
+
.pytype/
|
| 151 |
+
|
| 152 |
+
# Cython debug symbols
|
| 153 |
+
cython_debug/
|
| 154 |
+
|
| 155 |
+
# PyCharm
|
| 156 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
| 157 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
| 158 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
| 159 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
| 160 |
+
#.idea/
|
| 161 |
+
# VIM swap files
|
| 162 |
+
*.swp
|
LICENSE
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GNU GENERAL PUBLIC LICENSE
|
| 2 |
+
Version 3, 29 June 2007
|
| 3 |
+
|
| 4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
| 5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
| 6 |
+
of this license document, but changing it is not allowed.
|
| 7 |
+
|
| 8 |
+
Preamble
|
| 9 |
+
|
| 10 |
+
The GNU General Public License is a free, copyleft license for
|
| 11 |
+
software and other kinds of works.
|
| 12 |
+
|
| 13 |
+
The licenses for most software and other practical works are designed
|
| 14 |
+
to take away your freedom to share and change the works. By contrast,
|
| 15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
| 16 |
+
share and change all versions of a program--to make sure it remains free
|
| 17 |
+
software for all its users. We, the Free Software Foundation, use the
|
| 18 |
+
GNU General Public License for most of our software; it applies also to
|
| 19 |
+
any other work released this way by its authors. You can apply it to
|
| 20 |
+
your programs, too.
|
| 21 |
+
|
| 22 |
+
When we speak of free software, we are referring to freedom, not
|
| 23 |
+
price. Our General Public Licenses are designed to make sure that you
|
| 24 |
+
have the freedom to distribute copies of free software (and charge for
|
| 25 |
+
them if you wish), that you receive source code or can get it if you
|
| 26 |
+
want it, that you can change the software or use pieces of it in new
|
| 27 |
+
free programs, and that you know you can do these things.
|
| 28 |
+
|
| 29 |
+
To protect your rights, we need to prevent others from denying you
|
| 30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
| 31 |
+
certain responsibilities if you distribute copies of the software, or if
|
| 32 |
+
you modify it: responsibilities to respect the freedom of others.
|
| 33 |
+
|
| 34 |
+
For example, if you distribute copies of such a program, whether
|
| 35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
| 36 |
+
freedoms that you received. You must make sure that they, too, receive
|
| 37 |
+
or can get the source code. And you must show them these terms so they
|
| 38 |
+
know their rights.
|
| 39 |
+
|
| 40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
| 41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
| 42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
| 43 |
+
|
| 44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
| 45 |
+
that there is no warranty for this free software. For both users' and
|
| 46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
| 47 |
+
changed, so that their problems will not be attributed erroneously to
|
| 48 |
+
authors of previous versions.
|
| 49 |
+
|
| 50 |
+
Some devices are designed to deny users access to install or run
|
| 51 |
+
modified versions of the software inside them, although the manufacturer
|
| 52 |
+
can do so. This is fundamentally incompatible with the aim of
|
| 53 |
+
protecting users' freedom to change the software. The systematic
|
| 54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
| 55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
| 56 |
+
have designed this version of the GPL to prohibit the practice for those
|
| 57 |
+
products. If such problems arise substantially in other domains, we
|
| 58 |
+
stand ready to extend this provision to those domains in future versions
|
| 59 |
+
of the GPL, as needed to protect the freedom of users.
|
| 60 |
+
|
| 61 |
+
Finally, every program is threatened constantly by software patents.
|
| 62 |
+
States should not allow patents to restrict development and use of
|
| 63 |
+
software on general-purpose computers, but in those that do, we wish to
|
| 64 |
+
avoid the special danger that patents applied to a free program could
|
| 65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
| 66 |
+
patents cannot be used to render the program non-free.
|
| 67 |
+
|
| 68 |
+
The precise terms and conditions for copying, distribution and
|
| 69 |
+
modification follow.
|
| 70 |
+
|
| 71 |
+
TERMS AND CONDITIONS
|
| 72 |
+
|
| 73 |
+
0. Definitions.
|
| 74 |
+
|
| 75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
| 76 |
+
|
| 77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
| 78 |
+
works, such as semiconductor masks.
|
| 79 |
+
|
| 80 |
+
"The Program" refers to any copyrightable work licensed under this
|
| 81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
| 82 |
+
"recipients" may be individuals or organizations.
|
| 83 |
+
|
| 84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
| 85 |
+
in a fashion requiring copyright permission, other than the making of an
|
| 86 |
+
exact copy. The resulting work is called a "modified version" of the
|
| 87 |
+
earlier work or a work "based on" the earlier work.
|
| 88 |
+
|
| 89 |
+
A "covered work" means either the unmodified Program or a work based
|
| 90 |
+
on the Program.
|
| 91 |
+
|
| 92 |
+
To "propagate" a work means to do anything with it that, without
|
| 93 |
+
permission, would make you directly or secondarily liable for
|
| 94 |
+
infringement under applicable copyright law, except executing it on a
|
| 95 |
+
computer or modifying a private copy. Propagation includes copying,
|
| 96 |
+
distribution (with or without modification), making available to the
|
| 97 |
+
public, and in some countries other activities as well.
|
| 98 |
+
|
| 99 |
+
To "convey" a work means any kind of propagation that enables other
|
| 100 |
+
parties to make or receive copies. Mere interaction with a user through
|
| 101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
| 102 |
+
|
| 103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
| 104 |
+
to the extent that it includes a convenient and prominently visible
|
| 105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
| 106 |
+
tells the user that there is no warranty for the work (except to the
|
| 107 |
+
extent that warranties are provided), that licensees may convey the
|
| 108 |
+
work under this License, and how to view a copy of this License. If
|
| 109 |
+
the interface presents a list of user commands or options, such as a
|
| 110 |
+
menu, a prominent item in the list meets this criterion.
|
| 111 |
+
|
| 112 |
+
1. Source Code.
|
| 113 |
+
|
| 114 |
+
The "source code" for a work means the preferred form of the work
|
| 115 |
+
for making modifications to it. "Object code" means any non-source
|
| 116 |
+
form of a work.
|
| 117 |
+
|
| 118 |
+
A "Standard Interface" means an interface that either is an official
|
| 119 |
+
standard defined by a recognized standards body, or, in the case of
|
| 120 |
+
interfaces specified for a particular programming language, one that
|
| 121 |
+
is widely used among developers working in that language.
|
| 122 |
+
|
| 123 |
+
The "System Libraries" of an executable work include anything, other
|
| 124 |
+
than the work as a whole, that (a) is included in the normal form of
|
| 125 |
+
packaging a Major Component, but which is not part of that Major
|
| 126 |
+
Component, and (b) serves only to enable use of the work with that
|
| 127 |
+
Major Component, or to implement a Standard Interface for which an
|
| 128 |
+
implementation is available to the public in source code form. A
|
| 129 |
+
"Major Component", in this context, means a major essential component
|
| 130 |
+
(kernel, window system, and so on) of the specific operating system
|
| 131 |
+
(if any) on which the executable work runs, or a compiler used to
|
| 132 |
+
produce the work, or an object code interpreter used to run it.
|
| 133 |
+
|
| 134 |
+
The "Corresponding Source" for a work in object code form means all
|
| 135 |
+
the source code needed to generate, install, and (for an executable
|
| 136 |
+
work) run the object code and to modify the work, including scripts to
|
| 137 |
+
control those activities. However, it does not include the work's
|
| 138 |
+
System Libraries, or general-purpose tools or generally available free
|
| 139 |
+
programs which are used unmodified in performing those activities but
|
| 140 |
+
which are not part of the work. For example, Corresponding Source
|
| 141 |
+
includes interface definition files associated with source files for
|
| 142 |
+
the work, and the source code for shared libraries and dynamically
|
| 143 |
+
linked subprograms that the work is specifically designed to require,
|
| 144 |
+
such as by intimate data communication or control flow between those
|
| 145 |
+
subprograms and other parts of the work.
|
| 146 |
+
|
| 147 |
+
The Corresponding Source need not include anything that users
|
| 148 |
+
can regenerate automatically from other parts of the Corresponding
|
| 149 |
+
Source.
|
| 150 |
+
|
| 151 |
+
The Corresponding Source for a work in source code form is that
|
| 152 |
+
same work.
|
| 153 |
+
|
| 154 |
+
2. Basic Permissions.
|
| 155 |
+
|
| 156 |
+
All rights granted under this License are granted for the term of
|
| 157 |
+
copyright on the Program, and are irrevocable provided the stated
|
| 158 |
+
conditions are met. This License explicitly affirms your unlimited
|
| 159 |
+
permission to run the unmodified Program. The output from running a
|
| 160 |
+
covered work is covered by this License only if the output, given its
|
| 161 |
+
content, constitutes a covered work. This License acknowledges your
|
| 162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
| 163 |
+
|
| 164 |
+
You may make, run and propagate covered works that you do not
|
| 165 |
+
convey, without conditions so long as your license otherwise remains
|
| 166 |
+
in force. You may convey covered works to others for the sole purpose
|
| 167 |
+
of having them make modifications exclusively for you, or provide you
|
| 168 |
+
with facilities for running those works, provided that you comply with
|
| 169 |
+
the terms of this License in conveying all material for which you do
|
| 170 |
+
not control copyright. Those thus making or running the covered works
|
| 171 |
+
for you must do so exclusively on your behalf, under your direction
|
| 172 |
+
and control, on terms that prohibit them from making any copies of
|
| 173 |
+
your copyrighted material outside their relationship with you.
|
| 174 |
+
|
| 175 |
+
Conveying under any other circumstances is permitted solely under
|
| 176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
| 177 |
+
makes it unnecessary.
|
| 178 |
+
|
| 179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
| 180 |
+
|
| 181 |
+
No covered work shall be deemed part of an effective technological
|
| 182 |
+
measure under any applicable law fulfilling obligations under article
|
| 183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
| 184 |
+
similar laws prohibiting or restricting circumvention of such
|
| 185 |
+
measures.
|
| 186 |
+
|
| 187 |
+
When you convey a covered work, you waive any legal power to forbid
|
| 188 |
+
circumvention of technological measures to the extent such circumvention
|
| 189 |
+
is effected by exercising rights under this License with respect to
|
| 190 |
+
the covered work, and you disclaim any intention to limit operation or
|
| 191 |
+
modification of the work as a means of enforcing, against the work's
|
| 192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
| 193 |
+
technological measures.
|
| 194 |
+
|
| 195 |
+
4. Conveying Verbatim Copies.
|
| 196 |
+
|
| 197 |
+
You may convey verbatim copies of the Program's source code as you
|
| 198 |
+
receive it, in any medium, provided that you conspicuously and
|
| 199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
| 200 |
+
keep intact all notices stating that this License and any
|
| 201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
| 202 |
+
keep intact all notices of the absence of any warranty; and give all
|
| 203 |
+
recipients a copy of this License along with the Program.
|
| 204 |
+
|
| 205 |
+
You may charge any price or no price for each copy that you convey,
|
| 206 |
+
and you may offer support or warranty protection for a fee.
|
| 207 |
+
|
| 208 |
+
5. Conveying Modified Source Versions.
|
| 209 |
+
|
| 210 |
+
You may convey a work based on the Program, or the modifications to
|
| 211 |
+
produce it from the Program, in the form of source code under the
|
| 212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
| 213 |
+
|
| 214 |
+
a) The work must carry prominent notices stating that you modified
|
| 215 |
+
it, and giving a relevant date.
|
| 216 |
+
|
| 217 |
+
b) The work must carry prominent notices stating that it is
|
| 218 |
+
released under this License and any conditions added under section
|
| 219 |
+
7. This requirement modifies the requirement in section 4 to
|
| 220 |
+
"keep intact all notices".
|
| 221 |
+
|
| 222 |
+
c) You must license the entire work, as a whole, under this
|
| 223 |
+
License to anyone who comes into possession of a copy. This
|
| 224 |
+
License will therefore apply, along with any applicable section 7
|
| 225 |
+
additional terms, to the whole of the work, and all its parts,
|
| 226 |
+
regardless of how they are packaged. This License gives no
|
| 227 |
+
permission to license the work in any other way, but it does not
|
| 228 |
+
invalidate such permission if you have separately received it.
|
| 229 |
+
|
| 230 |
+
d) If the work has interactive user interfaces, each must display
|
| 231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
| 232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
| 233 |
+
work need not make them do so.
|
| 234 |
+
|
| 235 |
+
A compilation of a covered work with other separate and independent
|
| 236 |
+
works, which are not by their nature extensions of the covered work,
|
| 237 |
+
and which are not combined with it such as to form a larger program,
|
| 238 |
+
in or on a volume of a storage or distribution medium, is called an
|
| 239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
| 240 |
+
used to limit the access or legal rights of the compilation's users
|
| 241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
| 242 |
+
in an aggregate does not cause this License to apply to the other
|
| 243 |
+
parts of the aggregate.
|
| 244 |
+
|
| 245 |
+
6. Conveying Non-Source Forms.
|
| 246 |
+
|
| 247 |
+
You may convey a covered work in object code form under the terms
|
| 248 |
+
of sections 4 and 5, provided that you also convey the
|
| 249 |
+
machine-readable Corresponding Source under the terms of this License,
|
| 250 |
+
in one of these ways:
|
| 251 |
+
|
| 252 |
+
a) Convey the object code in, or embodied in, a physical product
|
| 253 |
+
(including a physical distribution medium), accompanied by the
|
| 254 |
+
Corresponding Source fixed on a durable physical medium
|
| 255 |
+
customarily used for software interchange.
|
| 256 |
+
|
| 257 |
+
b) Convey the object code in, or embodied in, a physical product
|
| 258 |
+
(including a physical distribution medium), accompanied by a
|
| 259 |
+
written offer, valid for at least three years and valid for as
|
| 260 |
+
long as you offer spare parts or customer support for that product
|
| 261 |
+
model, to give anyone who possesses the object code either (1) a
|
| 262 |
+
copy of the Corresponding Source for all the software in the
|
| 263 |
+
product that is covered by this License, on a durable physical
|
| 264 |
+
medium customarily used for software interchange, for a price no
|
| 265 |
+
more than your reasonable cost of physically performing this
|
| 266 |
+
conveying of source, or (2) access to copy the
|
| 267 |
+
Corresponding Source from a network server at no charge.
|
| 268 |
+
|
| 269 |
+
c) Convey individual copies of the object code with a copy of the
|
| 270 |
+
written offer to provide the Corresponding Source. This
|
| 271 |
+
alternative is allowed only occasionally and noncommercially, and
|
| 272 |
+
only if you received the object code with such an offer, in accord
|
| 273 |
+
with subsection 6b.
|
| 274 |
+
|
| 275 |
+
d) Convey the object code by offering access from a designated
|
| 276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
| 277 |
+
Corresponding Source in the same way through the same place at no
|
| 278 |
+
further charge. You need not require recipients to copy the
|
| 279 |
+
Corresponding Source along with the object code. If the place to
|
| 280 |
+
copy the object code is a network server, the Corresponding Source
|
| 281 |
+
may be on a different server (operated by you or a third party)
|
| 282 |
+
that supports equivalent copying facilities, provided you maintain
|
| 283 |
+
clear directions next to the object code saying where to find the
|
| 284 |
+
Corresponding Source. Regardless of what server hosts the
|
| 285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
| 286 |
+
available for as long as needed to satisfy these requirements.
|
| 287 |
+
|
| 288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
| 289 |
+
you inform other peers where the object code and Corresponding
|
| 290 |
+
Source of the work are being offered to the general public at no
|
| 291 |
+
charge under subsection 6d.
|
| 292 |
+
|
| 293 |
+
A separable portion of the object code, whose source code is excluded
|
| 294 |
+
from the Corresponding Source as a System Library, need not be
|
| 295 |
+
included in conveying the object code work.
|
| 296 |
+
|
| 297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
| 298 |
+
tangible personal property which is normally used for personal, family,
|
| 299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
| 300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
| 301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
| 302 |
+
product received by a particular user, "normally used" refers to a
|
| 303 |
+
typical or common use of that class of product, regardless of the status
|
| 304 |
+
of the particular user or of the way in which the particular user
|
| 305 |
+
actually uses, or expects or is expected to use, the product. A product
|
| 306 |
+
is a consumer product regardless of whether the product has substantial
|
| 307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
| 308 |
+
the only significant mode of use of the product.
|
| 309 |
+
|
| 310 |
+
"Installation Information" for a User Product means any methods,
|
| 311 |
+
procedures, authorization keys, or other information required to install
|
| 312 |
+
and execute modified versions of a covered work in that User Product from
|
| 313 |
+
a modified version of its Corresponding Source. The information must
|
| 314 |
+
suffice to ensure that the continued functioning of the modified object
|
| 315 |
+
code is in no case prevented or interfered with solely because
|
| 316 |
+
modification has been made.
|
| 317 |
+
|
| 318 |
+
If you convey an object code work under this section in, or with, or
|
| 319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
| 320 |
+
part of a transaction in which the right of possession and use of the
|
| 321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
| 322 |
+
fixed term (regardless of how the transaction is characterized), the
|
| 323 |
+
Corresponding Source conveyed under this section must be accompanied
|
| 324 |
+
by the Installation Information. But this requirement does not apply
|
| 325 |
+
if neither you nor any third party retains the ability to install
|
| 326 |
+
modified object code on the User Product (for example, the work has
|
| 327 |
+
been installed in ROM).
|
| 328 |
+
|
| 329 |
+
The requirement to provide Installation Information does not include a
|
| 330 |
+
requirement to continue to provide support service, warranty, or updates
|
| 331 |
+
for a work that has been modified or installed by the recipient, or for
|
| 332 |
+
the User Product in which it has been modified or installed. Access to a
|
| 333 |
+
network may be denied when the modification itself materially and
|
| 334 |
+
adversely affects the operation of the network or violates the rules and
|
| 335 |
+
protocols for communication across the network.
|
| 336 |
+
|
| 337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
| 338 |
+
in accord with this section must be in a format that is publicly
|
| 339 |
+
documented (and with an implementation available to the public in
|
| 340 |
+
source code form), and must require no special password or key for
|
| 341 |
+
unpacking, reading or copying.
|
| 342 |
+
|
| 343 |
+
7. Additional Terms.
|
| 344 |
+
|
| 345 |
+
"Additional permissions" are terms that supplement the terms of this
|
| 346 |
+
License by making exceptions from one or more of its conditions.
|
| 347 |
+
Additional permissions that are applicable to the entire Program shall
|
| 348 |
+
be treated as though they were included in this License, to the extent
|
| 349 |
+
that they are valid under applicable law. If additional permissions
|
| 350 |
+
apply only to part of the Program, that part may be used separately
|
| 351 |
+
under those permissions, but the entire Program remains governed by
|
| 352 |
+
this License without regard to the additional permissions.
|
| 353 |
+
|
| 354 |
+
When you convey a copy of a covered work, you may at your option
|
| 355 |
+
remove any additional permissions from that copy, or from any part of
|
| 356 |
+
it. (Additional permissions may be written to require their own
|
| 357 |
+
removal in certain cases when you modify the work.) You may place
|
| 358 |
+
additional permissions on material, added by you to a covered work,
|
| 359 |
+
for which you have or can give appropriate copyright permission.
|
| 360 |
+
|
| 361 |
+
Notwithstanding any other provision of this License, for material you
|
| 362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
| 363 |
+
that material) supplement the terms of this License with terms:
|
| 364 |
+
|
| 365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
| 366 |
+
terms of sections 15 and 16 of this License; or
|
| 367 |
+
|
| 368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
| 369 |
+
author attributions in that material or in the Appropriate Legal
|
| 370 |
+
Notices displayed by works containing it; or
|
| 371 |
+
|
| 372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
| 373 |
+
requiring that modified versions of such material be marked in
|
| 374 |
+
reasonable ways as different from the original version; or
|
| 375 |
+
|
| 376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
| 377 |
+
authors of the material; or
|
| 378 |
+
|
| 379 |
+
e) Declining to grant rights under trademark law for use of some
|
| 380 |
+
trade names, trademarks, or service marks; or
|
| 381 |
+
|
| 382 |
+
f) Requiring indemnification of licensors and authors of that
|
| 383 |
+
material by anyone who conveys the material (or modified versions of
|
| 384 |
+
it) with contractual assumptions of liability to the recipient, for
|
| 385 |
+
any liability that these contractual assumptions directly impose on
|
| 386 |
+
those licensors and authors.
|
| 387 |
+
|
| 388 |
+
All other non-permissive additional terms are considered "further
|
| 389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
| 390 |
+
received it, or any part of it, contains a notice stating that it is
|
| 391 |
+
governed by this License along with a term that is a further
|
| 392 |
+
restriction, you may remove that term. If a license document contains
|
| 393 |
+
a further restriction but permits relicensing or conveying under this
|
| 394 |
+
License, you may add to a covered work material governed by the terms
|
| 395 |
+
of that license document, provided that the further restriction does
|
| 396 |
+
not survive such relicensing or conveying.
|
| 397 |
+
|
| 398 |
+
If you add terms to a covered work in accord with this section, you
|
| 399 |
+
must place, in the relevant source files, a statement of the
|
| 400 |
+
additional terms that apply to those files, or a notice indicating
|
| 401 |
+
where to find the applicable terms.
|
| 402 |
+
|
| 403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
| 404 |
+
form of a separately written license, or stated as exceptions;
|
| 405 |
+
the above requirements apply either way.
|
| 406 |
+
|
| 407 |
+
8. Termination.
|
| 408 |
+
|
| 409 |
+
You may not propagate or modify a covered work except as expressly
|
| 410 |
+
provided under this License. Any attempt otherwise to propagate or
|
| 411 |
+
modify it is void, and will automatically terminate your rights under
|
| 412 |
+
this License (including any patent licenses granted under the third
|
| 413 |
+
paragraph of section 11).
|
| 414 |
+
|
| 415 |
+
However, if you cease all violation of this License, then your
|
| 416 |
+
license from a particular copyright holder is reinstated (a)
|
| 417 |
+
provisionally, unless and until the copyright holder explicitly and
|
| 418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
| 419 |
+
holder fails to notify you of the violation by some reasonable means
|
| 420 |
+
prior to 60 days after the cessation.
|
| 421 |
+
|
| 422 |
+
Moreover, your license from a particular copyright holder is
|
| 423 |
+
reinstated permanently if the copyright holder notifies you of the
|
| 424 |
+
violation by some reasonable means, this is the first time you have
|
| 425 |
+
received notice of violation of this License (for any work) from that
|
| 426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
| 427 |
+
your receipt of the notice.
|
| 428 |
+
|
| 429 |
+
Termination of your rights under this section does not terminate the
|
| 430 |
+
licenses of parties who have received copies or rights from you under
|
| 431 |
+
this License. If your rights have been terminated and not permanently
|
| 432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
| 433 |
+
material under section 10.
|
| 434 |
+
|
| 435 |
+
9. Acceptance Not Required for Having Copies.
|
| 436 |
+
|
| 437 |
+
You are not required to accept this License in order to receive or
|
| 438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
| 439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
| 440 |
+
to receive a copy likewise does not require acceptance. However,
|
| 441 |
+
nothing other than this License grants you permission to propagate or
|
| 442 |
+
modify any covered work. These actions infringe copyright if you do
|
| 443 |
+
not accept this License. Therefore, by modifying or propagating a
|
| 444 |
+
covered work, you indicate your acceptance of this License to do so.
|
| 445 |
+
|
| 446 |
+
10. Automatic Licensing of Downstream Recipients.
|
| 447 |
+
|
| 448 |
+
Each time you convey a covered work, the recipient automatically
|
| 449 |
+
receives a license from the original licensors, to run, modify and
|
| 450 |
+
propagate that work, subject to this License. You are not responsible
|
| 451 |
+
for enforcing compliance by third parties with this License.
|
| 452 |
+
|
| 453 |
+
An "entity transaction" is a transaction transferring control of an
|
| 454 |
+
organization, or substantially all assets of one, or subdividing an
|
| 455 |
+
organization, or merging organizations. If propagation of a covered
|
| 456 |
+
work results from an entity transaction, each party to that
|
| 457 |
+
transaction who receives a copy of the work also receives whatever
|
| 458 |
+
licenses to the work the party's predecessor in interest had or could
|
| 459 |
+
give under the previous paragraph, plus a right to possession of the
|
| 460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
| 461 |
+
the predecessor has it or can get it with reasonable efforts.
|
| 462 |
+
|
| 463 |
+
You may not impose any further restrictions on the exercise of the
|
| 464 |
+
rights granted or affirmed under this License. For example, you may
|
| 465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
| 466 |
+
rights granted under this License, and you may not initiate litigation
|
| 467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
| 468 |
+
any patent claim is infringed by making, using, selling, offering for
|
| 469 |
+
sale, or importing the Program or any portion of it.
|
| 470 |
+
|
| 471 |
+
11. Patents.
|
| 472 |
+
|
| 473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
| 474 |
+
License of the Program or a work on which the Program is based. The
|
| 475 |
+
work thus licensed is called the contributor's "contributor version".
|
| 476 |
+
|
| 477 |
+
A contributor's "essential patent claims" are all patent claims
|
| 478 |
+
owned or controlled by the contributor, whether already acquired or
|
| 479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
| 480 |
+
by this License, of making, using, or selling its contributor version,
|
| 481 |
+
but do not include claims that would be infringed only as a
|
| 482 |
+
consequence of further modification of the contributor version. For
|
| 483 |
+
purposes of this definition, "control" includes the right to grant
|
| 484 |
+
patent sublicenses in a manner consistent with the requirements of
|
| 485 |
+
this License.
|
| 486 |
+
|
| 487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
| 488 |
+
patent license under the contributor's essential patent claims, to
|
| 489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
| 490 |
+
propagate the contents of its contributor version.
|
| 491 |
+
|
| 492 |
+
In the following three paragraphs, a "patent license" is any express
|
| 493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
| 494 |
+
(such as an express permission to practice a patent or covenant not to
|
| 495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
| 496 |
+
party means to make such an agreement or commitment not to enforce a
|
| 497 |
+
patent against the party.
|
| 498 |
+
|
| 499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
| 500 |
+
and the Corresponding Source of the work is not available for anyone
|
| 501 |
+
to copy, free of charge and under the terms of this License, through a
|
| 502 |
+
publicly available network server or other readily accessible means,
|
| 503 |
+
then you must either (1) cause the Corresponding Source to be so
|
| 504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
| 505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
| 506 |
+
consistent with the requirements of this License, to extend the patent
|
| 507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
| 508 |
+
actual knowledge that, but for the patent license, your conveying the
|
| 509 |
+
covered work in a country, or your recipient's use of the covered work
|
| 510 |
+
in a country, would infringe one or more identifiable patents in that
|
| 511 |
+
country that you have reason to believe are valid.
|
| 512 |
+
|
| 513 |
+
If, pursuant to or in connection with a single transaction or
|
| 514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
| 515 |
+
covered work, and grant a patent license to some of the parties
|
| 516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
| 517 |
+
or convey a specific copy of the covered work, then the patent license
|
| 518 |
+
you grant is automatically extended to all recipients of the covered
|
| 519 |
+
work and works based on it.
|
| 520 |
+
|
| 521 |
+
A patent license is "discriminatory" if it does not include within
|
| 522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
| 523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
| 524 |
+
specifically granted under this License. You may not convey a covered
|
| 525 |
+
work if you are a party to an arrangement with a third party that is
|
| 526 |
+
in the business of distributing software, under which you make payment
|
| 527 |
+
to the third party based on the extent of your activity of conveying
|
| 528 |
+
the work, and under which the third party grants, to any of the
|
| 529 |
+
parties who would receive the covered work from you, a discriminatory
|
| 530 |
+
patent license (a) in connection with copies of the covered work
|
| 531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
| 532 |
+
for and in connection with specific products or compilations that
|
| 533 |
+
contain the covered work, unless you entered into that arrangement,
|
| 534 |
+
or that patent license was granted, prior to 28 March 2007.
|
| 535 |
+
|
| 536 |
+
Nothing in this License shall be construed as excluding or limiting
|
| 537 |
+
any implied license or other defenses to infringement that may
|
| 538 |
+
otherwise be available to you under applicable patent law.
|
| 539 |
+
|
| 540 |
+
12. No Surrender of Others' Freedom.
|
| 541 |
+
|
| 542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
| 543 |
+
otherwise) that contradict the conditions of this License, they do not
|
| 544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
| 545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
| 546 |
+
License and any other pertinent obligations, then as a consequence you may
|
| 547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
| 548 |
+
to collect a royalty for further conveying from those to whom you convey
|
| 549 |
+
the Program, the only way you could satisfy both those terms and this
|
| 550 |
+
License would be to refrain entirely from conveying the Program.
|
| 551 |
+
|
| 552 |
+
13. Use with the GNU Affero General Public License.
|
| 553 |
+
|
| 554 |
+
Notwithstanding any other provision of this License, you have
|
| 555 |
+
permission to link or combine any covered work with a work licensed
|
| 556 |
+
under version 3 of the GNU Affero General Public License into a single
|
| 557 |
+
combined work, and to convey the resulting work. The terms of this
|
| 558 |
+
License will continue to apply to the part which is the covered work,
|
| 559 |
+
but the special requirements of the GNU Affero General Public License,
|
| 560 |
+
section 13, concerning interaction through a network will apply to the
|
| 561 |
+
combination as such.
|
| 562 |
+
|
| 563 |
+
14. Revised Versions of this License.
|
| 564 |
+
|
| 565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
| 566 |
+
the GNU General Public License from time to time. Such new versions will
|
| 567 |
+
be similar in spirit to the present version, but may differ in detail to
|
| 568 |
+
address new problems or concerns.
|
| 569 |
+
|
| 570 |
+
Each version is given a distinguishing version number. If the
|
| 571 |
+
Program specifies that a certain numbered version of the GNU General
|
| 572 |
+
Public License "or any later version" applies to it, you have the
|
| 573 |
+
option of following the terms and conditions either of that numbered
|
| 574 |
+
version or of any later version published by the Free Software
|
| 575 |
+
Foundation. If the Program does not specify a version number of the
|
| 576 |
+
GNU General Public License, you may choose any version ever published
|
| 577 |
+
by the Free Software Foundation.
|
| 578 |
+
|
| 579 |
+
If the Program specifies that a proxy can decide which future
|
| 580 |
+
versions of the GNU General Public License can be used, that proxy's
|
| 581 |
+
public statement of acceptance of a version permanently authorizes you
|
| 582 |
+
to choose that version for the Program.
|
| 583 |
+
|
| 584 |
+
Later license versions may give you additional or different
|
| 585 |
+
permissions. However, no additional obligations are imposed on any
|
| 586 |
+
author or copyright holder as a result of your choosing to follow a
|
| 587 |
+
later version.
|
| 588 |
+
|
| 589 |
+
15. Disclaimer of Warranty.
|
| 590 |
+
|
| 591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
| 592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
| 593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
| 594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
| 595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
| 596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
| 597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
| 598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
| 599 |
+
|
| 600 |
+
16. Limitation of Liability.
|
| 601 |
+
|
| 602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
| 603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
| 604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
| 605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
| 606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
| 607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
| 608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
| 609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
| 610 |
+
SUCH DAMAGES.
|
| 611 |
+
|
| 612 |
+
17. Interpretation of Sections 15 and 16.
|
| 613 |
+
|
| 614 |
+
If the disclaimer of warranty and limitation of liability provided
|
| 615 |
+
above cannot be given local legal effect according to their terms,
|
| 616 |
+
reviewing courts shall apply local law that most closely approximates
|
| 617 |
+
an absolute waiver of all civil liability in connection with the
|
| 618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
| 619 |
+
copy of the Program in return for a fee.
|
| 620 |
+
|
| 621 |
+
END OF TERMS AND CONDITIONS
|
| 622 |
+
|
| 623 |
+
How to Apply These Terms to Your New Programs
|
| 624 |
+
|
| 625 |
+
If you develop a new program, and you want it to be of the greatest
|
| 626 |
+
possible use to the public, the best way to achieve this is to make it
|
| 627 |
+
free software which everyone can redistribute and change under these terms.
|
| 628 |
+
|
| 629 |
+
To do so, attach the following notices to the program. It is safest
|
| 630 |
+
to attach them to the start of each source file to most effectively
|
| 631 |
+
state the exclusion of warranty; and each file should have at least
|
| 632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
| 633 |
+
|
| 634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
| 635 |
+
Copyright (C) <year> <name of author>
|
| 636 |
+
|
| 637 |
+
This program is free software: you can redistribute it and/or modify
|
| 638 |
+
it under the terms of the GNU General Public License as published by
|
| 639 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 640 |
+
(at your option) any later version.
|
| 641 |
+
|
| 642 |
+
This program is distributed in the hope that it will be useful,
|
| 643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 645 |
+
GNU General Public License for more details.
|
| 646 |
+
|
| 647 |
+
You should have received a copy of the GNU General Public License
|
| 648 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 649 |
+
|
| 650 |
+
Also add information on how to contact you by electronic and paper mail.
|
| 651 |
+
|
| 652 |
+
If the program does terminal interaction, make it output a short
|
| 653 |
+
notice like this when it starts in an interactive mode:
|
| 654 |
+
|
| 655 |
+
<program> Copyright (C) <year> <name of author>
|
| 656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
| 657 |
+
This is free software, and you are welcome to redistribute it
|
| 658 |
+
under certain conditions; type `show c' for details.
|
| 659 |
+
|
| 660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
| 661 |
+
parts of the General Public License. Of course, your program's commands
|
| 662 |
+
might be different; for a GUI interface, you would use an "about box".
|
| 663 |
+
|
| 664 |
+
You should also get your employer (if you work as a programmer) or school,
|
| 665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
| 666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
| 667 |
+
<https://www.gnu.org/licenses/>.
|
| 668 |
+
|
| 669 |
+
The GNU General Public License does not permit incorporating your program
|
| 670 |
+
into proprietary programs. If your program is a subroutine library, you
|
| 671 |
+
may consider it more useful to permit linking proprietary applications with
|
| 672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
| 673 |
+
Public License instead of this License. But first, please read
|
| 674 |
+
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ComfyUI-VideoHelperSuite
|
| 2 |
+
Nodes related to video workflows
|
| 3 |
+
|
| 4 |
+
## I/O Nodes
|
| 5 |
+
### Load Video
|
| 6 |
+
Converts a video file into a series of images
|
| 7 |
+
- video: The video file to be loaded
|
| 8 |
+
- force_rate: Discards or duplicates frames as needed to hit a target frame rate. Disabled by setting to 0. This can be used to quickly match a suggested frame rate like the 8 fps of AnimateDiff.
|
| 9 |
+
- force_size: Allows for quick resizing to a number of suggested sizes. Several options allow you to set only width or height and determine the other from aspect ratio.
|
| 10 |
+
- frame_load_cap: The maximum number of frames which will be returned. This could also be thought of as the maximum batch size.
|
| 11 |
+
- skip_first_frames: How many frames to skip from the start of the video after adjusting for a forced frame rate. By incrementing this number by the frame_load_cap, you can easily process a longer input video in parts.
|
| 12 |
+
- select_every_nth: Allows for skipping a number of frames without considering the base frame rate or risking frame duplication. Often useful when working with animated gifs
|
| 13 |
+
A path variant of the Load Video node exists that allows loading videos from external paths
|
| 14 |
+

|
| 15 |
+

|
| 16 |
+
If [Advanced Previews](#advanced-previews) is enabled in the options menu of the web ui, the preview will reflect the current settings on the node.
|
| 17 |
+
### Load Image Sequence
|
| 18 |
+
Loads all image files from a subfolder. Options are similar to Load Video.
|
| 19 |
+
- image_load_cap: The maximum number of images which will be returned. This could also be thought of as the maximum batch size.
|
| 20 |
+
- skip_first_images: How many images to skip. By incrementing this number by image_load_cap, you can easily divide a long sequence of images into multiple batches.
|
| 21 |
+
- select_every_nth: Allows for skipping a number of images between every returned frame.
|
| 22 |
+
|
| 23 |
+
A path variant of Load Image sequence also exists.
|
| 24 |
+
### Video Combine
|
| 25 |
+
Combines a series of images into an output video
|
| 26 |
+
If the optional audio input is provided, it will also be combined into the output video
|
| 27 |
+
- frame_rate: How many of the input frames are displayed per second. A higher frame rate means that the output video plays faster and has less duration. This should usually be kept to 8 for AnimateDiff, or matched to the force_rate of a Load Video node.
|
| 28 |
+
- loop_count: How many additional times the video should repeat
|
| 29 |
+
- filename_prefix: The base file name used for output.
|
| 30 |
+
- You can save output to a subfolder: `subfolder/video`
|
| 31 |
+
- Like the builtin Save Image node, you can add timestamps. `%date:yyyy-MM-ddThh:mm:ss%` might become 2023-10-31T6:45:25
|
| 32 |
+
- format: The file format to use. Advanced information on configuring or adding additional video formats can be found in the [Video Formats](#video-formats) section.
|
| 33 |
+
- pingpong: Causes the input to be played back in the reverse to create a clean loop.
|
| 34 |
+
- save_output: Whether the image should be put into the output directory or the temp directory.
|
| 35 |
+
Returns: a `VHS_FILENAMES` which consists of a boolean indicating if save_output is enabled and a list of the full filepaths of all generated outputs in the order created. Accordingly `output[1][-1]` will be the most complete output.
|
| 36 |
+
|
| 37 |
+
Depending on the format chosen, additional options may become available, including
|
| 38 |
+
- crf: Describes the quality of the output video. A lower number gives a higher quality video and a larger file size, while a higher number gives a lower quality video with a smaller size. Scaling varies by codec, but visually lossless output generally occurs around 20.
|
| 39 |
+
- save_metadata: Includes a copy of the workflow in the output video which can be loaded by dragging and dropping the video, just like with images.
|
| 40 |
+
- pix_fmt: Changes how the pixel data is stored. `yuv420p10le` has higher color quality, but won't work on all devices
|
| 41 |
+
### Load Audio
|
| 42 |
+
Provides a way to load standalone audio files.
|
| 43 |
+
- seek_seconds: An optional start time for the audio file in seconds.
|
| 44 |
+
|
| 45 |
+
## Latent/Image Nodes
|
| 46 |
+
A number of utility nodes exist for managing latents. For each, there is an equivalent node which works on images.
|
| 47 |
+
### Split Batch
|
| 48 |
+
Divides the latents into two sets. The first `split_index` latents go to output A and the remainder to output B. If less then `split_index` latents are provided as input, all are passed to output A and output B is empty.
|
| 49 |
+
### Merge Batch
|
| 50 |
+
Combines two groups of latents into a single output. The order of the output is the latents in A followed by the latents in B.
|
| 51 |
+
If the input groups are not the same size, the node provides options for rescaling the latents before merging.
|
| 52 |
+
### Select Every Nth
|
| 53 |
+
The first of every `select_every_nth` input is passed and the remainder are discarded
|
| 54 |
+
### Get Count
|
| 55 |
+
### Duplicate Batch
|
| 56 |
+
|
| 57 |
+
## Video Previews
|
| 58 |
+
Load Video (Upload), Load Video (Path), Load Images (Upload), Load Images (Path) and Video Combine provide animated previews.
|
| 59 |
+
Nodes with previews provide additional functionality when right clicked
|
| 60 |
+
- Open preview
|
| 61 |
+
- Save preview
|
| 62 |
+
- Pause preview: Can improve performance with very large videos
|
| 63 |
+
- Hide preview: Can improve performance, save space
|
| 64 |
+
- Sync preview: Restarts all previews for side-by-side comparisons
|
| 65 |
+
|
| 66 |
+
### Advanced Previews
|
| 67 |
+
Advanced Previews must be manually enabled by clicking the settings gear next to Queue Prompt and checking the box for VHS Advanced Previews.
|
| 68 |
+
If enabled, videos which are displayed in the ui will be converted with ffmpeg on request. This has several benefits
|
| 69 |
+
- Previews for Load Video nodes will reflect the settings on the node such as skip_first_frames and frame_load_cap
|
| 70 |
+
- This makes it easy to select an exact portion of an input video and sync it with outputs
|
| 71 |
+
- It can use substantially less bandwidth if running the server remotely
|
| 72 |
+
- It can greatly improve the browser performance by downsizing videos to the in ui resolution, particularly useful with animated gifs
|
| 73 |
+
- It allows for previews of videos that would not normally be playable in browser.
|
| 74 |
+
- Can be limited to subdirectories of ComyUI if `VHS_STRICT_PATHS` is set as an environment variable.
|
| 75 |
+
|
| 76 |
+
This fucntionality is disabled since it comes with several downsides
|
| 77 |
+
- There is a delay before videos show in the browser. This delay can become quite large if the input video is long
|
| 78 |
+
- The preview videos are lower quality (The original can always be viewed with Right Click -> Open preview)
|
| 79 |
+
|
| 80 |
+
## Video Formats
|
| 81 |
+
Those familiar with ffmpeg are able to add json files to the video_formats folders to add new output types to Video Combine.
|
| 82 |
+
Consider the following example for av1-webm
|
| 83 |
+
```json
|
| 84 |
+
{
|
| 85 |
+
"main_pass":
|
| 86 |
+
[
|
| 87 |
+
"-n", "-c:v", "libsvtav1",
|
| 88 |
+
"-pix_fmt", "yuv420p10le",
|
| 89 |
+
"-crf", ["crf","INT", {"default": 23, "min": 0, "max": 100, "step": 1}]
|
| 90 |
+
],
|
| 91 |
+
"audio_pass": ["-c:a", "libopus"],
|
| 92 |
+
"extension": "webm",
|
| 93 |
+
"environment": {"SVT_LOG": "1"}
|
| 94 |
+
}
|
| 95 |
+
```
|
| 96 |
+
Most configuration takes place in `main_pass`, which is a list of arguments that are passed to ffmpeg.
|
| 97 |
+
- `"-n"` designates that the command should fail if a file of the same name already exists. This should never happen, but if some bug were to occur, it would ensure other files aren't overwritten.
|
| 98 |
+
- `"-c:v", "libsvtav1"` designates that the video should be encoded with an av1 codec using the new SVT-AV1 encoder. SVT-AV1 is much faster than libaom-av1, but may not exist in older versions of ffmpeg. Alternatively, av1_nvenc could be used for gpu encoding with newer nvidia cards.
|
| 99 |
+
- `"-pix_fmt", "yuv420p10le"` designates the standard pixel format with 10-bit color. It's important that some pixel format be specified to ensure a nonconfigurable input pix_fmt isn't used.
|
| 100 |
+
|
| 101 |
+
`audio pass` contains a list of arguments which are passed to ffmpeg when audio is passed into Video Combine
|
| 102 |
+
|
| 103 |
+
`extension` designates both the file extension and the container format that is used. If some of the above options are omitted from `main_pass` it can affect what default options are chosen.
|
| 104 |
+
`environment` can optionally be provided to set environment variables during execution. For av1 it's used to reduce the verbosity of logging so that only major errors are displayed.
|
| 105 |
+
`input_color_depth` effects the format in which pixels are passed to the ffmpeg subprocess. Current valid options are `8bit` and `16bit`. The later will produce higher quality output, but is experimental.
|
| 106 |
+
|
| 107 |
+
Fields can be exposed in the webui as a widget using a format similar to what is used in the creation of custom nodes. In the above example, the argument for `-crf` will be exposed as a format widget in the webui. Format widgets are a list of up to 3 terms
|
| 108 |
+
- The name of the widget that will be displayed in the web ui
|
| 109 |
+
- Either a primitive such as "INT" or "BOOLEAN", or a list of string options
|
| 110 |
+
- A dictionary of options
|
__init__.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .videohelpersuite.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
|
| 2 |
+
import folder_paths
|
| 3 |
+
from .videohelpersuite.server import server
|
| 4 |
+
from .videohelpersuite import documentation
|
| 5 |
+
from .videohelpersuite import latent_preview
|
| 6 |
+
|
| 7 |
+
WEB_DIRECTORY = "./web"
|
| 8 |
+
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
|
| 9 |
+
documentation.format_descriptions(NODE_CLASS_MAPPINGS)
|
pyproject.toml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "comfyui-videohelpersuite"
|
| 3 |
+
description = "Nodes related to video workflows"
|
| 4 |
+
version = "1.7.7"
|
| 5 |
+
license = { file = "LICENSE" }
|
| 6 |
+
dependencies = ["opencv-python", "imageio-ffmpeg"]
|
| 7 |
+
|
| 8 |
+
[project.urls]
|
| 9 |
+
Repository = "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"
|
| 10 |
+
|
| 11 |
+
# Used by Comfy Registry https://comfyregistry.org
|
| 12 |
+
[tool.comfy]
|
| 13 |
+
PublisherId = "kosinkadink"
|
| 14 |
+
DisplayName = "ComfyUI-VideoHelperSuite"
|
| 15 |
+
Icon = ""
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
opencv-python
|
| 2 |
+
imageio-ffmpeg
|
testframework/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Code to automate execution of the tests and evaluate the results.
|
| 2 |
+
Distributed as a `custom node`, and can be installed by copying or simlinking to the `custom_nodes` directory.
|
| 3 |
+
Requires that ffprobe be available and added to the path. Note that imageio-ffmpeg does not bundle ffprobe.
|
| 4 |
+
|
| 5 |
+
When installed, it adds a new sidebar tab to automate running one, or a folder of tests. This requires that the `Use new menu and workflow management` setting not be disabled
|
testframework/__init__.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from . import server
|
| 2 |
+
NODE_CLASS_MAPPINGS = {}
|
| 3 |
+
NODE_DISPLAY_NAME_MAPPINGS = {}
|
| 4 |
+
|
| 5 |
+
WEB_DIRECTORY = "./web"
|
| 6 |
+
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
|
testframework/server.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
import torch
|
| 5 |
+
import shutil
|
| 6 |
+
|
| 7 |
+
import server
|
| 8 |
+
import folder_paths
|
| 9 |
+
|
| 10 |
+
web = server.web
|
| 11 |
+
|
| 12 |
+
@server.PromptServer.instance.routes.post("/VHS_test")
|
| 13 |
+
async def test(request):
|
| 14 |
+
try:
|
| 15 |
+
req_data = await request.json()
|
| 16 |
+
output = req_data['output']['gifs'][0]
|
| 17 |
+
filename = output['filename']
|
| 18 |
+
typ = output['type']
|
| 19 |
+
base_args = ["ffprobe", "-v", "error", '-count_packets', "-show_entries", "stream", "-of", "json"]
|
| 20 |
+
video = folder_paths.get_annotated_filepath(f'{filename} [{typ}]')
|
| 21 |
+
vprobe = json.loads(subprocess.run(base_args + ['-select_streams', 'v:0', video],
|
| 22 |
+
capture_output=True, check=True).stdout)['streams'][0]
|
| 23 |
+
aprobe = json.loads(subprocess.run(base_args + ['-select_streams', 'a:0', video],
|
| 24 |
+
capture_output=True, check=True).stdout)['streams']
|
| 25 |
+
probe = {'video': vprobe}
|
| 26 |
+
if len(aprobe) > 0:
|
| 27 |
+
probe['audio'] = aprobe[0]
|
| 28 |
+
errors = []
|
| 29 |
+
compare = None
|
| 30 |
+
for test in req_data['tests']:
|
| 31 |
+
if test['type'] == 'compare':
|
| 32 |
+
compare = test
|
| 33 |
+
continue
|
| 34 |
+
key = test['key']
|
| 35 |
+
expected = test['value']
|
| 36 |
+
actual = probe[test['type']][key]
|
| 37 |
+
if expected != actual:
|
| 38 |
+
#Consider always dumping type?
|
| 39 |
+
errors.append(f'{key}: {expected} != {actual}')
|
| 40 |
+
if len(errors) == 0 and compare is not None:
|
| 41 |
+
if not os.path.exists(compare['filename']):
|
| 42 |
+
os.makedirs(os.path.split(compare['filename'])[0], exist_ok=True)
|
| 43 |
+
shutil.copy(video, compare['filename'])
|
| 44 |
+
print("Missing comparison file has been initialized from output:", os.path.abspath(compare['filename']))
|
| 45 |
+
else:
|
| 46 |
+
#NOTE: This does not include the full memory optimizations of VHS
|
| 47 |
+
#Tests should be small
|
| 48 |
+
#TODO: Figure out way to do opacity comparison. May need to do blending in python
|
| 49 |
+
#(easy, but slower and more memory intensive)
|
| 50 |
+
diff = subprocess.run(['ffmpeg', '-v', 'error', '-i', video, '-i', compare['filename'], '-filter_complex', 'blend=all_mode=grainextract', '-pix_fmt', 'rgb24', '-f', 'rawvideo', '-'], stdout=subprocess.PIPE, check=True).stdout
|
| 51 |
+
diff = torch.frombuffer(diff, dtype=torch.uint8).to(dtype=torch.float32).div_(255)
|
| 52 |
+
#diff = diff.reshape((-1,4))
|
| 53 |
+
d = (diff-0.5).abs().sum()/diff.size(0)
|
| 54 |
+
if d > compare['tolerance']:
|
| 55 |
+
errors.append(f'Similarity is outside specified tolerance: {d}')
|
| 56 |
+
else:
|
| 57 |
+
print('d:', d)
|
| 58 |
+
return web.json_response(errors)
|
| 59 |
+
except Exception as e:
|
| 60 |
+
return web.json_response(str(e))
|
testframework/web/js/testRunner.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import {app} from "../../../scripts/app.js";
|
| 3 |
+
import {api} from "../../../scripts/api.js";
|
| 4 |
+
|
| 5 |
+
let watched_nodes = {}
|
| 6 |
+
let resolve = undefined
|
| 7 |
+
let testURL = api.apiURL("/VHS_test")
|
| 8 |
+
let errors = []
|
| 9 |
+
api.addEventListener("executed", async function ({detail}) {
|
| 10 |
+
if (watched_nodes && watched_nodes[detail?.node]) {
|
| 11 |
+
if (detail?.output?.unfinished_batch) {
|
| 12 |
+
return
|
| 13 |
+
}
|
| 14 |
+
let requestBody = {tests: watched_nodes[detail.node], output: detail.output}
|
| 15 |
+
try {
|
| 16 |
+
let req = await fetch(api.apiURL("/VHS_test"),
|
| 17 |
+
{method: "POST", body: JSON.stringify(requestBody)});
|
| 18 |
+
let testResult = await req.json()
|
| 19 |
+
if (testResult.length != 0) {
|
| 20 |
+
errors.push(testResult)
|
| 21 |
+
}
|
| 22 |
+
} catch(e) {
|
| 23 |
+
errors.push(e)
|
| 24 |
+
}
|
| 25 |
+
if (!(watched_nodes.length -= 1)) {
|
| 26 |
+
resolve()
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
});
|
| 30 |
+
|
| 31 |
+
const workflowService = app.extensionManager.workflow
|
| 32 |
+
|
| 33 |
+
async function runTest(file) {
|
| 34 |
+
if (!file?.name?.endsWith(".json")) {
|
| 35 |
+
return false
|
| 36 |
+
}
|
| 37 |
+
let workflow = JSON.parse(await file.text())
|
| 38 |
+
await app.loadGraphData(workflow)
|
| 39 |
+
//NOTE: API is not used so workflow data is actually processed
|
| 40 |
+
watched_nodes = workflow.tests
|
| 41 |
+
errors = []
|
| 42 |
+
let p = new Promise((r) => resolve = r)
|
| 43 |
+
await app.queuePrompt()
|
| 44 |
+
//block until execution completes
|
| 45 |
+
await p
|
| 46 |
+
watched_nodes = {}
|
| 47 |
+
if (errors.length > 0) {
|
| 48 |
+
app.ui.dialog.show("Failed " + errors.length + " tests:\n" + errors)
|
| 49 |
+
return true
|
| 50 |
+
}
|
| 51 |
+
await workflowService.closeWorkflow(workflowService.activeWorkflow, {warnIfUnsaved: false})
|
| 52 |
+
return false
|
| 53 |
+
}
|
| 54 |
+
let iconOverride = document.createElement("style")
|
| 55 |
+
iconOverride.innerHTML = `.VHSTestIcon:before {content: '🧪';}`
|
| 56 |
+
document.body.append(iconOverride)
|
| 57 |
+
|
| 58 |
+
let testSidebar = {id: 'VHStest', title: 'VHS Test', icon: 'VHSTestIcon', type: 'custom',
|
| 59 |
+
render: (e) => {
|
| 60 |
+
e.innerHTML = `Select a folder containing tests
|
| 61 |
+
<input>
|
| 62 |
+
Or select a single test
|
| 63 |
+
<input>
|
| 64 |
+
`
|
| 65 |
+
|
| 66 |
+
const folderInput = e.children[0]
|
| 67 |
+
const fileInput = e.children[1]
|
| 68 |
+
Object.assign(folderInput, {
|
| 69 |
+
type: "file",
|
| 70 |
+
webkitdirectory: true,
|
| 71 |
+
onchange: async function() {
|
| 72 |
+
const startTime = Date.now()
|
| 73 |
+
let failedTests = false
|
| 74 |
+
for(const file of this.files) {
|
| 75 |
+
failedTests ||= await runTest(file)
|
| 76 |
+
}
|
| 77 |
+
this.value=""
|
| 78 |
+
if (!failedTests) {
|
| 79 |
+
console.log("All tests passed in " + ((Date.now() - startTime)/1000) + "s")
|
| 80 |
+
}
|
| 81 |
+
},
|
| 82 |
+
});
|
| 83 |
+
Object.assign(fileInput, {
|
| 84 |
+
type: "file",
|
| 85 |
+
accept: ".json",
|
| 86 |
+
onchange: async function() {
|
| 87 |
+
if (this.files.length) {
|
| 88 |
+
if(!(await runTest(this.files[0]))) {
|
| 89 |
+
console.log("Test complete")
|
| 90 |
+
}
|
| 91 |
+
this.value=""
|
| 92 |
+
}
|
| 93 |
+
},
|
| 94 |
+
});
|
| 95 |
+
}}
|
| 96 |
+
app.extensionManager.registerSidebarTab(testSidebar)
|
tests/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Workflows for automated testing of VHS. Most include an additional tests key to check the properties or perform comparisons on node outputs
|
tests/audio.json
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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| 18 |
+
"flags": {},
|
| 19 |
+
"order": 2,
|
| 20 |
+
"mode": 0,
|
| 21 |
+
"inputs": [
|
| 22 |
+
{
|
| 23 |
+
"name": "images",
|
| 24 |
+
"type": "IMAGE",
|
| 25 |
+
"link": 2
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"name": "audio",
|
| 29 |
+
"shape": 7,
|
| 30 |
+
"type": "AUDIO",
|
| 31 |
+
"link": 3
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"name": "meta_batch",
|
| 35 |
+
"shape": 7,
|
| 36 |
+
"type": "VHS_BatchManager",
|
| 37 |
+
"link": null
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"name": "vae",
|
| 41 |
+
"shape": 7,
|
| 42 |
+
"type": "VAE",
|
| 43 |
+
"link": null
|
| 44 |
+
}
|
| 45 |
+
],
|
| 46 |
+
"outputs": [
|
| 47 |
+
{
|
| 48 |
+
"name": "Filenames",
|
| 49 |
+
"type": "VHS_FILENAMES",
|
| 50 |
+
"links": null
|
| 51 |
+
}
|
| 52 |
+
],
|
| 53 |
+
"properties": {
|
| 54 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 55 |
+
},
|
| 56 |
+
"widgets_values": {
|
| 57 |
+
"frame_rate": 8,
|
| 58 |
+
"loop_count": 0,
|
| 59 |
+
"filename_prefix": "AnimateDiff",
|
| 60 |
+
"format": "video/webm",
|
| 61 |
+
"pix_fmt": "yuv420p",
|
| 62 |
+
"crf": 20,
|
| 63 |
+
"save_metadata": true,
|
| 64 |
+
"trim_to_audio": false,
|
| 65 |
+
"pingpong": false,
|
| 66 |
+
"save_output": false,
|
| 67 |
+
"videopreview": {
|
| 68 |
+
"hidden": false,
|
| 69 |
+
"paused": false,
|
| 70 |
+
"params": {}
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"id": 6,
|
| 76 |
+
"type": "VHS_VideoCombine",
|
| 77 |
+
"pos": [
|
| 78 |
+
503,
|
| 79 |
+
363
|
| 80 |
+
],
|
| 81 |
+
"size": [
|
| 82 |
+
210,
|
| 83 |
+
334
|
| 84 |
+
],
|
| 85 |
+
"flags": {},
|
| 86 |
+
"order": 3,
|
| 87 |
+
"mode": 0,
|
| 88 |
+
"inputs": [
|
| 89 |
+
{
|
| 90 |
+
"name": "images",
|
| 91 |
+
"type": "IMAGE",
|
| 92 |
+
"link": 4
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"name": "audio",
|
| 96 |
+
"shape": 7,
|
| 97 |
+
"type": "AUDIO",
|
| 98 |
+
"link": 5
|
| 99 |
+
},
|
| 100 |
+
{
|
| 101 |
+
"name": "meta_batch",
|
| 102 |
+
"shape": 7,
|
| 103 |
+
"type": "VHS_BatchManager",
|
| 104 |
+
"link": null
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"name": "vae",
|
| 108 |
+
"shape": 7,
|
| 109 |
+
"type": "VAE",
|
| 110 |
+
"link": null
|
| 111 |
+
}
|
| 112 |
+
],
|
| 113 |
+
"outputs": [
|
| 114 |
+
{
|
| 115 |
+
"name": "Filenames",
|
| 116 |
+
"type": "VHS_FILENAMES",
|
| 117 |
+
"links": null
|
| 118 |
+
}
|
| 119 |
+
],
|
| 120 |
+
"properties": {
|
| 121 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 122 |
+
},
|
| 123 |
+
"widgets_values": {
|
| 124 |
+
"frame_rate": 8,
|
| 125 |
+
"loop_count": 0,
|
| 126 |
+
"filename_prefix": "AnimateDiff",
|
| 127 |
+
"format": "video/h264-mp4",
|
| 128 |
+
"pix_fmt": "yuv420p",
|
| 129 |
+
"crf": 19,
|
| 130 |
+
"save_metadata": true,
|
| 131 |
+
"trim_to_audio": false,
|
| 132 |
+
"pingpong": false,
|
| 133 |
+
"save_output": false,
|
| 134 |
+
"videopreview": {
|
| 135 |
+
"hidden": false,
|
| 136 |
+
"paused": false,
|
| 137 |
+
"params": {}
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
},
|
| 141 |
+
{
|
| 142 |
+
"id": 4,
|
| 143 |
+
"type": "VHS_LoadVideoPath",
|
| 144 |
+
"pos": [
|
| 145 |
+
29,
|
| 146 |
+
16
|
| 147 |
+
],
|
| 148 |
+
"size": [
|
| 149 |
+
221.27618408203125,
|
| 150 |
+
413.1552734375
|
| 151 |
+
],
|
| 152 |
+
"flags": {},
|
| 153 |
+
"order": 0,
|
| 154 |
+
"mode": 0,
|
| 155 |
+
"inputs": [
|
| 156 |
+
{
|
| 157 |
+
"name": "meta_batch",
|
| 158 |
+
"shape": 7,
|
| 159 |
+
"type": "VHS_BatchManager",
|
| 160 |
+
"link": null
|
| 161 |
+
},
|
| 162 |
+
{
|
| 163 |
+
"name": "vae",
|
| 164 |
+
"shape": 7,
|
| 165 |
+
"type": "VAE",
|
| 166 |
+
"link": null
|
| 167 |
+
}
|
| 168 |
+
],
|
| 169 |
+
"outputs": [
|
| 170 |
+
{
|
| 171 |
+
"name": "IMAGE",
|
| 172 |
+
"type": "IMAGE",
|
| 173 |
+
"links": [
|
| 174 |
+
2,
|
| 175 |
+
4
|
| 176 |
+
]
|
| 177 |
+
},
|
| 178 |
+
{
|
| 179 |
+
"name": "frame_count",
|
| 180 |
+
"type": "INT",
|
| 181 |
+
"links": null
|
| 182 |
+
},
|
| 183 |
+
{
|
| 184 |
+
"name": "audio",
|
| 185 |
+
"type": "AUDIO",
|
| 186 |
+
"links": [
|
| 187 |
+
3
|
| 188 |
+
]
|
| 189 |
+
},
|
| 190 |
+
{
|
| 191 |
+
"name": "video_info",
|
| 192 |
+
"type": "VHS_VIDEOINFO",
|
| 193 |
+
"links": null
|
| 194 |
+
}
|
| 195 |
+
],
|
| 196 |
+
"properties": {
|
| 197 |
+
"Node name for S&R": "VHS_LoadVideoPath"
|
| 198 |
+
},
|
| 199 |
+
"widgets_values": {
|
| 200 |
+
"video": "input/bigbuckbunny.mp4",
|
| 201 |
+
"force_rate": 8,
|
| 202 |
+
"custom_width": 0,
|
| 203 |
+
"custom_height": 0,
|
| 204 |
+
"frame_load_cap": 30,
|
| 205 |
+
"skip_first_frames": 0,
|
| 206 |
+
"select_every_nth": 1,
|
| 207 |
+
"format": "AnimateDiff",
|
| 208 |
+
"videopreview": {
|
| 209 |
+
"hidden": false,
|
| 210 |
+
"paused": false,
|
| 211 |
+
"params": {
|
| 212 |
+
"filename": "input/bigbuckbunny.mp4",
|
| 213 |
+
"type": "path",
|
| 214 |
+
"format": "video/mp4",
|
| 215 |
+
"force_rate": 8,
|
| 216 |
+
"custom_width": 0,
|
| 217 |
+
"custom_height": 0,
|
| 218 |
+
"frame_load_cap": 30,
|
| 219 |
+
"skip_first_frames": 0,
|
| 220 |
+
"select_every_nth": 1
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
},
|
| 225 |
+
{
|
| 226 |
+
"id": 7,
|
| 227 |
+
"type": "VHS_LoadAudio",
|
| 228 |
+
"pos": [
|
| 229 |
+
83,
|
| 230 |
+
564
|
| 231 |
+
],
|
| 232 |
+
"size": [
|
| 233 |
+
218.93820190429688,
|
| 234 |
+
126
|
| 235 |
+
],
|
| 236 |
+
"flags": {},
|
| 237 |
+
"order": 1,
|
| 238 |
+
"mode": 0,
|
| 239 |
+
"inputs": [],
|
| 240 |
+
"outputs": [
|
| 241 |
+
{
|
| 242 |
+
"name": "audio",
|
| 243 |
+
"type": "AUDIO",
|
| 244 |
+
"links": [
|
| 245 |
+
5
|
| 246 |
+
]
|
| 247 |
+
},
|
| 248 |
+
{
|
| 249 |
+
"name": "duration",
|
| 250 |
+
"type": "FLOAT",
|
| 251 |
+
"links": null
|
| 252 |
+
}
|
| 253 |
+
],
|
| 254 |
+
"properties": {
|
| 255 |
+
"Node name for S&R": "VHS_LoadAudio"
|
| 256 |
+
},
|
| 257 |
+
"widgets_values": {
|
| 258 |
+
"audio_file": "input/bigbuckbunny.mp4",
|
| 259 |
+
"seek_seconds": 0,
|
| 260 |
+
"duration": 5
|
| 261 |
+
}
|
| 262 |
+
}
|
| 263 |
+
],
|
| 264 |
+
"links": [
|
| 265 |
+
[
|
| 266 |
+
2,
|
| 267 |
+
4,
|
| 268 |
+
0,
|
| 269 |
+
5,
|
| 270 |
+
0,
|
| 271 |
+
"IMAGE"
|
| 272 |
+
],
|
| 273 |
+
[
|
| 274 |
+
3,
|
| 275 |
+
4,
|
| 276 |
+
2,
|
| 277 |
+
5,
|
| 278 |
+
1,
|
| 279 |
+
"AUDIO"
|
| 280 |
+
],
|
| 281 |
+
[
|
| 282 |
+
4,
|
| 283 |
+
4,
|
| 284 |
+
0,
|
| 285 |
+
6,
|
| 286 |
+
0,
|
| 287 |
+
"IMAGE"
|
| 288 |
+
],
|
| 289 |
+
[
|
| 290 |
+
5,
|
| 291 |
+
7,
|
| 292 |
+
0,
|
| 293 |
+
6,
|
| 294 |
+
1,
|
| 295 |
+
"AUDIO"
|
| 296 |
+
]
|
| 297 |
+
],
|
| 298 |
+
"groups": [],
|
| 299 |
+
"config": {},
|
| 300 |
+
"extra": {
|
| 301 |
+
"frontendVersion": "1.25.0",
|
| 302 |
+
"VHS_latentpreview": true,
|
| 303 |
+
"VHS_latentpreviewrate": 0,
|
| 304 |
+
"VHS_MetadataImage": true,
|
| 305 |
+
"VHS_KeepIntermediate": true
|
| 306 |
+
},
|
| 307 |
+
"version": 0.4,
|
| 308 |
+
"tests": {
|
| 309 |
+
"5": [{"type": "audio", "key": "nb_read_packets", "value": "177"}],
|
| 310 |
+
"6": [{"type": "audio", "key": "nb_read_packets", "value": "176"}],
|
| 311 |
+
"length": 2
|
| 312 |
+
}
|
| 313 |
+
}
|
tests/batch4x4.json
ADDED
|
@@ -0,0 +1,535 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"last_node_id": 18,
|
| 3 |
+
"last_link_id": 28,
|
| 4 |
+
"nodes": [
|
| 5 |
+
{
|
| 6 |
+
"id": 16,
|
| 7 |
+
"type": "SolidMask",
|
| 8 |
+
"pos": [
|
| 9 |
+
38,
|
| 10 |
+
1066
|
| 11 |
+
],
|
| 12 |
+
"size": {
|
| 13 |
+
"0": 315,
|
| 14 |
+
"1": 106
|
| 15 |
+
},
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 0,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"outputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "MASK",
|
| 22 |
+
"type": "MASK",
|
| 23 |
+
"links": [
|
| 24 |
+
18
|
| 25 |
+
],
|
| 26 |
+
"slot_index": 0,
|
| 27 |
+
"shape": 3
|
| 28 |
+
}
|
| 29 |
+
],
|
| 30 |
+
"properties": {
|
| 31 |
+
"Node name for S&R": "SolidMask"
|
| 32 |
+
},
|
| 33 |
+
"widgets_values": [
|
| 34 |
+
1,
|
| 35 |
+
512,
|
| 36 |
+
512
|
| 37 |
+
]
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"id": 15,
|
| 41 |
+
"type": "ImageCompositeMasked",
|
| 42 |
+
"pos": [
|
| 43 |
+
412.0800030517579,
|
| 44 |
+
591.4099975585939
|
| 45 |
+
],
|
| 46 |
+
"size": {
|
| 47 |
+
"0": 315,
|
| 48 |
+
"1": 146
|
| 49 |
+
},
|
| 50 |
+
"flags": {},
|
| 51 |
+
"order": 5,
|
| 52 |
+
"mode": 0,
|
| 53 |
+
"inputs": [
|
| 54 |
+
{
|
| 55 |
+
"name": "destination",
|
| 56 |
+
"type": "IMAGE",
|
| 57 |
+
"link": 16
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"name": "source",
|
| 61 |
+
"type": "IMAGE",
|
| 62 |
+
"link": 17
|
| 63 |
+
},
|
| 64 |
+
{
|
| 65 |
+
"name": "mask",
|
| 66 |
+
"type": "MASK",
|
| 67 |
+
"link": 18
|
| 68 |
+
}
|
| 69 |
+
],
|
| 70 |
+
"outputs": [
|
| 71 |
+
{
|
| 72 |
+
"name": "IMAGE",
|
| 73 |
+
"type": "IMAGE",
|
| 74 |
+
"links": [
|
| 75 |
+
19
|
| 76 |
+
],
|
| 77 |
+
"slot_index": 0,
|
| 78 |
+
"shape": 3
|
| 79 |
+
}
|
| 80 |
+
],
|
| 81 |
+
"properties": {
|
| 82 |
+
"Node name for S&R": "ImageCompositeMasked"
|
| 83 |
+
},
|
| 84 |
+
"widgets_values": [
|
| 85 |
+
0,
|
| 86 |
+
0,
|
| 87 |
+
false
|
| 88 |
+
]
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"id": 18,
|
| 92 |
+
"type": "VHS_BatchManager",
|
| 93 |
+
"pos": [
|
| 94 |
+
329.8000881958008,
|
| 95 |
+
-87.40008056640622
|
| 96 |
+
],
|
| 97 |
+
"size": {
|
| 98 |
+
"0": 315,
|
| 99 |
+
"1": 58
|
| 100 |
+
},
|
| 101 |
+
"flags": {},
|
| 102 |
+
"order": 1,
|
| 103 |
+
"mode": 0,
|
| 104 |
+
"outputs": [
|
| 105 |
+
{
|
| 106 |
+
"name": "VHS_BatchManager",
|
| 107 |
+
"type": "VHS_BatchManager",
|
| 108 |
+
"links": [
|
| 109 |
+
24,
|
| 110 |
+
25,
|
| 111 |
+
26,
|
| 112 |
+
27
|
| 113 |
+
],
|
| 114 |
+
"slot_index": 0,
|
| 115 |
+
"shape": 3
|
| 116 |
+
}
|
| 117 |
+
],
|
| 118 |
+
"properties": {
|
| 119 |
+
"Node name for S&R": "VHS_BatchManager"
|
| 120 |
+
},
|
| 121 |
+
"widgets_values": {
|
| 122 |
+
"frames_per_batch": 4,
|
| 123 |
+
"count": 2
|
| 124 |
+
}
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"id": 10,
|
| 128 |
+
"type": "VHS_LoadVideoPath",
|
| 129 |
+
"pos": [
|
| 130 |
+
24,
|
| 131 |
+
102
|
| 132 |
+
],
|
| 133 |
+
"size": [
|
| 134 |
+
320,
|
| 135 |
+
420.7188019966722
|
| 136 |
+
],
|
| 137 |
+
"flags": {},
|
| 138 |
+
"order": 2,
|
| 139 |
+
"mode": 0,
|
| 140 |
+
"inputs": [
|
| 141 |
+
{
|
| 142 |
+
"name": "meta_batch",
|
| 143 |
+
"type": "VHS_BatchManager",
|
| 144 |
+
"link": 25,
|
| 145 |
+
"slot_index": 0
|
| 146 |
+
},
|
| 147 |
+
{
|
| 148 |
+
"name": "vae",
|
| 149 |
+
"type": "VAE",
|
| 150 |
+
"link": null
|
| 151 |
+
}
|
| 152 |
+
],
|
| 153 |
+
"outputs": [
|
| 154 |
+
{
|
| 155 |
+
"name": "IMAGE",
|
| 156 |
+
"type": "IMAGE",
|
| 157 |
+
"links": [
|
| 158 |
+
16,
|
| 159 |
+
22
|
| 160 |
+
],
|
| 161 |
+
"slot_index": 0,
|
| 162 |
+
"shape": 3
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"name": "frame_count",
|
| 166 |
+
"type": "INT",
|
| 167 |
+
"links": null,
|
| 168 |
+
"shape": 3
|
| 169 |
+
},
|
| 170 |
+
{
|
| 171 |
+
"name": "audio",
|
| 172 |
+
"type": "AUDIO",
|
| 173 |
+
"links": [
|
| 174 |
+
28
|
| 175 |
+
],
|
| 176 |
+
"slot_index": 2,
|
| 177 |
+
"shape": 3
|
| 178 |
+
},
|
| 179 |
+
{
|
| 180 |
+
"name": "video_info",
|
| 181 |
+
"type": "VHS_VIDEOINFO",
|
| 182 |
+
"links": null,
|
| 183 |
+
"shape": 3
|
| 184 |
+
}
|
| 185 |
+
],
|
| 186 |
+
"properties": {
|
| 187 |
+
"Node name for S&R": "VHS_LoadVideoPath"
|
| 188 |
+
},
|
| 189 |
+
"widgets_values": {
|
| 190 |
+
"video": "input/bigbuckbunny.mp4",
|
| 191 |
+
"force_rate": 8,
|
| 192 |
+
"force_size": "512x?",
|
| 193 |
+
"custom_width": 512,
|
| 194 |
+
"custom_height": 512,
|
| 195 |
+
"frame_load_cap": 16,
|
| 196 |
+
"skip_first_frames": 64,
|
| 197 |
+
"select_every_nth": 1,
|
| 198 |
+
"videopreview": {
|
| 199 |
+
"hidden": false,
|
| 200 |
+
"paused": false,
|
| 201 |
+
"params": {
|
| 202 |
+
"frame_load_cap": 16,
|
| 203 |
+
"skip_first_frames": 64,
|
| 204 |
+
"force_rate": 8,
|
| 205 |
+
"filename": "input/bigbuckbunny.mp4",
|
| 206 |
+
"type": "path",
|
| 207 |
+
"format": "video/mp4",
|
| 208 |
+
"select_every_nth": 1,
|
| 209 |
+
"force_size": "512x?"
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
},
|
| 214 |
+
{
|
| 215 |
+
"id": 14,
|
| 216 |
+
"type": "VHS_LoadVideoPath",
|
| 217 |
+
"pos": [
|
| 218 |
+
26,
|
| 219 |
+
598
|
| 220 |
+
],
|
| 221 |
+
"size": [
|
| 222 |
+
320,
|
| 223 |
+
444.7188019966722
|
| 224 |
+
],
|
| 225 |
+
"flags": {},
|
| 226 |
+
"order": 3,
|
| 227 |
+
"mode": 0,
|
| 228 |
+
"inputs": [
|
| 229 |
+
{
|
| 230 |
+
"name": "meta_batch",
|
| 231 |
+
"type": "VHS_BatchManager",
|
| 232 |
+
"link": 26,
|
| 233 |
+
"slot_index": 0
|
| 234 |
+
},
|
| 235 |
+
{
|
| 236 |
+
"name": "vae",
|
| 237 |
+
"type": "VAE",
|
| 238 |
+
"link": null
|
| 239 |
+
}
|
| 240 |
+
],
|
| 241 |
+
"outputs": [
|
| 242 |
+
{
|
| 243 |
+
"name": "IMAGE",
|
| 244 |
+
"type": "IMAGE",
|
| 245 |
+
"links": [
|
| 246 |
+
17
|
| 247 |
+
],
|
| 248 |
+
"slot_index": 0,
|
| 249 |
+
"shape": 3
|
| 250 |
+
},
|
| 251 |
+
{
|
| 252 |
+
"name": "frame_count",
|
| 253 |
+
"type": "INT",
|
| 254 |
+
"links": null,
|
| 255 |
+
"shape": 3
|
| 256 |
+
},
|
| 257 |
+
{
|
| 258 |
+
"name": "audio",
|
| 259 |
+
"type": "VHS_AUDIO",
|
| 260 |
+
"links": [],
|
| 261 |
+
"slot_index": 2,
|
| 262 |
+
"shape": 3
|
| 263 |
+
},
|
| 264 |
+
{
|
| 265 |
+
"name": "video_info",
|
| 266 |
+
"type": "VHS_VIDEOINFO",
|
| 267 |
+
"links": null,
|
| 268 |
+
"shape": 3
|
| 269 |
+
}
|
| 270 |
+
],
|
| 271 |
+
"properties": {
|
| 272 |
+
"Node name for S&R": "VHS_LoadVideoPath"
|
| 273 |
+
},
|
| 274 |
+
"widgets_values": {
|
| 275 |
+
"video": "input/bigbuckbunny.mp4",
|
| 276 |
+
"force_rate": 8,
|
| 277 |
+
"force_size": "Custom Width",
|
| 278 |
+
"custom_width": 384,
|
| 279 |
+
"custom_height": 512,
|
| 280 |
+
"frame_load_cap": 16,
|
| 281 |
+
"skip_first_frames": 64,
|
| 282 |
+
"select_every_nth": 1,
|
| 283 |
+
"videopreview": {
|
| 284 |
+
"hidden": false,
|
| 285 |
+
"paused": false,
|
| 286 |
+
"params": {
|
| 287 |
+
"frame_load_cap": 16,
|
| 288 |
+
"skip_first_frames": 64,
|
| 289 |
+
"force_rate": 8,
|
| 290 |
+
"filename": "input/bigbuckbunny.mp4",
|
| 291 |
+
"type": "path",
|
| 292 |
+
"format": "video/mp4",
|
| 293 |
+
"select_every_nth": 1,
|
| 294 |
+
"force_size": "512x?"
|
| 295 |
+
}
|
| 296 |
+
}
|
| 297 |
+
}
|
| 298 |
+
},
|
| 299 |
+
{
|
| 300 |
+
"id": 11,
|
| 301 |
+
"type": "VHS_VideoCombine",
|
| 302 |
+
"pos": [
|
| 303 |
+
762,
|
| 304 |
+
646
|
| 305 |
+
],
|
| 306 |
+
"size": [
|
| 307 |
+
320,
|
| 308 |
+
492.75
|
| 309 |
+
],
|
| 310 |
+
"flags": {},
|
| 311 |
+
"order": 6,
|
| 312 |
+
"mode": 0,
|
| 313 |
+
"inputs": [
|
| 314 |
+
{
|
| 315 |
+
"name": "images",
|
| 316 |
+
"type": "IMAGE",
|
| 317 |
+
"link": 19
|
| 318 |
+
},
|
| 319 |
+
{
|
| 320 |
+
"name": "audio",
|
| 321 |
+
"type": "AUDIO",
|
| 322 |
+
"link": 28
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"name": "meta_batch",
|
| 326 |
+
"type": "VHS_BatchManager",
|
| 327 |
+
"link": 27,
|
| 328 |
+
"slot_index": 2
|
| 329 |
+
},
|
| 330 |
+
{
|
| 331 |
+
"name": "vae",
|
| 332 |
+
"type": "VAE",
|
| 333 |
+
"link": null
|
| 334 |
+
}
|
| 335 |
+
],
|
| 336 |
+
"outputs": [
|
| 337 |
+
{
|
| 338 |
+
"name": "Filenames",
|
| 339 |
+
"type": "VHS_FILENAMES",
|
| 340 |
+
"links": null,
|
| 341 |
+
"shape": 3
|
| 342 |
+
}
|
| 343 |
+
],
|
| 344 |
+
"properties": {
|
| 345 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 346 |
+
},
|
| 347 |
+
"widgets_values": {
|
| 348 |
+
"frame_rate": 8,
|
| 349 |
+
"loop_count": 0,
|
| 350 |
+
"filename_prefix": "AnimateDiff",
|
| 351 |
+
"format": "video/h264-mp4",
|
| 352 |
+
"pix_fmt": "yuv420p",
|
| 353 |
+
"crf": 19,
|
| 354 |
+
"save_metadata": true,
|
| 355 |
+
"pingpong": false,
|
| 356 |
+
"save_output": false,
|
| 357 |
+
"videopreview": {
|
| 358 |
+
"hidden": false,
|
| 359 |
+
"paused": false,
|
| 360 |
+
"params": {
|
| 361 |
+
"filename": "AnimateDiff_00005-audio.mp4",
|
| 362 |
+
"subfolder": "",
|
| 363 |
+
"type": "temp",
|
| 364 |
+
"format": "video/h264-mp4",
|
| 365 |
+
"frame_rate": 8
|
| 366 |
+
}
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
},
|
| 370 |
+
{
|
| 371 |
+
"id": 17,
|
| 372 |
+
"type": "VHS_VideoCombine",
|
| 373 |
+
"pos": [
|
| 374 |
+
756,
|
| 375 |
+
100
|
| 376 |
+
],
|
| 377 |
+
"size": [
|
| 378 |
+
320,
|
| 379 |
+
492.75
|
| 380 |
+
],
|
| 381 |
+
"flags": {},
|
| 382 |
+
"order": 4,
|
| 383 |
+
"mode": 0,
|
| 384 |
+
"inputs": [
|
| 385 |
+
{
|
| 386 |
+
"name": "images",
|
| 387 |
+
"type": "IMAGE",
|
| 388 |
+
"link": 22
|
| 389 |
+
},
|
| 390 |
+
{
|
| 391 |
+
"name": "audio",
|
| 392 |
+
"type": "VHS_AUDIO",
|
| 393 |
+
"link": null
|
| 394 |
+
},
|
| 395 |
+
{
|
| 396 |
+
"name": "meta_batch",
|
| 397 |
+
"type": "VHS_BatchManager",
|
| 398 |
+
"link": 24,
|
| 399 |
+
"slot_index": 2
|
| 400 |
+
},
|
| 401 |
+
{
|
| 402 |
+
"name": "vae",
|
| 403 |
+
"type": "VAE",
|
| 404 |
+
"link": null
|
| 405 |
+
}
|
| 406 |
+
],
|
| 407 |
+
"outputs": [
|
| 408 |
+
{
|
| 409 |
+
"name": "Filenames",
|
| 410 |
+
"type": "VHS_FILENAMES",
|
| 411 |
+
"links": null,
|
| 412 |
+
"shape": 3
|
| 413 |
+
}
|
| 414 |
+
],
|
| 415 |
+
"properties": {
|
| 416 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 417 |
+
},
|
| 418 |
+
"widgets_values": {
|
| 419 |
+
"frame_rate": 8,
|
| 420 |
+
"loop_count": 0,
|
| 421 |
+
"filename_prefix": "AnimateDiff",
|
| 422 |
+
"format": "video/webm",
|
| 423 |
+
"pix_fmt": "yuv420p",
|
| 424 |
+
"crf": 20,
|
| 425 |
+
"save_metadata": true,
|
| 426 |
+
"pingpong": false,
|
| 427 |
+
"save_output": false,
|
| 428 |
+
"videopreview": {
|
| 429 |
+
"hidden": false,
|
| 430 |
+
"paused": false,
|
| 431 |
+
"params": {
|
| 432 |
+
"filename": "AnimateDiff_00004.webm",
|
| 433 |
+
"subfolder": "",
|
| 434 |
+
"type": "temp",
|
| 435 |
+
"format": "video/webm",
|
| 436 |
+
"frame_rate": 8
|
| 437 |
+
}
|
| 438 |
+
}
|
| 439 |
+
}
|
| 440 |
+
}
|
| 441 |
+
],
|
| 442 |
+
"links": [
|
| 443 |
+
[
|
| 444 |
+
16,
|
| 445 |
+
10,
|
| 446 |
+
0,
|
| 447 |
+
15,
|
| 448 |
+
0,
|
| 449 |
+
"IMAGE"
|
| 450 |
+
],
|
| 451 |
+
[
|
| 452 |
+
17,
|
| 453 |
+
14,
|
| 454 |
+
0,
|
| 455 |
+
15,
|
| 456 |
+
1,
|
| 457 |
+
"IMAGE"
|
| 458 |
+
],
|
| 459 |
+
[
|
| 460 |
+
18,
|
| 461 |
+
16,
|
| 462 |
+
0,
|
| 463 |
+
15,
|
| 464 |
+
2,
|
| 465 |
+
"MASK"
|
| 466 |
+
],
|
| 467 |
+
[
|
| 468 |
+
19,
|
| 469 |
+
15,
|
| 470 |
+
0,
|
| 471 |
+
11,
|
| 472 |
+
0,
|
| 473 |
+
"IMAGE"
|
| 474 |
+
],
|
| 475 |
+
[
|
| 476 |
+
22,
|
| 477 |
+
10,
|
| 478 |
+
0,
|
| 479 |
+
17,
|
| 480 |
+
0,
|
| 481 |
+
"IMAGE"
|
| 482 |
+
],
|
| 483 |
+
[
|
| 484 |
+
24,
|
| 485 |
+
18,
|
| 486 |
+
0,
|
| 487 |
+
17,
|
| 488 |
+
2,
|
| 489 |
+
"VHS_BatchManager"
|
| 490 |
+
],
|
| 491 |
+
[
|
| 492 |
+
25,
|
| 493 |
+
18,
|
| 494 |
+
0,
|
| 495 |
+
10,
|
| 496 |
+
0,
|
| 497 |
+
"VHS_BatchManager"
|
| 498 |
+
],
|
| 499 |
+
[
|
| 500 |
+
26,
|
| 501 |
+
18,
|
| 502 |
+
0,
|
| 503 |
+
14,
|
| 504 |
+
0,
|
| 505 |
+
"VHS_BatchManager"
|
| 506 |
+
],
|
| 507 |
+
[
|
| 508 |
+
27,
|
| 509 |
+
18,
|
| 510 |
+
0,
|
| 511 |
+
11,
|
| 512 |
+
2,
|
| 513 |
+
"VHS_BatchManager"
|
| 514 |
+
],
|
| 515 |
+
[
|
| 516 |
+
28,
|
| 517 |
+
10,
|
| 518 |
+
2,
|
| 519 |
+
11,
|
| 520 |
+
1,
|
| 521 |
+
"VHS_AUDIO"
|
| 522 |
+
]
|
| 523 |
+
],
|
| 524 |
+
"groups": [],
|
| 525 |
+
"config": {},
|
| 526 |
+
"extra": {},
|
| 527 |
+
"version": 0.4,
|
| 528 |
+
"tests": {
|
| 529 |
+
"17": [{"type": "video", "key": "nb_read_packets", "value": "16"}],
|
| 530 |
+
"11": [{"type": "video", "key": "nb_read_packets", "value": "16"},
|
| 531 |
+
{"type": "compare", "filename": "custom_nodes/ComfyUI-VideoHelperSuite/tests/outputs/batch.mp4", "tolerance": 0.02}
|
| 532 |
+
],
|
| 533 |
+
"length": 1
|
| 534 |
+
}
|
| 535 |
+
}
|
tests/converted-format-input.json
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"last_node_id": 19,
|
| 3 |
+
"last_link_id": 20,
|
| 4 |
+
"nodes": [
|
| 5 |
+
{
|
| 6 |
+
"id": 18,
|
| 7 |
+
"type": "PrimitiveNode",
|
| 8 |
+
"pos": [
|
| 9 |
+
318,
|
| 10 |
+
618
|
| 11 |
+
],
|
| 12 |
+
"size": [
|
| 13 |
+
210,
|
| 14 |
+
82
|
| 15 |
+
],
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 0,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"inputs": [],
|
| 20 |
+
"outputs": [
|
| 21 |
+
{
|
| 22 |
+
"name": "INT",
|
| 23 |
+
"type": "INT",
|
| 24 |
+
"links": [
|
| 25 |
+
18
|
| 26 |
+
],
|
| 27 |
+
"widget": {
|
| 28 |
+
"name": "crf"
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
],
|
| 32 |
+
"properties": {
|
| 33 |
+
"Run widget replace on values": false
|
| 34 |
+
},
|
| 35 |
+
"widgets_values": [
|
| 36 |
+
60,
|
| 37 |
+
"fixed"
|
| 38 |
+
]
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"id": 11,
|
| 42 |
+
"type": "LoadImage",
|
| 43 |
+
"pos": [
|
| 44 |
+
260.4530029296875,
|
| 45 |
+
233.2003173828125
|
| 46 |
+
],
|
| 47 |
+
"size": [
|
| 48 |
+
315,
|
| 49 |
+
314
|
| 50 |
+
],
|
| 51 |
+
"flags": {},
|
| 52 |
+
"order": 1,
|
| 53 |
+
"mode": 0,
|
| 54 |
+
"inputs": [],
|
| 55 |
+
"outputs": [
|
| 56 |
+
{
|
| 57 |
+
"name": "IMAGE",
|
| 58 |
+
"type": "IMAGE",
|
| 59 |
+
"links": [
|
| 60 |
+
19
|
| 61 |
+
],
|
| 62 |
+
"slot_index": 0
|
| 63 |
+
},
|
| 64 |
+
{
|
| 65 |
+
"name": "MASK",
|
| 66 |
+
"type": "MASK",
|
| 67 |
+
"links": null
|
| 68 |
+
}
|
| 69 |
+
],
|
| 70 |
+
"properties": {
|
| 71 |
+
"Node name for S&R": "LoadImage"
|
| 72 |
+
},
|
| 73 |
+
"widgets_values": [
|
| 74 |
+
"example.png",
|
| 75 |
+
"image"
|
| 76 |
+
]
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"id": 17,
|
| 80 |
+
"type": "VHS_VideoCombine",
|
| 81 |
+
"pos": [
|
| 82 |
+
733.3749389648438,
|
| 83 |
+
338.28924560546875
|
| 84 |
+
],
|
| 85 |
+
"size": [
|
| 86 |
+
222.91415405273438,
|
| 87 |
+
522.9141845703125
|
| 88 |
+
],
|
| 89 |
+
"flags": {},
|
| 90 |
+
"order": 3,
|
| 91 |
+
"mode": 0,
|
| 92 |
+
"inputs": [
|
| 93 |
+
{
|
| 94 |
+
"name": "images",
|
| 95 |
+
"type": "IMAGE",
|
| 96 |
+
"link": 19
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"name": "audio",
|
| 100 |
+
"type": "AUDIO",
|
| 101 |
+
"link": null,
|
| 102 |
+
"shape": 7
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"name": "meta_batch",
|
| 106 |
+
"type": "VHS_BatchManager",
|
| 107 |
+
"link": null,
|
| 108 |
+
"shape": 7
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"name": "vae",
|
| 112 |
+
"type": "VAE",
|
| 113 |
+
"link": null,
|
| 114 |
+
"shape": 7
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"name": "crf",
|
| 118 |
+
"type": "INT",
|
| 119 |
+
"link": 18,
|
| 120 |
+
"widget": {
|
| 121 |
+
"name": "crf"
|
| 122 |
+
}
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"name": "pix_fmt",
|
| 126 |
+
"type": [
|
| 127 |
+
"yuv420p",
|
| 128 |
+
"yuv420p10le"
|
| 129 |
+
],
|
| 130 |
+
"link": 20,
|
| 131 |
+
"widget": {
|
| 132 |
+
"name": "pix_fmt"
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
],
|
| 136 |
+
"outputs": [
|
| 137 |
+
{
|
| 138 |
+
"name": "Filenames",
|
| 139 |
+
"type": "VHS_FILENAMES",
|
| 140 |
+
"links": null
|
| 141 |
+
}
|
| 142 |
+
],
|
| 143 |
+
"properties": {
|
| 144 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 145 |
+
},
|
| 146 |
+
"widgets_values": {
|
| 147 |
+
"frame_rate": 8,
|
| 148 |
+
"loop_count": 0,
|
| 149 |
+
"filename_prefix": "AnimateDiff",
|
| 150 |
+
"format": "video/h264-mp4",
|
| 151 |
+
"pix_fmt": "yuv420p10le",
|
| 152 |
+
"crf": 60,
|
| 153 |
+
"save_metadata": true,
|
| 154 |
+
"pingpong": false,
|
| 155 |
+
"save_output": false,
|
| 156 |
+
"videopreview": {
|
| 157 |
+
"hidden": false,
|
| 158 |
+
"paused": false,
|
| 159 |
+
"params": {
|
| 160 |
+
"filename": "AnimateDiff_00001.mp4",
|
| 161 |
+
"subfolder": "",
|
| 162 |
+
"type": "temp",
|
| 163 |
+
"format": "video/h264-mp4",
|
| 164 |
+
"frame_rate": 8
|
| 165 |
+
},
|
| 166 |
+
"muted": false
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
},
|
| 170 |
+
{
|
| 171 |
+
"id": 19,
|
| 172 |
+
"type": "PrimitiveNode",
|
| 173 |
+
"pos": [
|
| 174 |
+
300,
|
| 175 |
+
760
|
| 176 |
+
],
|
| 177 |
+
"size": [
|
| 178 |
+
290,
|
| 179 |
+
110
|
| 180 |
+
],
|
| 181 |
+
"flags": {},
|
| 182 |
+
"order": 2,
|
| 183 |
+
"mode": 0,
|
| 184 |
+
"inputs": [],
|
| 185 |
+
"outputs": [
|
| 186 |
+
{
|
| 187 |
+
"name": "COMBO",
|
| 188 |
+
"type": "COMBO",
|
| 189 |
+
"links": [
|
| 190 |
+
20
|
| 191 |
+
],
|
| 192 |
+
"widget": {
|
| 193 |
+
"name": "pix_fmt"
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
],
|
| 197 |
+
"properties": {
|
| 198 |
+
"Run widget replace on values": false
|
| 199 |
+
},
|
| 200 |
+
"widgets_values": [
|
| 201 |
+
"yuv420p10le",
|
| 202 |
+
"fixed",
|
| 203 |
+
""
|
| 204 |
+
]
|
| 205 |
+
}
|
| 206 |
+
],
|
| 207 |
+
"links": [
|
| 208 |
+
[
|
| 209 |
+
18,
|
| 210 |
+
18,
|
| 211 |
+
0,
|
| 212 |
+
17,
|
| 213 |
+
4,
|
| 214 |
+
"INT"
|
| 215 |
+
],
|
| 216 |
+
[
|
| 217 |
+
19,
|
| 218 |
+
11,
|
| 219 |
+
0,
|
| 220 |
+
17,
|
| 221 |
+
0,
|
| 222 |
+
"IMAGE"
|
| 223 |
+
],
|
| 224 |
+
[
|
| 225 |
+
20,
|
| 226 |
+
19,
|
| 227 |
+
0,
|
| 228 |
+
17,
|
| 229 |
+
5,
|
| 230 |
+
[
|
| 231 |
+
"yuv420p",
|
| 232 |
+
"yuv420p10le"
|
| 233 |
+
]
|
| 234 |
+
]
|
| 235 |
+
],
|
| 236 |
+
"groups": [],
|
| 237 |
+
"config": {},
|
| 238 |
+
"extra": {
|
| 239 |
+
"ds": {
|
| 240 |
+
"scale": 0.8264462809917354,
|
| 241 |
+
"offset": [
|
| 242 |
+
45.8650452880864,
|
| 243 |
+
-157.46987175292935
|
| 244 |
+
]
|
| 245 |
+
}
|
| 246 |
+
},
|
| 247 |
+
"version": 0.4,
|
| 248 |
+
"tests": {
|
| 249 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| 5 |
+
{
|
| 6 |
+
"id": 18,
|
| 7 |
+
"type": "VHS_VideoInfoLoaded",
|
| 8 |
+
"pos": [
|
| 9 |
+
424,
|
| 10 |
+
427
|
| 11 |
+
],
|
| 12 |
+
"size": {
|
| 13 |
+
"0": 304.79998779296875,
|
| 14 |
+
"1": 106
|
| 15 |
+
},
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 2,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"inputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "video_info",
|
| 22 |
+
"type": "VHS_VIDEOINFO",
|
| 23 |
+
"link": 19
|
| 24 |
+
}
|
| 25 |
+
],
|
| 26 |
+
"outputs": [
|
| 27 |
+
{
|
| 28 |
+
"name": "fps🟦",
|
| 29 |
+
"type": "FLOAT",
|
| 30 |
+
"links": [
|
| 31 |
+
20
|
| 32 |
+
],
|
| 33 |
+
"slot_index": 0,
|
| 34 |
+
"shape": 3
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"name": "frame_count🟦",
|
| 38 |
+
"type": "INT",
|
| 39 |
+
"links": null,
|
| 40 |
+
"shape": 3
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"name": "duration🟦",
|
| 44 |
+
"type": "FLOAT",
|
| 45 |
+
"links": null,
|
| 46 |
+
"shape": 3
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"name": "width🟦",
|
| 50 |
+
"type": "INT",
|
| 51 |
+
"links": null,
|
| 52 |
+
"shape": 3
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "height🟦",
|
| 56 |
+
"type": "INT",
|
| 57 |
+
"links": null,
|
| 58 |
+
"shape": 3
|
| 59 |
+
}
|
| 60 |
+
],
|
| 61 |
+
"properties": {
|
| 62 |
+
"Node name for S&R": "VHS_VideoInfoLoaded"
|
| 63 |
+
},
|
| 64 |
+
"widgets_values": {}
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"id": 17,
|
| 68 |
+
"type": "VHS_VideoCombine",
|
| 69 |
+
"pos": [
|
| 70 |
+
783,
|
| 71 |
+
223
|
| 72 |
+
],
|
| 73 |
+
"size": [
|
| 74 |
+
315,
|
| 75 |
+
286
|
| 76 |
+
],
|
| 77 |
+
"flags": {},
|
| 78 |
+
"order": 3,
|
| 79 |
+
"mode": 0,
|
| 80 |
+
"inputs": [
|
| 81 |
+
{
|
| 82 |
+
"name": "images",
|
| 83 |
+
"type": "IMAGE",
|
| 84 |
+
"link": 21
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"name": "audio",
|
| 88 |
+
"type": "VHS_AUDIO",
|
| 89 |
+
"link": null
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"name": "meta_batch",
|
| 93 |
+
"type": "VHS_BatchManager",
|
| 94 |
+
"link": null
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"name": "frame_rate",
|
| 98 |
+
"type": "FLOAT",
|
| 99 |
+
"link": 20,
|
| 100 |
+
"widget": {
|
| 101 |
+
"name": "frame_rate"
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
],
|
| 105 |
+
"outputs": [
|
| 106 |
+
{
|
| 107 |
+
"name": "Filenames",
|
| 108 |
+
"type": "VHS_FILENAMES",
|
| 109 |
+
"links": null,
|
| 110 |
+
"shape": 3
|
| 111 |
+
}
|
| 112 |
+
],
|
| 113 |
+
"properties": {
|
| 114 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 115 |
+
},
|
| 116 |
+
"widgets_values": {
|
| 117 |
+
"frame_rate": 8,
|
| 118 |
+
"loop_count": 0,
|
| 119 |
+
"filename_prefix": "AnimateDiff",
|
| 120 |
+
"format": "video/h264-mp4",
|
| 121 |
+
"pix_fmt": "yuv420p",
|
| 122 |
+
"crf": 19,
|
| 123 |
+
"save_metadata": true,
|
| 124 |
+
"pingpong": false,
|
| 125 |
+
"save_output": false,
|
| 126 |
+
"videopreview": {
|
| 127 |
+
"hidden": false,
|
| 128 |
+
"paused": false,
|
| 129 |
+
"params": {
|
| 130 |
+
"filename": "AnimateDiff_00001.mp4",
|
| 131 |
+
"subfolder": "",
|
| 132 |
+
"type": "temp",
|
| 133 |
+
"format": "video/h264-mp4"
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
},
|
| 138 |
+
{
|
| 139 |
+
"id": 16,
|
| 140 |
+
"type": "VHS_LoadVideoPath",
|
| 141 |
+
"pos": [
|
| 142 |
+
96,
|
| 143 |
+
230
|
| 144 |
+
],
|
| 145 |
+
"size": [
|
| 146 |
+
315,
|
| 147 |
+
449.5
|
| 148 |
+
],
|
| 149 |
+
"flags": {},
|
| 150 |
+
"order": 1,
|
| 151 |
+
"mode": 0,
|
| 152 |
+
"inputs": [
|
| 153 |
+
{
|
| 154 |
+
"name": "meta_batch",
|
| 155 |
+
"type": "VHS_BatchManager",
|
| 156 |
+
"link": null
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
"name": "frame_load_cap",
|
| 160 |
+
"type": "INT",
|
| 161 |
+
"link": 23,
|
| 162 |
+
"slot_index": 1,
|
| 163 |
+
"widget": {
|
| 164 |
+
"name": "frame_load_cap"
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
],
|
| 168 |
+
"outputs": [
|
| 169 |
+
{
|
| 170 |
+
"name": "IMAGE",
|
| 171 |
+
"type": "IMAGE",
|
| 172 |
+
"links": [
|
| 173 |
+
21
|
| 174 |
+
],
|
| 175 |
+
"slot_index": 0,
|
| 176 |
+
"shape": 3
|
| 177 |
+
},
|
| 178 |
+
{
|
| 179 |
+
"name": "frame_count",
|
| 180 |
+
"type": "INT",
|
| 181 |
+
"links": null,
|
| 182 |
+
"shape": 3
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"name": "audio",
|
| 186 |
+
"type": "VHS_AUDIO",
|
| 187 |
+
"links": null,
|
| 188 |
+
"shape": 3
|
| 189 |
+
},
|
| 190 |
+
{
|
| 191 |
+
"name": "video_info",
|
| 192 |
+
"type": "VHS_VIDEOINFO",
|
| 193 |
+
"links": [
|
| 194 |
+
19
|
| 195 |
+
],
|
| 196 |
+
"slot_index": 3,
|
| 197 |
+
"shape": 3
|
| 198 |
+
}
|
| 199 |
+
],
|
| 200 |
+
"properties": {
|
| 201 |
+
"Node name for S&R": "VHS_LoadVideoPath"
|
| 202 |
+
},
|
| 203 |
+
"widgets_values": {
|
| 204 |
+
"video": "input/leader.webm",
|
| 205 |
+
"force_rate": 0,
|
| 206 |
+
"force_size": "Disabled",
|
| 207 |
+
"custom_width": 512,
|
| 208 |
+
"custom_height": 512,
|
| 209 |
+
"frame_load_cap": 64,
|
| 210 |
+
"skip_first_frames": 0,
|
| 211 |
+
"select_every_nth": 1,
|
| 212 |
+
"videopreview": {
|
| 213 |
+
"hidden": false,
|
| 214 |
+
"paused": false,
|
| 215 |
+
"params": {
|
| 216 |
+
"frame_load_cap": 64,
|
| 217 |
+
"skip_first_frames": 0,
|
| 218 |
+
"force_rate": 0,
|
| 219 |
+
"filename": "input/leader.webm",
|
| 220 |
+
"type": "path",
|
| 221 |
+
"format": "video/webm",
|
| 222 |
+
"select_every_nth": 1
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
},
|
| 227 |
+
{
|
| 228 |
+
"id": 20,
|
| 229 |
+
"type": "PrimitiveNode",
|
| 230 |
+
"pos": [
|
| 231 |
+
-240,
|
| 232 |
+
170
|
| 233 |
+
],
|
| 234 |
+
"size": {
|
| 235 |
+
"0": 210,
|
| 236 |
+
"1": 80
|
| 237 |
+
},
|
| 238 |
+
"flags": {},
|
| 239 |
+
"order": 0,
|
| 240 |
+
"mode": 0,
|
| 241 |
+
"outputs": [
|
| 242 |
+
{
|
| 243 |
+
"name": "INT",
|
| 244 |
+
"type": "INT",
|
| 245 |
+
"links": [
|
| 246 |
+
23
|
| 247 |
+
],
|
| 248 |
+
"widget": {
|
| 249 |
+
"name": "frame_load_cap"
|
| 250 |
+
}
|
| 251 |
+
}
|
| 252 |
+
],
|
| 253 |
+
"properties": {
|
| 254 |
+
"Run widget replace on values": false
|
| 255 |
+
},
|
| 256 |
+
"widgets_values": [
|
| 257 |
+
64,
|
| 258 |
+
"fixed"
|
| 259 |
+
]
|
| 260 |
+
}
|
| 261 |
+
],
|
| 262 |
+
"links": [
|
| 263 |
+
[
|
| 264 |
+
19,
|
| 265 |
+
16,
|
| 266 |
+
3,
|
| 267 |
+
18,
|
| 268 |
+
0,
|
| 269 |
+
"VHS_VIDEOINFO"
|
| 270 |
+
],
|
| 271 |
+
[
|
| 272 |
+
20,
|
| 273 |
+
18,
|
| 274 |
+
0,
|
| 275 |
+
17,
|
| 276 |
+
3,
|
| 277 |
+
"FLOAT"
|
| 278 |
+
],
|
| 279 |
+
[
|
| 280 |
+
21,
|
| 281 |
+
16,
|
| 282 |
+
0,
|
| 283 |
+
17,
|
| 284 |
+
0,
|
| 285 |
+
"IMAGE"
|
| 286 |
+
],
|
| 287 |
+
[
|
| 288 |
+
23,
|
| 289 |
+
20,
|
| 290 |
+
0,
|
| 291 |
+
16,
|
| 292 |
+
1,
|
| 293 |
+
"INT"
|
| 294 |
+
]
|
| 295 |
+
],
|
| 296 |
+
"groups": [],
|
| 297 |
+
"config": {},
|
| 298 |
+
"extra": {},
|
| 299 |
+
"version": 0.4,
|
| 300 |
+
"tests": {
|
| 301 |
+
"17": [{"type": "video", "key": "width", "value": 1440},
|
| 302 |
+
{"type": "video", "key": "height", "value": 1080},
|
| 303 |
+
{"type": "video", "key": "nb_read_packets", "value": "64"}
|
| 304 |
+
],
|
| 305 |
+
"length": 1
|
| 306 |
+
}
|
| 307 |
+
}
|
tests/loop.json
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
"nodes": [
|
| 5 |
+
{
|
| 6 |
+
"id": 1,
|
| 7 |
+
"type": "VHS_LoadVideo",
|
| 8 |
+
"pos": {
|
| 9 |
+
"0": 54,
|
| 10 |
+
"1": 89
|
| 11 |
+
},
|
| 12 |
+
"size": [
|
| 13 |
+
260,
|
| 14 |
+
460
|
| 15 |
+
],
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 0,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"inputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "meta_batch",
|
| 22 |
+
"type": "VHS_BatchManager",
|
| 23 |
+
"link": null
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"name": "vae",
|
| 27 |
+
"type": "VAE",
|
| 28 |
+
"link": null
|
| 29 |
+
}
|
| 30 |
+
],
|
| 31 |
+
"outputs": [
|
| 32 |
+
{
|
| 33 |
+
"name": "IMAGE",
|
| 34 |
+
"type": "IMAGE",
|
| 35 |
+
"links": [
|
| 36 |
+
1
|
| 37 |
+
],
|
| 38 |
+
"slot_index": 0,
|
| 39 |
+
"shape": 3
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"name": "frame_count",
|
| 43 |
+
"type": "INT",
|
| 44 |
+
"links": null,
|
| 45 |
+
"shape": 3
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"name": "audio",
|
| 49 |
+
"type": "VHS_AUDIO",
|
| 50 |
+
"links": null,
|
| 51 |
+
"shape": 3
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"name": "video_info",
|
| 55 |
+
"type": "VHS_VIDEOINFO",
|
| 56 |
+
"links": null,
|
| 57 |
+
"shape": 3
|
| 58 |
+
}
|
| 59 |
+
],
|
| 60 |
+
"properties": {
|
| 61 |
+
"Node name for S&R": "VHS_LoadVideo"
|
| 62 |
+
},
|
| 63 |
+
"widgets_values": {
|
| 64 |
+
"video": "leader.webm",
|
| 65 |
+
"force_rate": 8,
|
| 66 |
+
"force_size": "Disabled",
|
| 67 |
+
"custom_width": 304,
|
| 68 |
+
"custom_height": 312,
|
| 69 |
+
"frame_load_cap": 16,
|
| 70 |
+
"skip_first_frames": 1,
|
| 71 |
+
"select_every_nth": 1,
|
| 72 |
+
"choose video to upload": "image",
|
| 73 |
+
"videopreview": {
|
| 74 |
+
"hidden": false,
|
| 75 |
+
"paused": false,
|
| 76 |
+
"params": {
|
| 77 |
+
"frame_load_cap": 16,
|
| 78 |
+
"skip_first_frames": 1,
|
| 79 |
+
"force_rate": 8,
|
| 80 |
+
"filename": "leader.webm",
|
| 81 |
+
"type": "input",
|
| 82 |
+
"format": "video/mp4",
|
| 83 |
+
"force_size": "410.4x?",
|
| 84 |
+
"select_every_nth": 1
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"id": 3,
|
| 91 |
+
"type": "VHS_VideoCombine",
|
| 92 |
+
"pos": {
|
| 93 |
+
"0": 629,
|
| 94 |
+
"1": 222
|
| 95 |
+
},
|
| 96 |
+
"size": [
|
| 97 |
+
320,
|
| 98 |
+
550
|
| 99 |
+
],
|
| 100 |
+
"flags": {},
|
| 101 |
+
"order": 1,
|
| 102 |
+
"mode": 0,
|
| 103 |
+
"inputs": [
|
| 104 |
+
{
|
| 105 |
+
"name": "images",
|
| 106 |
+
"type": "IMAGE",
|
| 107 |
+
"link": 1
|
| 108 |
+
},
|
| 109 |
+
{
|
| 110 |
+
"name": "audio",
|
| 111 |
+
"type": "AUDIO",
|
| 112 |
+
"link": null
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"name": "meta_batch",
|
| 116 |
+
"type": "VHS_BatchManager",
|
| 117 |
+
"link": null
|
| 118 |
+
},
|
| 119 |
+
{
|
| 120 |
+
"name": "vae",
|
| 121 |
+
"type": "VAE",
|
| 122 |
+
"link": null
|
| 123 |
+
}
|
| 124 |
+
],
|
| 125 |
+
"outputs": [
|
| 126 |
+
{
|
| 127 |
+
"name": "Filenames",
|
| 128 |
+
"type": "VHS_FILENAMES",
|
| 129 |
+
"links": null,
|
| 130 |
+
"shape": 3
|
| 131 |
+
}
|
| 132 |
+
],
|
| 133 |
+
"properties": {
|
| 134 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 135 |
+
},
|
| 136 |
+
"widgets_values": {
|
| 137 |
+
"frame_rate": 8,
|
| 138 |
+
"loop_count": 1,
|
| 139 |
+
"filename_prefix": "AnimateDiff",
|
| 140 |
+
"format": "video/h264-mp4",
|
| 141 |
+
"pix_fmt": "yuv420p",
|
| 142 |
+
"crf": 19,
|
| 143 |
+
"save_metadata": true,
|
| 144 |
+
"pingpong": false,
|
| 145 |
+
"save_output": false,
|
| 146 |
+
"videopreview": {
|
| 147 |
+
"hidden": false,
|
| 148 |
+
"paused": false,
|
| 149 |
+
"params": {
|
| 150 |
+
"filename": "AnimateDiff_00005.mp4",
|
| 151 |
+
"subfolder": "",
|
| 152 |
+
"type": "temp",
|
| 153 |
+
"format": "video/h264-mp4",
|
| 154 |
+
"frame_rate": 8
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
],
|
| 160 |
+
"links": [
|
| 161 |
+
[
|
| 162 |
+
1,
|
| 163 |
+
1,
|
| 164 |
+
0,
|
| 165 |
+
3,
|
| 166 |
+
0,
|
| 167 |
+
"IMAGE"
|
| 168 |
+
]
|
| 169 |
+
],
|
| 170 |
+
"groups": [],
|
| 171 |
+
"config": {},
|
| 172 |
+
"extra": {},
|
| 173 |
+
"version": 0.4,
|
| 174 |
+
"tests": {
|
| 175 |
+
"3": [{"type": "video", "key": "nb_read_packets", "value": "32"}],
|
| 176 |
+
"length": 1
|
| 177 |
+
}
|
| 178 |
+
}
|
tests/old-prores.json
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "bc7448ba-118f-4226-95ab-32227992f954",
|
| 3 |
+
"revision": 0,
|
| 4 |
+
"last_node_id": 6,
|
| 5 |
+
"last_link_id": 4,
|
| 6 |
+
"nodes": [
|
| 7 |
+
{
|
| 8 |
+
"id": 1,
|
| 9 |
+
"type": "VHS_LoadVideo",
|
| 10 |
+
"pos": [
|
| 11 |
+
54,
|
| 12 |
+
89
|
| 13 |
+
],
|
| 14 |
+
"size": [
|
| 15 |
+
245.1999969482422,
|
| 16 |
+
492.7751770019531
|
| 17 |
+
],
|
| 18 |
+
"flags": {},
|
| 19 |
+
"order": 0,
|
| 20 |
+
"mode": 0,
|
| 21 |
+
"inputs": [
|
| 22 |
+
{
|
| 23 |
+
"name": "meta_batch",
|
| 24 |
+
"shape": 7,
|
| 25 |
+
"type": "VHS_BatchManager",
|
| 26 |
+
"link": null
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"name": "vae",
|
| 30 |
+
"shape": 7,
|
| 31 |
+
"type": "VAE",
|
| 32 |
+
"link": null
|
| 33 |
+
}
|
| 34 |
+
],
|
| 35 |
+
"outputs": [
|
| 36 |
+
{
|
| 37 |
+
"name": "IMAGE",
|
| 38 |
+
"type": "IMAGE",
|
| 39 |
+
"slot_index": 0,
|
| 40 |
+
"links": [
|
| 41 |
+
1,
|
| 42 |
+
2,
|
| 43 |
+
3,
|
| 44 |
+
4
|
| 45 |
+
]
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"name": "frame_count",
|
| 49 |
+
"type": "INT",
|
| 50 |
+
"links": null
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"name": "audio",
|
| 54 |
+
"type": "AUDIO",
|
| 55 |
+
"links": null
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"name": "video_info",
|
| 59 |
+
"type": "VHS_VIDEOINFO",
|
| 60 |
+
"links": null
|
| 61 |
+
}
|
| 62 |
+
],
|
| 63 |
+
"properties": {
|
| 64 |
+
"Node name for S&R": "VHS_LoadVideo"
|
| 65 |
+
},
|
| 66 |
+
"widgets_values": {
|
| 67 |
+
"video": "leader.webm",
|
| 68 |
+
"force_rate": 8,
|
| 69 |
+
"custom_width": 512,
|
| 70 |
+
"custom_height": 0,
|
| 71 |
+
"frame_load_cap": 64,
|
| 72 |
+
"skip_first_frames": 1,
|
| 73 |
+
"select_every_nth": 1,
|
| 74 |
+
"format": "AnimateDiff",
|
| 75 |
+
"choose video to upload": "image",
|
| 76 |
+
"videopreview": {
|
| 77 |
+
"hidden": false,
|
| 78 |
+
"paused": false,
|
| 79 |
+
"params": {
|
| 80 |
+
"frame_load_cap": 64,
|
| 81 |
+
"skip_first_frames": 0,
|
| 82 |
+
"force_rate": 8,
|
| 83 |
+
"filename": "leader.webm",
|
| 84 |
+
"type": "input",
|
| 85 |
+
"format": "video/mp4",
|
| 86 |
+
"select_every_nth": 1
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"id": 4,
|
| 93 |
+
"type": "VHS_VideoCombine",
|
| 94 |
+
"pos": [
|
| 95 |
+
630.9500122070312,
|
| 96 |
+
136.90997314453125
|
| 97 |
+
],
|
| 98 |
+
"size": [
|
| 99 |
+
315,
|
| 100 |
+
497.25
|
| 101 |
+
],
|
| 102 |
+
"flags": {},
|
| 103 |
+
"order": 2,
|
| 104 |
+
"mode": 0,
|
| 105 |
+
"inputs": [
|
| 106 |
+
{
|
| 107 |
+
"name": "images",
|
| 108 |
+
"type": "IMAGE",
|
| 109 |
+
"link": 2
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"name": "audio",
|
| 113 |
+
"shape": 7,
|
| 114 |
+
"type": "AUDIO",
|
| 115 |
+
"link": null
|
| 116 |
+
},
|
| 117 |
+
{
|
| 118 |
+
"name": "meta_batch",
|
| 119 |
+
"shape": 7,
|
| 120 |
+
"type": "VHS_BatchManager",
|
| 121 |
+
"link": null
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"name": "vae",
|
| 125 |
+
"shape": 7,
|
| 126 |
+
"type": "VAE",
|
| 127 |
+
"link": null
|
| 128 |
+
}
|
| 129 |
+
],
|
| 130 |
+
"outputs": [
|
| 131 |
+
{
|
| 132 |
+
"name": "Filenames",
|
| 133 |
+
"type": "VHS_FILENAMES",
|
| 134 |
+
"links": null
|
| 135 |
+
}
|
| 136 |
+
],
|
| 137 |
+
"properties": {
|
| 138 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 139 |
+
},
|
| 140 |
+
"widgets_values": {
|
| 141 |
+
"frame_rate": 8,
|
| 142 |
+
"loop_count": 0,
|
| 143 |
+
"filename_prefix": "AnimateDiff",
|
| 144 |
+
"format": "video/ProRes",
|
| 145 |
+
"profile": "2",
|
| 146 |
+
"pingpong": false,
|
| 147 |
+
"save_output": false,
|
| 148 |
+
"videopreview": {
|
| 149 |
+
"hidden": false,
|
| 150 |
+
"paused": false,
|
| 151 |
+
"params": {
|
| 152 |
+
"filename": "AnimateDiff_00004.mov",
|
| 153 |
+
"subfolder": "",
|
| 154 |
+
"type": "temp",
|
| 155 |
+
"format": "video/ProRes",
|
| 156 |
+
"frame_rate": 8,
|
| 157 |
+
"workflow": "AnimateDiff_00004.png"
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
},
|
| 162 |
+
{
|
| 163 |
+
"id": 3,
|
| 164 |
+
"type": "VHS_VideoCombine",
|
| 165 |
+
"pos": [
|
| 166 |
+
635.0499267578125,
|
| 167 |
+
-407.1000061035156
|
| 168 |
+
],
|
| 169 |
+
"size": [
|
| 170 |
+
315,
|
| 171 |
+
497.25
|
| 172 |
+
],
|
| 173 |
+
"flags": {},
|
| 174 |
+
"order": 1,
|
| 175 |
+
"mode": 0,
|
| 176 |
+
"inputs": [
|
| 177 |
+
{
|
| 178 |
+
"name": "images",
|
| 179 |
+
"type": "IMAGE",
|
| 180 |
+
"link": 1
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"name": "audio",
|
| 184 |
+
"shape": 7,
|
| 185 |
+
"type": "AUDIO",
|
| 186 |
+
"link": null
|
| 187 |
+
},
|
| 188 |
+
{
|
| 189 |
+
"name": "meta_batch",
|
| 190 |
+
"shape": 7,
|
| 191 |
+
"type": "VHS_BatchManager",
|
| 192 |
+
"link": null
|
| 193 |
+
},
|
| 194 |
+
{
|
| 195 |
+
"name": "vae",
|
| 196 |
+
"shape": 7,
|
| 197 |
+
"type": "VAE",
|
| 198 |
+
"link": null
|
| 199 |
+
}
|
| 200 |
+
],
|
| 201 |
+
"outputs": [
|
| 202 |
+
{
|
| 203 |
+
"name": "Filenames",
|
| 204 |
+
"type": "VHS_FILENAMES",
|
| 205 |
+
"links": null
|
| 206 |
+
}
|
| 207 |
+
],
|
| 208 |
+
"properties": {
|
| 209 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 210 |
+
},
|
| 211 |
+
"widgets_values": {
|
| 212 |
+
"frame_rate": 8,
|
| 213 |
+
"loop_count": 0,
|
| 214 |
+
"filename_prefix": "AnimateDiff",
|
| 215 |
+
"format": "video/ProRes",
|
| 216 |
+
"profile": "1",
|
| 217 |
+
"pingpong": false,
|
| 218 |
+
"save_output": false,
|
| 219 |
+
"videopreview": {
|
| 220 |
+
"hidden": false,
|
| 221 |
+
"paused": false,
|
| 222 |
+
"params": {
|
| 223 |
+
"filename": "AnimateDiff_00001.mov",
|
| 224 |
+
"subfolder": "",
|
| 225 |
+
"type": "temp",
|
| 226 |
+
"format": "video/ProRes",
|
| 227 |
+
"frame_rate": 8,
|
| 228 |
+
"workflow": "AnimateDiff_00001.png"
|
| 229 |
+
}
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
},
|
| 233 |
+
{
|
| 234 |
+
"id": 5,
|
| 235 |
+
"type": "VHS_VideoCombine",
|
| 236 |
+
"pos": [
|
| 237 |
+
974.6401977539062,
|
| 238 |
+
-409.33984375
|
| 239 |
+
],
|
| 240 |
+
"size": [
|
| 241 |
+
315,
|
| 242 |
+
497.25
|
| 243 |
+
],
|
| 244 |
+
"flags": {},
|
| 245 |
+
"order": 3,
|
| 246 |
+
"mode": 0,
|
| 247 |
+
"inputs": [
|
| 248 |
+
{
|
| 249 |
+
"name": "images",
|
| 250 |
+
"type": "IMAGE",
|
| 251 |
+
"link": 3
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"name": "audio",
|
| 255 |
+
"shape": 7,
|
| 256 |
+
"type": "AUDIO",
|
| 257 |
+
"link": null
|
| 258 |
+
},
|
| 259 |
+
{
|
| 260 |
+
"name": "meta_batch",
|
| 261 |
+
"shape": 7,
|
| 262 |
+
"type": "VHS_BatchManager",
|
| 263 |
+
"link": null
|
| 264 |
+
},
|
| 265 |
+
{
|
| 266 |
+
"name": "vae",
|
| 267 |
+
"shape": 7,
|
| 268 |
+
"type": "VAE",
|
| 269 |
+
"link": null
|
| 270 |
+
}
|
| 271 |
+
],
|
| 272 |
+
"outputs": [
|
| 273 |
+
{
|
| 274 |
+
"name": "Filenames",
|
| 275 |
+
"type": "VHS_FILENAMES",
|
| 276 |
+
"links": null
|
| 277 |
+
}
|
| 278 |
+
],
|
| 279 |
+
"properties": {
|
| 280 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 281 |
+
},
|
| 282 |
+
"widgets_values": {
|
| 283 |
+
"frame_rate": 8,
|
| 284 |
+
"loop_count": 0,
|
| 285 |
+
"filename_prefix": "AnimateDiff",
|
| 286 |
+
"format": "video/ProRes",
|
| 287 |
+
"profile": "3",
|
| 288 |
+
"pingpong": false,
|
| 289 |
+
"save_output": false,
|
| 290 |
+
"videopreview": {
|
| 291 |
+
"hidden": false,
|
| 292 |
+
"paused": false,
|
| 293 |
+
"params": {
|
| 294 |
+
"filename": "AnimateDiff_00002.mov",
|
| 295 |
+
"subfolder": "",
|
| 296 |
+
"type": "temp",
|
| 297 |
+
"format": "video/ProRes",
|
| 298 |
+
"frame_rate": 8,
|
| 299 |
+
"workflow": "AnimateDiff_00002.png"
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
},
|
| 304 |
+
{
|
| 305 |
+
"id": 6,
|
| 306 |
+
"type": "VHS_VideoCombine",
|
| 307 |
+
"pos": [
|
| 308 |
+
968.7000122070312,
|
| 309 |
+
138.7698974609375
|
| 310 |
+
],
|
| 311 |
+
"size": [
|
| 312 |
+
315,
|
| 313 |
+
497.25
|
| 314 |
+
],
|
| 315 |
+
"flags": {},
|
| 316 |
+
"order": 4,
|
| 317 |
+
"mode": 0,
|
| 318 |
+
"inputs": [
|
| 319 |
+
{
|
| 320 |
+
"name": "images",
|
| 321 |
+
"type": "IMAGE",
|
| 322 |
+
"link": 4
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"name": "audio",
|
| 326 |
+
"shape": 7,
|
| 327 |
+
"type": "AUDIO",
|
| 328 |
+
"link": null
|
| 329 |
+
},
|
| 330 |
+
{
|
| 331 |
+
"name": "meta_batch",
|
| 332 |
+
"shape": 7,
|
| 333 |
+
"type": "VHS_BatchManager",
|
| 334 |
+
"link": null
|
| 335 |
+
},
|
| 336 |
+
{
|
| 337 |
+
"name": "vae",
|
| 338 |
+
"shape": 7,
|
| 339 |
+
"type": "VAE",
|
| 340 |
+
"link": null
|
| 341 |
+
}
|
| 342 |
+
],
|
| 343 |
+
"outputs": [
|
| 344 |
+
{
|
| 345 |
+
"name": "Filenames",
|
| 346 |
+
"type": "VHS_FILENAMES",
|
| 347 |
+
"links": null
|
| 348 |
+
}
|
| 349 |
+
],
|
| 350 |
+
"properties": {
|
| 351 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 352 |
+
},
|
| 353 |
+
"widgets_values": {
|
| 354 |
+
"frame_rate": 8,
|
| 355 |
+
"loop_count": 0,
|
| 356 |
+
"filename_prefix": "AnimateDiff",
|
| 357 |
+
"format": "video/ProRes",
|
| 358 |
+
"profile": "4",
|
| 359 |
+
"pingpong": false,
|
| 360 |
+
"save_output": false,
|
| 361 |
+
"videopreview": {
|
| 362 |
+
"hidden": false,
|
| 363 |
+
"paused": false,
|
| 364 |
+
"params": {
|
| 365 |
+
"filename": "AnimateDiff_00003.mov",
|
| 366 |
+
"subfolder": "",
|
| 367 |
+
"type": "temp",
|
| 368 |
+
"format": "video/ProRes",
|
| 369 |
+
"frame_rate": 8
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
+
}
|
| 373 |
+
}
|
| 374 |
+
],
|
| 375 |
+
"links": [
|
| 376 |
+
[
|
| 377 |
+
1,
|
| 378 |
+
1,
|
| 379 |
+
0,
|
| 380 |
+
3,
|
| 381 |
+
0,
|
| 382 |
+
"IMAGE"
|
| 383 |
+
],
|
| 384 |
+
[
|
| 385 |
+
2,
|
| 386 |
+
1,
|
| 387 |
+
0,
|
| 388 |
+
4,
|
| 389 |
+
0,
|
| 390 |
+
"IMAGE"
|
| 391 |
+
],
|
| 392 |
+
[
|
| 393 |
+
3,
|
| 394 |
+
1,
|
| 395 |
+
0,
|
| 396 |
+
5,
|
| 397 |
+
0,
|
| 398 |
+
"IMAGE"
|
| 399 |
+
],
|
| 400 |
+
[
|
| 401 |
+
4,
|
| 402 |
+
1,
|
| 403 |
+
0,
|
| 404 |
+
6,
|
| 405 |
+
0,
|
| 406 |
+
"IMAGE"
|
| 407 |
+
]
|
| 408 |
+
],
|
| 409 |
+
"groups": [],
|
| 410 |
+
"config": {},
|
| 411 |
+
"extra": {
|
| 412 |
+
"frontendVersion": "1.17.0",
|
| 413 |
+
"VHS_latentpreview": true,
|
| 414 |
+
"VHS_latentpreviewrate": 0,
|
| 415 |
+
"VHS_MetadataImage": true,
|
| 416 |
+
"VHS_KeepIntermediate": true
|
| 417 |
+
},
|
| 418 |
+
"version": 0.4,
|
| 419 |
+
"tests": {
|
| 420 |
+
"6": [{"type": "video", "key": "pix_fmt", "value": "yuv444p12le"}],
|
| 421 |
+
"length": 1
|
| 422 |
+
}
|
| 423 |
+
}
|
tests/old-vae-conversion.json
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
+
320,
|
| 14 |
+
468.7188019966722
|
| 15 |
+
],
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 2,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"inputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "images",
|
| 22 |
+
"type": "LATENT",
|
| 23 |
+
"link": 9
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"name": "audio",
|
| 27 |
+
"type": "AUDIO",
|
| 28 |
+
"link": null
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"name": "meta_batch",
|
| 32 |
+
"type": "VHS_BatchManager",
|
| 33 |
+
"link": null
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"name": "vae",
|
| 37 |
+
"type": "VAE",
|
| 38 |
+
"link": 8
|
| 39 |
+
}
|
| 40 |
+
],
|
| 41 |
+
"outputs": [
|
| 42 |
+
{
|
| 43 |
+
"name": "Filenames",
|
| 44 |
+
"type": "VHS_FILENAMES",
|
| 45 |
+
"links": null,
|
| 46 |
+
"shape": 3
|
| 47 |
+
}
|
| 48 |
+
],
|
| 49 |
+
"properties": {
|
| 50 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 51 |
+
},
|
| 52 |
+
"widgets_values": {
|
| 53 |
+
"frame_rate": 8,
|
| 54 |
+
"loop_count": 0,
|
| 55 |
+
"filename_prefix": "AnimateDiff",
|
| 56 |
+
"format": "video/webm",
|
| 57 |
+
"crf": 20,
|
| 58 |
+
"save_metadata": true,
|
| 59 |
+
"pingpong": false,
|
| 60 |
+
"save_output": false,
|
| 61 |
+
"videopreview": {
|
| 62 |
+
"hidden": false,
|
| 63 |
+
"paused": false,
|
| 64 |
+
"params": {
|
| 65 |
+
"filename": "AnimateDiff_00001.webm",
|
| 66 |
+
"subfolder": "",
|
| 67 |
+
"type": "temp",
|
| 68 |
+
"format": "video/webm",
|
| 69 |
+
"frame_rate": 8
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"id": 6,
|
| 76 |
+
"type": "VHS_LoadVideoPath",
|
| 77 |
+
"pos": [
|
| 78 |
+
171,
|
| 79 |
+
239
|
| 80 |
+
],
|
| 81 |
+
"size": [
|
| 82 |
+
320,
|
| 83 |
+
420.7188019966722
|
| 84 |
+
],
|
| 85 |
+
"flags": {},
|
| 86 |
+
"order": 1,
|
| 87 |
+
"mode": 0,
|
| 88 |
+
"inputs": [
|
| 89 |
+
{
|
| 90 |
+
"name": "meta_batch",
|
| 91 |
+
"type": "VHS_BatchManager",
|
| 92 |
+
"link": null
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"name": "vae",
|
| 96 |
+
"type": "VAE",
|
| 97 |
+
"link": 7,
|
| 98 |
+
"slot_index": 1
|
| 99 |
+
}
|
| 100 |
+
],
|
| 101 |
+
"outputs": [
|
| 102 |
+
{
|
| 103 |
+
"name": "LATENT",
|
| 104 |
+
"type": "LATENT",
|
| 105 |
+
"links": [
|
| 106 |
+
9
|
| 107 |
+
],
|
| 108 |
+
"slot_index": 0,
|
| 109 |
+
"shape": 3
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"name": "frame_count",
|
| 113 |
+
"type": "INT",
|
| 114 |
+
"links": null,
|
| 115 |
+
"shape": 3
|
| 116 |
+
},
|
| 117 |
+
{
|
| 118 |
+
"name": "audio",
|
| 119 |
+
"type": "AUDIO",
|
| 120 |
+
"links": [],
|
| 121 |
+
"slot_index": 2,
|
| 122 |
+
"shape": 3
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"name": "video_info",
|
| 126 |
+
"type": "VHS_VIDEOINFO",
|
| 127 |
+
"links": null,
|
| 128 |
+
"shape": 3
|
| 129 |
+
}
|
| 130 |
+
],
|
| 131 |
+
"properties": {
|
| 132 |
+
"Node name for S&R": "VHS_LoadVideoPath"
|
| 133 |
+
},
|
| 134 |
+
"widgets_values": {
|
| 135 |
+
"video": "input/bigbuckbunny.mp4",
|
| 136 |
+
"force_rate": 8,
|
| 137 |
+
"force_size": "Disabled",
|
| 138 |
+
"custom_width": 512,
|
| 139 |
+
"custom_height": 512,
|
| 140 |
+
"frame_load_cap": 64,
|
| 141 |
+
"skip_first_frames": 0,
|
| 142 |
+
"select_every_nth": 1,
|
| 143 |
+
"videopreview": {
|
| 144 |
+
"hidden": false,
|
| 145 |
+
"paused": false,
|
| 146 |
+
"params": {
|
| 147 |
+
"frame_load_cap": 64,
|
| 148 |
+
"skip_first_frames": 0,
|
| 149 |
+
"force_rate": 8,
|
| 150 |
+
"filename": "input/bigbuckbunny.mp4",
|
| 151 |
+
"type": "path",
|
| 152 |
+
"format": "video/mp4",
|
| 153 |
+
"select_every_nth": 1
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
"id": 10,
|
| 160 |
+
"type": "VAELoader",
|
| 161 |
+
"pos": [
|
| 162 |
+
-42,
|
| 163 |
+
88
|
| 164 |
+
],
|
| 165 |
+
"size": {
|
| 166 |
+
"0": 315,
|
| 167 |
+
"1": 58
|
| 168 |
+
},
|
| 169 |
+
"flags": {},
|
| 170 |
+
"order": 0,
|
| 171 |
+
"mode": 0,
|
| 172 |
+
"outputs": [
|
| 173 |
+
{
|
| 174 |
+
"name": "VAE",
|
| 175 |
+
"type": "VAE",
|
| 176 |
+
"links": [
|
| 177 |
+
7,
|
| 178 |
+
8
|
| 179 |
+
],
|
| 180 |
+
"shape": 3,
|
| 181 |
+
"slot_index": 0
|
| 182 |
+
}
|
| 183 |
+
],
|
| 184 |
+
"properties": {
|
| 185 |
+
"Node name for S&R": "VAELoader"
|
| 186 |
+
},
|
| 187 |
+
"widgets_values": [
|
| 188 |
+
"taesd"
|
| 189 |
+
]
|
| 190 |
+
}
|
| 191 |
+
],
|
| 192 |
+
"links": [
|
| 193 |
+
[
|
| 194 |
+
7,
|
| 195 |
+
10,
|
| 196 |
+
0,
|
| 197 |
+
6,
|
| 198 |
+
1,
|
| 199 |
+
"VAE"
|
| 200 |
+
],
|
| 201 |
+
[
|
| 202 |
+
8,
|
| 203 |
+
10,
|
| 204 |
+
0,
|
| 205 |
+
7,
|
| 206 |
+
3,
|
| 207 |
+
"VAE"
|
| 208 |
+
],
|
| 209 |
+
[
|
| 210 |
+
9,
|
| 211 |
+
6,
|
| 212 |
+
0,
|
| 213 |
+
7,
|
| 214 |
+
0,
|
| 215 |
+
"LATENT"
|
| 216 |
+
]
|
| 217 |
+
],
|
| 218 |
+
"groups": [],
|
| 219 |
+
"config": {},
|
| 220 |
+
"extra": {},
|
| 221 |
+
"version": 0.4,
|
| 222 |
+
"tests": {
|
| 223 |
+
"7": [{"type": "video", "key": "width", "value": 1920},
|
| 224 |
+
{"type": "video", "key": "height", "value": 1080},
|
| 225 |
+
{"type": "video", "key": "nb_read_packets", "value": "64"}
|
| 226 |
+
],
|
| 227 |
+
"length": 1
|
| 228 |
+
}
|
| 229 |
+
}
|
tests/simple.json
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"last_node_id": 3,
|
| 3 |
+
"last_link_id": 1,
|
| 4 |
+
"nodes": [
|
| 5 |
+
{
|
| 6 |
+
"id": 1,
|
| 7 |
+
"type": "VHS_LoadVideo",
|
| 8 |
+
"pos": [
|
| 9 |
+
54,
|
| 10 |
+
89
|
| 11 |
+
],
|
| 12 |
+
"size": [
|
| 13 |
+
235.1999969482422,
|
| 14 |
+
384.56999829610186
|
| 15 |
+
],
|
| 16 |
+
"flags": {},
|
| 17 |
+
"order": 0,
|
| 18 |
+
"mode": 0,
|
| 19 |
+
"outputs": [
|
| 20 |
+
{
|
| 21 |
+
"name": "IMAGE",
|
| 22 |
+
"type": "IMAGE",
|
| 23 |
+
"links": [
|
| 24 |
+
1
|
| 25 |
+
],
|
| 26 |
+
"shape": 3,
|
| 27 |
+
"slot_index": 0
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"name": "frame_count",
|
| 31 |
+
"type": "INT",
|
| 32 |
+
"links": null,
|
| 33 |
+
"shape": 3
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"name": "audio",
|
| 37 |
+
"type": "VHS_AUDIO",
|
| 38 |
+
"links": null,
|
| 39 |
+
"shape": 3
|
| 40 |
+
}
|
| 41 |
+
],
|
| 42 |
+
"properties": {
|
| 43 |
+
"Node name for S&R": "VHS_LoadVideo"
|
| 44 |
+
},
|
| 45 |
+
"widgets_values": {
|
| 46 |
+
"video": "leader.webm",
|
| 47 |
+
"force_rate": 8,
|
| 48 |
+
"force_size": "Custom Width",
|
| 49 |
+
"custom_width": 304,
|
| 50 |
+
"custom_height": 312,
|
| 51 |
+
"frame_load_cap": 16,
|
| 52 |
+
"skip_first_frames": 1,
|
| 53 |
+
"select_every_nth": 1,
|
| 54 |
+
"choose video to upload": "image",
|
| 55 |
+
"videopreview": {
|
| 56 |
+
"hidden": false,
|
| 57 |
+
"paused": false,
|
| 58 |
+
"params": {
|
| 59 |
+
"frame_load_cap": 0,
|
| 60 |
+
"skip_first_frames": 0,
|
| 61 |
+
"force_rate": 0,
|
| 62 |
+
"filename": "leader.webm",
|
| 63 |
+
"type": "input",
|
| 64 |
+
"format": "video/mp4",
|
| 65 |
+
"force_size": "410.4x?",
|
| 66 |
+
"select_every_nth": 1
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"id": 3,
|
| 73 |
+
"type": "VHS_VideoCombine",
|
| 74 |
+
"pos": [
|
| 75 |
+
629,
|
| 76 |
+
222
|
| 77 |
+
],
|
| 78 |
+
"size": {
|
| 79 |
+
"0": 315,
|
| 80 |
+
"1": 250
|
| 81 |
+
},
|
| 82 |
+
"flags": {},
|
| 83 |
+
"order": 1,
|
| 84 |
+
"mode": 0,
|
| 85 |
+
"inputs": [
|
| 86 |
+
{
|
| 87 |
+
"name": "images",
|
| 88 |
+
"type": "IMAGE",
|
| 89 |
+
"link": 1
|
| 90 |
+
}
|
| 91 |
+
],
|
| 92 |
+
"outputs": [],
|
| 93 |
+
"properties": {
|
| 94 |
+
"Node name for S&R": "VHS_VideoCombine"
|
| 95 |
+
},
|
| 96 |
+
"widgets_values": {
|
| 97 |
+
"frame_rate": 8,
|
| 98 |
+
"loop_count": 0,
|
| 99 |
+
"filename_prefix": "AnimateDiff",
|
| 100 |
+
"format": "video/webm",
|
| 101 |
+
"pingpong": false,
|
| 102 |
+
"save_image": false,
|
| 103 |
+
"crf": 20,
|
| 104 |
+
"save_metadata": false,
|
| 105 |
+
"audio_file": "",
|
| 106 |
+
"videopreview": {
|
| 107 |
+
"hidden": false,
|
| 108 |
+
"paused": false
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
],
|
| 113 |
+
"links": [
|
| 114 |
+
[
|
| 115 |
+
1,
|
| 116 |
+
1,
|
| 117 |
+
0,
|
| 118 |
+
3,
|
| 119 |
+
0,
|
| 120 |
+
"IMAGE"
|
| 121 |
+
]
|
| 122 |
+
],
|
| 123 |
+
"groups": [],
|
| 124 |
+
"config": {},
|
| 125 |
+
"extra": {},
|
| 126 |
+
"version": 0.4,
|
| 127 |
+
"tests": {
|
| 128 |
+
"3": [{"type": "video", "key": "width", "value": 304},
|
| 129 |
+
{"type": "video", "key": "height", "value": 232},
|
| 130 |
+
{"type": "compare", "filename": "custom_nodes/ComfyUI-VideoHelperSuite/tests/outputs/simple.webm", "tolerance": 0.02}
|
| 131 |
+
],
|
| 132 |
+
"length": 1
|
| 133 |
+
}
|
| 134 |
+
}
|
video_formats/16bit-png.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-n",
|
| 5 |
+
"-pix_fmt", "rgba64"
|
| 6 |
+
],
|
| 7 |
+
"input_color_depth": "16bit",
|
| 8 |
+
"extension": "%03d.png"
|
| 9 |
+
}
|
video_formats/8bit-png.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-n"
|
| 5 |
+
],
|
| 6 |
+
"extension": "%03d.png"
|
| 7 |
+
}
|
video_formats/ProRes.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-n", "-c:v", "prores_ks",
|
| 5 |
+
"-profile:v", [["$profile"]],
|
| 6 |
+
["profile", {
|
| 7 |
+
"lt": [[]], "1": [[]], "standard": [[]], "2": [[]], "hq": [[]], "3": [[]],
|
| 8 |
+
"4": ["has_alpha", {"True": [["-pix_fmt", "yuva444p10le"]],
|
| 9 |
+
"False": [["-pix_fmt", "yuv444p10le"]]}],
|
| 10 |
+
"4444": ["has_alpha", {"True": [["-pix_fmt", "yuva444p10le"]],
|
| 11 |
+
"False": [["-pix_fmt", "yuv444p10le"]]}],
|
| 12 |
+
"4444xq": ["has_alpha", {"True": [["-pix_fmt", "yuva444p10le"]],
|
| 13 |
+
"False": [["-pix_fmt", "yuv444p10le"]]}]
|
| 14 |
+
}],
|
| 15 |
+
"-vf", "scale=out_color_matrix=bt709",
|
| 16 |
+
"-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709"
|
| 17 |
+
],
|
| 18 |
+
"fake_trc": "bt709",
|
| 19 |
+
"audio_pass": ["-c:a", "pcm_s16le"],
|
| 20 |
+
"extension": "mov",
|
| 21 |
+
"extra_widgets": [["profile", ["lt", "standard", "hq", "4444", "4444xq"], {"default": "hq"}]]
|
| 22 |
+
}
|
video_formats/av1-webm.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-n", "-c:v", "libsvtav1",
|
| 5 |
+
"-pix_fmt", ["pix_fmt", ["yuv420p10le", "yuv420p"]],
|
| 6 |
+
"-crf", ["crf","INT", {"default": 23, "min": 0, "max": 100, "step": 1}],
|
| 7 |
+
"-vf", "scale=out_color_matrix=bt709",
|
| 8 |
+
"-color_range", "tv", "-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709"
|
| 9 |
+
],
|
| 10 |
+
"fake_trc": "bt709",
|
| 11 |
+
"audio_pass": ["-c:a", "libopus"],
|
| 12 |
+
"input_color_depth": ["input_color_depth", ["8bit", "16bit"]],
|
| 13 |
+
"save_metadata": ["save_metadata", "BOOLEAN", {"default": true}],
|
| 14 |
+
"extension": "webm",
|
| 15 |
+
"environment": {"SVT_LOG": "1"}
|
| 16 |
+
}
|
video_formats/ffmpeg-gif.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-n",
|
| 5 |
+
"-filter_complex", ["dither", ["bayer", "heckbert", "floyd_steinberg", "sierra2", "sierra2_4a", "sierra3", "burkes", "atkinson", "none"], {"default": "sierra2_4a"}, "[0:v] split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse=dither=$val"]
|
| 6 |
+
],
|
| 7 |
+
"extension": "gif"
|
| 8 |
+
}
|
video_formats/ffv1-mkv.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass": [
|
| 3 |
+
"-n",
|
| 4 |
+
"-c:v", "ffv1",
|
| 5 |
+
"-level", ["level", ["0", "1", "3"], {"default": "3"}],
|
| 6 |
+
"-coder", ["coder", ["0", "1", "2"], {"default": "1"}],
|
| 7 |
+
"-context", ["context", ["0", "1"], {"default": "1"}],
|
| 8 |
+
"-g", ["gop_size", "INT", {"default": 1, "min": 1, "max": 300, "step": 1}],
|
| 9 |
+
"-slices", ["slices", ["4", "6", "9", "12", "16", "20", "24", "30"], {"default": "16"}],
|
| 10 |
+
"-slicecrc", ["slicecrc", ["0", "1"], {"default": "1"}],
|
| 11 |
+
"-pix_fmt", ["pix_fmt", ["bgra", "rgba64le", "yuv420p", "yuv422p", "yuv444p", "yuva420p", "yuva422p", "yuva444p", "yuv420p10le", "yuv422p10le", "yuv444p10le", "yuv420p12le", "yuv422p12le", "yuv444p12le", "yuv420p14le", "yuv422p14le", "yuv444p14le", "yuv420p16le", "yuv422p16le", "yuv444p16le", "gray", "gray10le", "gray12le", "gray16le"], {"default": "bgra"}]
|
| 12 |
+
],
|
| 13 |
+
"audio_pass": ["-c:a", "flac"],
|
| 14 |
+
"save_metadata": ["save_metadata", "BOOLEAN", {"default": true}],
|
| 15 |
+
"trim_to_audio": ["trim_to_audio", "BOOLEAN", {"default": false}],
|
| 16 |
+
"extension": "mkv"
|
| 17 |
+
}
|
video_formats/gifski.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-pix_fmt", "yuv444p",
|
| 5 |
+
"-vf", "scale=out_color_matrix=bt709:out_range=pc",
|
| 6 |
+
"-color_range", "pc"
|
| 7 |
+
],
|
| 8 |
+
"extension": "gif",
|
| 9 |
+
"gifski_pass": [
|
| 10 |
+
"-Q", ["quality","INT", {"default": 90, "min": 1, "max": 100, "step": 1}]
|
| 11 |
+
]
|
| 12 |
+
}
|
video_formats/h264-mp4.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-n", "-c:v", "libx264",
|
| 5 |
+
"-pix_fmt", ["pix_fmt", ["yuv420p", "yuv420p10le"]],
|
| 6 |
+
"-crf", ["crf","INT", {"default": 19, "min": 0, "max": 100, "step": 1}],
|
| 7 |
+
"-vf", "scale=out_color_matrix=bt709",
|
| 8 |
+
"-color_range", "tv", "-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709"
|
| 9 |
+
],
|
| 10 |
+
"fake_trc": "bt709",
|
| 11 |
+
"audio_pass": ["-c:a", "aac"],
|
| 12 |
+
"save_metadata": ["save_metadata", "BOOLEAN", {"default": true}],
|
| 13 |
+
"trim_to_audio": ["trim_to_audio", "BOOLEAN", {"default": false}],
|
| 14 |
+
"extension": "mp4"
|
| 15 |
+
}
|
video_formats/h265-mp4.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-n", "-c:v", "libx265",
|
| 5 |
+
"-vtag", "hvc1",
|
| 6 |
+
"-pix_fmt", ["pix_fmt", ["yuv420p10le", "yuv420p"]],
|
| 7 |
+
"-crf", ["crf","INT", {"default": 22, "min": 0, "max": 100, "step": 1}],
|
| 8 |
+
"-preset", "medium",
|
| 9 |
+
"-x265-params", "log-level=quiet",
|
| 10 |
+
"-vf", "scale=out_color_matrix=bt709",
|
| 11 |
+
"-color_range", "tv", "-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709"
|
| 12 |
+
],
|
| 13 |
+
"fake_trc": "bt709",
|
| 14 |
+
"audio_pass": ["-c:a", "aac"],
|
| 15 |
+
"save_metadata": ["save_metadata", "BOOLEAN", {"default": true}],
|
| 16 |
+
"extension": "mp4"
|
| 17 |
+
}
|
video_formats/nvenc_av1-mp4.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-n", "-c:v", "av1_nvenc",
|
| 5 |
+
"-pix_fmt", ["pix_fmt", ["yuv420p", "p010le"]],
|
| 6 |
+
"-vf", "scale=out_color_matrix=bt709",
|
| 7 |
+
"-color_range", "tv", "-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709"
|
| 8 |
+
],
|
| 9 |
+
"fake_trc": "bt709",
|
| 10 |
+
"audio_pass": ["-c:a", "aac"],
|
| 11 |
+
"bitrate": ["bitrate","INT", {"default": 10, "min": 1, "max": 999, "step": 1 }],
|
| 12 |
+
"megabit": ["megabit","BOOLEAN", {"default": true}],
|
| 13 |
+
"save_metadata": ["save_metadata", "BOOLEAN", {"default": true}],
|
| 14 |
+
"extension": "mp4"
|
| 15 |
+
}
|
video_formats/nvenc_h264-mp4.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-n", "-c:v", "h264_nvenc",
|
| 5 |
+
"-pix_fmt", ["pix_fmt", ["yuv420p", "p010le"]],
|
| 6 |
+
"-vf", "scale=out_color_matrix=bt709",
|
| 7 |
+
"-color_range", "tv", "-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709"
|
| 8 |
+
],
|
| 9 |
+
"fake_trc": "bt709",
|
| 10 |
+
"audio_pass": ["-c:a", "aac"],
|
| 11 |
+
"bitrate": ["bitrate","INT", {"default": 10, "min": 1, "max": 999, "step": 1 }],
|
| 12 |
+
"megabit": ["megabit","BOOLEAN", {"default": true}],
|
| 13 |
+
"save_metadata": ["save_metadata", "BOOLEAN", {"default": true}],
|
| 14 |
+
"extension": "mp4"
|
| 15 |
+
}
|
video_formats/nvenc_hevc-mp4.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-n", "-c:v", "hevc_nvenc",
|
| 5 |
+
"-vtag", "hvc1",
|
| 6 |
+
"-pix_fmt", ["pix_fmt", ["yuv420p", "p010le"]],
|
| 7 |
+
"-vf", "scale=out_color_matrix=bt709",
|
| 8 |
+
"-color_range", "tv", "-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709"
|
| 9 |
+
],
|
| 10 |
+
"fake_trc": "bt709",
|
| 11 |
+
"audio_pass": ["-c:a", "aac"],
|
| 12 |
+
"bitrate": ["bitrate","INT", {"default": 10, "min": 1, "max": 999, "step": 1 }],
|
| 13 |
+
"megabit": ["megabit","BOOLEAN", {"default": true}],
|
| 14 |
+
"save_metadata": ["save_metadata", "BOOLEAN", {"default": true}],
|
| 15 |
+
"extension": "mp4"
|
| 16 |
+
}
|
video_formats/webm.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"main_pass":
|
| 3 |
+
[
|
| 4 |
+
"-n",
|
| 5 |
+
"-pix_fmt", ["pix_fmt",["yuv420p","yuva420p"]],
|
| 6 |
+
"-crf", ["crf","INT", {"default": 20, "min": 0, "max": 100, "step": 1}],
|
| 7 |
+
"-b:v", "0",
|
| 8 |
+
"-vf", "scale=out_color_matrix=bt709",
|
| 9 |
+
"-color_range", "tv", "-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709"
|
| 10 |
+
],
|
| 11 |
+
"fake_trc": "bt709",
|
| 12 |
+
"audio_pass": ["-c:a", "libvorbis"],
|
| 13 |
+
"save_metadata": ["save_metadata", "BOOLEAN", {"default": true}],
|
| 14 |
+
"trim_to_audio": ["trim_to_audio", "BOOLEAN", {"default": false}],
|
| 15 |
+
"extension": "webm"
|
| 16 |
+
}
|
videohelpersuite/batched_nodes.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from nodes import VAEEncode
|
| 3 |
+
from comfy.utils import ProgressBar
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class VAEDecodeBatched:
|
| 7 |
+
@classmethod
|
| 8 |
+
def INPUT_TYPES(s):
|
| 9 |
+
return {
|
| 10 |
+
"required": {
|
| 11 |
+
"samples": ("LATENT", ),
|
| 12 |
+
"vae": ("VAE", ),
|
| 13 |
+
"per_batch": ("INT", {"default": 16, "min": 1})
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/batched nodes"
|
| 18 |
+
|
| 19 |
+
RETURN_TYPES = ("IMAGE",)
|
| 20 |
+
FUNCTION = "decode"
|
| 21 |
+
|
| 22 |
+
def decode(self, vae, samples, per_batch):
|
| 23 |
+
decoded = []
|
| 24 |
+
pbar = ProgressBar(samples["samples"].shape[0])
|
| 25 |
+
for start_idx in range(0, samples["samples"].shape[0], per_batch):
|
| 26 |
+
decoded.append(vae.decode(samples["samples"][start_idx:start_idx+per_batch]))
|
| 27 |
+
pbar.update(per_batch)
|
| 28 |
+
return (torch.cat(decoded, dim=0), )
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class VAEEncodeBatched:
|
| 32 |
+
@classmethod
|
| 33 |
+
def INPUT_TYPES(s):
|
| 34 |
+
return {
|
| 35 |
+
"required": {
|
| 36 |
+
"pixels": ("IMAGE", ), "vae": ("VAE", ),
|
| 37 |
+
"per_batch": ("INT", {"default": 16, "min": 1})
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/batched nodes"
|
| 42 |
+
|
| 43 |
+
RETURN_TYPES = ("LATENT",)
|
| 44 |
+
FUNCTION = "encode"
|
| 45 |
+
|
| 46 |
+
def encode(self, vae, pixels, per_batch):
|
| 47 |
+
t = []
|
| 48 |
+
pbar = ProgressBar(pixels.shape[0])
|
| 49 |
+
for start_idx in range(0, pixels.shape[0], per_batch):
|
| 50 |
+
try:
|
| 51 |
+
sub_pixels = vae.vae_encode_crop_pixels(pixels[start_idx:start_idx+per_batch])
|
| 52 |
+
except:
|
| 53 |
+
sub_pixels = VAEEncode.vae_encode_crop_pixels(pixels[start_idx:start_idx+per_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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .logger import logger
|
| 2 |
+
|
| 3 |
+
def image(src):
|
| 4 |
+
return f'<img src={src} loading=lazy style="width: 0px; min-width: 100%">'
|
| 5 |
+
def video(src):
|
| 6 |
+
return f'<video preload="none" src={src} muted loop controls controlslist="nodownload noremoteplayback noplaybackrate" style="width: 0px; min-width: 100%" class="VHS_loopedvideo">'
|
| 7 |
+
def short_desc(desc):
|
| 8 |
+
return f'<div id=VHS_shortdesc>{desc}</div>'
|
| 9 |
+
|
| 10 |
+
def format_each(desc, **kwargs):
|
| 11 |
+
if isinstance(desc, dict):
|
| 12 |
+
res = {}
|
| 13 |
+
for k,v in desc.items():
|
| 14 |
+
res[format_each(k, **kwargs)] = format_each(v, **kwargs)
|
| 15 |
+
return res
|
| 16 |
+
if isinstance(desc, list):
|
| 17 |
+
res = []
|
| 18 |
+
for v in desc:
|
| 19 |
+
res.append(format_each(v, **kwargs))
|
| 20 |
+
return res
|
| 21 |
+
return desc.format(**kwargs)
|
| 22 |
+
def format_type(desc, lower, lowers=None, upper=None, uppers=None, cap=None):
|
| 23 |
+
"""Utility function for nodes with image/latent/mask variants"""
|
| 24 |
+
if lowers is None:
|
| 25 |
+
lowers = lower + 's'
|
| 26 |
+
if cap is None:
|
| 27 |
+
cap = lower.capitalize()
|
| 28 |
+
if upper is None:
|
| 29 |
+
upper = lower.upper()
|
| 30 |
+
if uppers is None:
|
| 31 |
+
uppers = lowers.upper()
|
| 32 |
+
return format_each(desc, lower=lower, lowers=lowers, upper=upper, uppers=uppers, cap=cap)
|
| 33 |
+
|
| 34 |
+
common_descriptions = {
|
| 35 |
+
'merge_strategy': [
|
| 36 |
+
'Determines what the output resolution will be if input resolutions don\'t match',
|
| 37 |
+
{'match A': 'Always use the resolution for A',
|
| 38 |
+
'match B': 'Always use the resolution for B',
|
| 39 |
+
'match smaller': 'Pick the smaller resolution by area',
|
| 40 |
+
'match larger': 'Pick the larger resolution by area',
|
| 41 |
+
}],
|
| 42 |
+
'scale_method': [
|
| 43 |
+
'Determines what method to use if scaling is required',
|
| 44 |
+
],
|
| 45 |
+
'crop_method': 'When sizes don\'t match, should the resized image have it\'s aspect ratio changed, or be cropped to maintain aspect ratio',
|
| 46 |
+
'VHS_PATH': [
|
| 47 |
+
'This is a VHS_PATH input. When edited, it provides a list of possible valid files or directories',
|
| 48 |
+
video('https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite/assets/4284322/729b7185-1fca-41d8-bc8d-a770bb2a5ce6'),
|
| 49 |
+
'The current top-most completion may be selected with Tab',
|
| 50 |
+
'You can navigate up a directory by pressing Ctrl+B (or Ctrl+W if supported by browser)',
|
| 51 |
+
'The filter on suggested file types can be disabled by pressing Ctrl+G.',
|
| 52 |
+
'If converted to an input, this functions as a string',
|
| 53 |
+
],
|
| 54 |
+
"GetCount": ['Get {cap} Count 🎥🅥🅗🅢', short_desc('Return the number of {lowers} in an input as an INT'),
|
| 55 |
+
{'Inputs': {
|
| 56 |
+
'{lowers}': 'The input {lower}',
|
| 57 |
+
},
|
| 58 |
+
'Outputs': {
|
| 59 |
+
'count': 'The number of {lowers} in the input',
|
| 60 |
+
},
|
| 61 |
+
}],
|
| 62 |
+
"SelectEveryNth": ['Select Every Nth {cap} 🎥🅥🅗🅢', short_desc('Keep only 1 {lower} for every interval'),
|
| 63 |
+
{'Inputs': {
|
| 64 |
+
'{lowers}': 'The input {lower}',
|
| 65 |
+
},
|
| 66 |
+
'Outputs': {
|
| 67 |
+
'{upper}': 'The output {lowers}',
|
| 68 |
+
'count': 'The number of {lowers} in the input',
|
| 69 |
+
},
|
| 70 |
+
'Widgets':{
|
| 71 |
+
'select_every_nth': 'The interval from which one frame is kept. 1 means no frames are skipped.',
|
| 72 |
+
'skip_first_{lowers}': 'A number of frames which that is skipped from the start. This applies before select_every_nth. As a result, multiple copies of the node can each have a different skip_first_frames to divide the {lower} into groups'
|
| 73 |
+
},
|
| 74 |
+
}],
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
descriptions = {
|
| 78 |
+
'VHS_VideoCombine': ['Video Combine 🎥🅥🅗🅢', short_desc('Combine an image sequence into a video'), {
|
| 79 |
+
'Inputs': {
|
| 80 |
+
'images': 'The images to be turned into a video',
|
| 81 |
+
'audio':'(optional) audio to add to the video',
|
| 82 |
+
'meta_batch': '(optional) Connect to a Meta Batch manager to divide extremely long image sequences into sub batches. See the documentation for Meta Batch Manager',
|
| 83 |
+
'vae':['(optional) If provided, the node will take latents as input instead of images. This drastically reduces the required RAM (not VRAM) when working with long (100+ frames) sequences',
|
| 84 |
+
"Unlike on Load Video, this isn't always a strict upgrade over using a standalone VAE Decode.",
|
| 85 |
+
"If you have multiple Video Combine outputs, then the VAE decode will be performed for each output node increasing execution time",
|
| 86 |
+
"If you make any change to output settings on the Video Combine (such as changing the output format), the VAE decode will be performed again as the decoded result is (by design) not cached",
|
| 87 |
+
]
|
| 88 |
+
},
|
| 89 |
+
'Widgets':{
|
| 90 |
+
'frame_rate': 'The frame rate which will be used for the output video. Consider converting this to an input and connecting this to a Load Video with Video Info(Loaded)->fps. When including audio, failure to properly set this will result in audio desync',
|
| 91 |
+
'loop_count': 'The number of additional times the video should repeat. Can cause performance issues when used with long (100+ frames) sequences',
|
| 92 |
+
'filename_prefix': 'A prefix to add to the name of the output filename. This can include subfolders or format strings.',
|
| 93 |
+
'format': 'The output format to use. Formats starting with, \'image\' are saved with PIL, but formats starting with \'video\' utilize the video_formats system. \'video\' options require ffmpeg and selecting one frequently adds additional options to the node.',
|
| 94 |
+
'pingpong': 'Play the video normally, then repeat the video in reverse so that it \'pingpongs\' back and forth. This is frequently used to minimize the appearance of skips on very short animations.',
|
| 95 |
+
'save_output': 'Specifies if output files should be saved to the output folder, or the temporary output folder',
|
| 96 |
+
'videopreview': 'Displays a preview for the processed result. If advanced previews is enabled, the output is always converted to a format viewable from the browser. If the video has audio, it will also be previewed when moused over. Additional preview options can be accessed with right click.',
|
| 97 |
+
},
|
| 98 |
+
'Common Format Widgets': {
|
| 99 |
+
'crf': 'Determines how much to prioritize quality over filesize. Numbers vary between formats, but on each format that includes it, the default value provides visually loss less output',
|
| 100 |
+
'pix_fmt': ['The pixel format to use for output. Alternative options will often have higher quality at the cost of increased file size and reduced compatibility with external software.', {
|
| 101 |
+
'yuv420p': 'The most common and default format',
|
| 102 |
+
'yuv420p10le': 'Use 10 bit color depth. This can improve color quality when combined with 16bit input color depth',
|
| 103 |
+
'yuva420p': 'Include transparency in the output video'
|
| 104 |
+
}],
|
| 105 |
+
'input_color_depth': 'VHS supports outputting 16bit images. While this produces higher quality output, the difference usually isn\'t visible without postprocessing and it significantly increases file size and processing time.',
|
| 106 |
+
'save_metadata': 'Determines if metadata for the workflow should be included in the output video file',
|
| 107 |
+
}
|
| 108 |
+
}],
|
| 109 |
+
'VHS_LoadVideo': ['Load Video 🎥🅥🅗🅢', short_desc('Loads a video from the input folder'),
|
| 110 |
+
{'Inputs': {
|
| 111 |
+
'meta_batch': '(optional) Connect to a Meta Batch manager to divide extremely long sequences into sub batches. See the documentation for Meta Batch Manager',
|
| 112 |
+
'vae': ['(optional) If provided the node will output latents instead of images. This drastically reduces the required RAM (not VRAM) when working with long (100+ frames) sequences',
|
| 113 |
+
'Using this is strongly encouraged unless connecting to a node that requires a blue image connection such as Apply Controllnet',
|
| 114 |
+
],
|
| 115 |
+
},
|
| 116 |
+
'Outputs': {
|
| 117 |
+
'IMAGE': 'The loaded images',
|
| 118 |
+
'frame_count': 'The length of images just returned',
|
| 119 |
+
'audio': 'The audio from the loaded video',
|
| 120 |
+
'video_info': 'Exposes additional info about the video such as the source frame rate, or the total length',
|
| 121 |
+
'LATENT': 'The loaded images pre-converted to latents. Only available when a vae is connected',
|
| 122 |
+
},
|
| 123 |
+
'Widgets': {
|
| 124 |
+
'video': 'The video file to be loaded. Lists all files with a video extension in the ComfyUI/Input folder',
|
| 125 |
+
'force_rate': 'Drops or duplicates frames so that the produced output has the target frame rate. Many motion models are trained on videos of a specific frame rate and will give better results if input matches that frame rate. If set to 0, all frames are returned. May give unusual results with inputs that have a variable frame rate like animated gifs. Reducing this value can also greatly reduce the execution time and memory requirements.',
|
| 126 |
+
'force_size': 'Previously was used to provide suggested resolutions. Instead, custom_width and custom_height can be disabled by setting to 0.',
|
| 127 |
+
'custom_width': 'Allows for an arbitrary width to be entered, cropping to maintain aspect ratio if both are set',
|
| 128 |
+
'custom_height': 'Allows for an arbitrary height to be entered, cropping to maintain aspect ratio if both are set',
|
| 129 |
+
'frame_load_cap': 'The maximum number of frames to load. If 0, all frames are loaded.',
|
| 130 |
+
'skip_first_frames': 'A number of frames which are discarded before producing output.',
|
| 131 |
+
'select_every_nth': 'Similar to frame rate. Keeps only the first of every n frames and discard the rest. Has better compatibility with variable frame rate inputs such as gifs. When combined with force_rate, select_every_nth_applies after force_rate so the resulting output has a frame rate equivalent to force_rate/select_every_nth. select_every_nth does not apply to skip_first_frames',
|
| 132 |
+
'format': 'Updates other widgets so that only values supported by the given format can be entered and provides recommended defaults.',
|
| 133 |
+
'choose video to upload': 'An upload button is provided to upload local files to the input folder',
|
| 134 |
+
'videopreview': 'Displays a preview for the selected video input. If advanced previews is enabled, this preview will reflect the frame_load_cap, force_rate, skip_first_frames, and select_every_nth values chosen. If the video has audio, it will also be previewed when moused over. Additional preview options can be accessed with right click.',
|
| 135 |
+
}
|
| 136 |
+
}],
|
| 137 |
+
'VHS_LoadVideoFFmpeg': ['Load Video FFmpeg 🎥🅥🅗🅢', short_desc('Loads a video from the input folder using ffmpeg instead of opencv'),
|
| 138 |
+
'Provides faster execution speed, transparency support, and allows specifying start time in seconds',
|
| 139 |
+
{'Inputs': {
|
| 140 |
+
'meta_batch': '(optional) Connect to a Meta Batch manager to divide extremely long sequences into sub batches. See the documentation for Meta Batch Manager',
|
| 141 |
+
'vae': ['(optional) If provided the node will output latents instead of images. This drastically reduces the required RAM (not VRAM) when working with long (100+ frames) sequences',
|
| 142 |
+
'Using this is strongly encouraged unless connecting to a node that requires a blue image connection such as Apply Controllnet',
|
| 143 |
+
],
|
| 144 |
+
},
|
| 145 |
+
'Outputs': {
|
| 146 |
+
'IMAGE': 'The loaded images',
|
| 147 |
+
'mask': 'Transparency data from the loaded video',
|
| 148 |
+
'audio': 'The audio from the loaded video',
|
| 149 |
+
'video_info': 'Exposes additional info about the video such as the source frame rate, or the total length',
|
| 150 |
+
'LATENT': 'The loaded images pre-converted to latents. Only available when a vae is connected',
|
| 151 |
+
},
|
| 152 |
+
'Widgets': {
|
| 153 |
+
'video': 'The video file to be loaded. Lists all files with a video extension in the ComfyUI/Input folder',
|
| 154 |
+
'force_rate': 'Drops or duplicates frames so that the produced output has the target frame rate. Many motion models are trained on videos of a specific frame rate and will give better results if input matches that frame rate. If set to 0, all frames are returned. May give unusual results with inputs that have a variable frame rate like animated gifs. Reducing this value can also greatly reduce the execution time and memory requirements.',
|
| 155 |
+
'force_size': 'Previously was used to provide suggested resolutions. Instead, custom_width and custom_height can be disabled by setting to 0.',
|
| 156 |
+
'custom_width': 'Allows for an arbitrary width to be entered, cropping to maintain aspect ratio if both are set',
|
| 157 |
+
'custom_height': 'Allows for an arbitrary height to be entered, cropping to maintain aspect ratio if both are set',
|
| 158 |
+
'frame_load_cap': 'The maximum number of frames to load. If 0, all frames are loaded.',
|
| 159 |
+
'start_time': 'A timestamp, in seconds from the start of the video, to start loading frames from. ',
|
| 160 |
+
'format': 'Updates other widgets so that only values supported by the given format can be entered and provides recommended defaults.',
|
| 161 |
+
'choose video to upload': 'An upload button is provided to upload local files to the input folder',
|
| 162 |
+
'videopreview': 'Displays a preview for the selected video input. If advanced previews is enabled, this preview will reflect the frame_load_cap, force_rate, skip_first_frames, and select_every_nth values chosen. If the video has audio, it will also be previewed when moused over. Additional preview options can be accessed with right click.',
|
| 163 |
+
}
|
| 164 |
+
}],
|
| 165 |
+
'VHS_LoadVideoPath': ['Load Video (Path) 🎥🅥🅗🅢', short_desc('Loads a video from an arbitrary path'),
|
| 166 |
+
{'Inputs': {
|
| 167 |
+
'meta_batch': '(optional) Connect to a Meta Batch manager to divide extremely long sequences into sub batches. See the documentation for Meta Batch Manager',
|
| 168 |
+
'vae': ['(optional) If provided the node will output latents instead of images. This drastically reduces the required RAM (not VRAM) when working with long (100+ frames) sequences',
|
| 169 |
+
'Using this is strongly encouraged unless connecting to a node that requires a blue image connection such as Apply Controllnet',
|
| 170 |
+
],
|
| 171 |
+
},
|
| 172 |
+
'Outputs': {
|
| 173 |
+
'IMAGE': 'The loaded images',
|
| 174 |
+
'frame_count': 'The length of images just returned',
|
| 175 |
+
'audio': 'The audio from the loaded video',
|
| 176 |
+
'video_info': 'Exposes additional info about the video such as the source frame rate, or the total length',
|
| 177 |
+
'LATENT': 'The loaded images pre-converted to latents. Only available when a vae is connected',
|
| 178 |
+
},
|
| 179 |
+
'Widgets': {
|
| 180 |
+
'video': ['The video file to be loaded.', 'You can also select an image to load it as a single frame'] + common_descriptions['VHS_PATH'],
|
| 181 |
+
'force_rate': 'Drops or duplicates frames so that the produced output has the target frame rate. Many motion models are trained on videos of a specific frame rate and will give better results if input matches that frame rate. If set to 0, all frames are returned. May give unusual results with inputs that have a variable frame rate like animated gifs. Reducing this value can also greatly reduce the execution time and memory requirements.',
|
| 182 |
+
'force_size': 'Previously was used to provide suggested resolutions. Instead, custom_width and custom_height can be disabled by setting to 0.',
|
| 183 |
+
'custom_width': 'Allows for an arbitrary width to be entered, cropping to maintain aspect ratio if both are set',
|
| 184 |
+
'custom_height': 'Allows for an arbitrary height to be entered, cropping to maintain aspect ratio if both are set',
|
| 185 |
+
'frame_load_cap': 'The maximum number of frames to load. If 0, all frames are loaded.',
|
| 186 |
+
'skip_first_frames': 'A number of frames which are discarded before producing output.',
|
| 187 |
+
'select_every_nth': 'Similar to frame rate. Keeps only the first of every n frames and discard the rest. Has better compatibility with variable frame rate inputs such as gifs. When combined with force_rate, select_every_nth_applies after force_rate so the resulting output has a frame rate equivalent to force_rate/select_every_nth. select_every_nth does not apply to skip_first_frames',
|
| 188 |
+
'format': 'Updates other widgets so that only values supported by the given format can be entered and provides recommended defaults.',
|
| 189 |
+
'videopreview': 'Displays a preview for the selected video input. Will only be shown if Advanced Previews is enabled. This preview will reflect the frame_load_cap, force_rate, skip_first_frames, and select_every_nth values chosen. If the video has audio, it will also be previewed when moused over. Additional preview options can be accessed with right click.',
|
| 190 |
+
}
|
| 191 |
+
}],
|
| 192 |
+
'VHS_LoadVideoFFmpegPath': ['Load Video FFmpeg (Path) 🎥🅥🅗🅢', short_desc('Loads a video from an arbitrary path using ffmpeg instead of opencv'),
|
| 193 |
+
'Provides faster execution speed, transparency support, and allows specifying start time in seconds',
|
| 194 |
+
{'Inputs': {
|
| 195 |
+
'meta_batch': '(optional) Connect to a Meta Batch manager to divide extremely long sequences into sub batches. See the documentation for Meta Batch Manager',
|
| 196 |
+
'vae': ['(optional) If provided the node will output latents instead of images. This drastically reduces the required RAM (not VRAM) when working with long (100+ frames) sequences',
|
| 197 |
+
'Using this is strongly encouraged unless connecting to a node that requires a blue image connection such as Apply Controllnet',
|
| 198 |
+
],
|
| 199 |
+
},
|
| 200 |
+
'Outputs': {
|
| 201 |
+
'IMAGE': 'The loaded images',
|
| 202 |
+
'mask': 'Transparency data from the loaded video',
|
| 203 |
+
'audio': 'The audio from the loaded video',
|
| 204 |
+
'video_info': 'Exposes additional info about the video such as the source frame rate, or the total length',
|
| 205 |
+
'LATENT': 'The loaded images pre-converted to latents. Only available when a vae is connected',
|
| 206 |
+
},
|
| 207 |
+
'Widgets': {
|
| 208 |
+
'video': ['The video file to be loaded.', 'You can also select an image to load it as a single frame'] + common_descriptions['VHS_PATH'],
|
| 209 |
+
'force_rate': 'Drops or duplicates frames so that the produced output has the target frame rate. Many motion models are trained on videos of a specific frame rate and will give better results if input matches that frame rate. If set to 0, all frames are returned. May give unusual results with inputs that have a variable frame rate like animated gifs. Reducing this value can also greatly reduce the execution time and memory requirements.',
|
| 210 |
+
'force_size': 'Previously was used to provide suggested resolutions. Instead, custom_width and custom_height can be disabled by setting to 0.',
|
| 211 |
+
'custom_width': 'Allows for an arbitrary width to be entered, cropping to maintain aspect ratio if both are set',
|
| 212 |
+
'custom_height': 'Allows for an arbitrary height to be entered, cropping to maintain aspect ratio if both are set',
|
| 213 |
+
'frame_load_cap': 'The maximum number of frames to load. If 0, all frames are loaded.',
|
| 214 |
+
'skip_first_frames': 'A number of frames which are discarded before producing output.',
|
| 215 |
+
'select_every_nth': 'Similar to frame rate. Keeps only the first of every n frames and discard the rest. Has better compatibility with variable frame rate inputs such as gifs. When combined with force_rate, select_every_nth_applies after force_rate so the resulting output has a frame rate equivalent to force_rate/select_every_nth. select_every_nth does not apply to skip_first_frames',
|
| 216 |
+
'format': 'Updates other widgets so that only values supported by the given format can be entered and provides recommended defaults.',
|
| 217 |
+
'videopreview': 'Displays a preview for the selected video input. Will only be shown if Advanced Previews is enabled. This preview will reflect the frame_load_cap, force_rate, skip_first_frames, and select_every_nth values chosen. If the video has audio, it will also be previewed when moused over. Additional preview options can be accessed with right click.',
|
| 218 |
+
}
|
| 219 |
+
}],
|
| 220 |
+
'VHS_LoadImages': ['Load Images 🎥🅥🅗🅢', short_desc('Loads a sequence of images from a subdirectory of the input folder'),
|
| 221 |
+
{'Inputs': {
|
| 222 |
+
'meta_batch': '(optional) Connect to a Meta Batch manager to divide extremely long sequences into sub batches. See the documentation for Meta Batch Manager',
|
| 223 |
+
},
|
| 224 |
+
'Outputs': {
|
| 225 |
+
'IMAGE': 'The loaded images',
|
| 226 |
+
'MASK': 'The alpha channel of the loaded images.',
|
| 227 |
+
'frame_count': 'The length of images just returned',
|
| 228 |
+
},
|
| 229 |
+
'Widgets': {
|
| 230 |
+
'directory': 'The directory images will be loaded from. Filtered to process jpg, png, ppm, bmp, tif, and webp files',
|
| 231 |
+
'image_load_cap': 'The maximum number of images to load. If 0, all images are loaded.',
|
| 232 |
+
'start_time': 'A timestamp, in seconds from the start of the video, to start loading frames from. ',
|
| 233 |
+
'choose folder to upload': 'An upload button is provided to upload a local folder containing images to the input folder',
|
| 234 |
+
'videopreview': 'Displays a preview for the selected video input. Will only be shown if Advanced Previews is enabled. This preview will reflect the image_load_cap, skip_first_images, and select_every_nth values chosen. Additional preview options can be accessed with right click.',
|
| 235 |
+
}
|
| 236 |
+
}],
|
| 237 |
+
'VHS_LoadImagesPath': ['Load Images (Path) 🎥🅥🅗🅢', short_desc('Loads a sequence of images from an arbitrary path'),
|
| 238 |
+
{'Inputs': {
|
| 239 |
+
'meta_batch': '(optional) Connect to a Meta Batch manager to divide extremely long sequences into sub batches. See the documentation for Meta Batch Manager',
|
| 240 |
+
},
|
| 241 |
+
'Outputs': {
|
| 242 |
+
'IMAGE': 'The loaded images',
|
| 243 |
+
'MASK': 'The alpha channel of the loaded images.',
|
| 244 |
+
'frame_count': 'The length of images just returned',
|
| 245 |
+
},
|
| 246 |
+
'Widgets': {
|
| 247 |
+
'directory': ['The directory images will be loaded from. Filtered to process jpg, png, ppm, bmp, tif, and webp files'] + common_descriptions['VHS_PATH'],
|
| 248 |
+
'image_load_cap': 'The maximum number of images to load. If 0, all images are loaded.',
|
| 249 |
+
'skip_first_images': 'A number of images which are discarded before producing output.',
|
| 250 |
+
'select_every_nth': 'Keeps only the first of every n frames and discard the rest.',
|
| 251 |
+
'videopreview': 'Displays a preview for the selected video input. Will only be shown if Advanced Previews is enabled. This preview will reflect the image_load_cap, skip_first_images, and select_every_nth values chosen. Additional preview options can be accessed with right click.',
|
| 252 |
+
}
|
| 253 |
+
}],
|
| 254 |
+
'VHS_LoadImagePath': ['Load Image (Path) 🎥🅥🅗🅢', short_desc('Load a single image from a given path'),
|
| 255 |
+
{'Inputs': {
|
| 256 |
+
'vae': '(optional) If provided the node will output latents instead of images.',
|
| 257 |
+
},
|
| 258 |
+
'Outputs': {
|
| 259 |
+
'IMAGE': 'The loaded images',
|
| 260 |
+
'MASK': 'The alpha channel of the loaded images.',
|
| 261 |
+
},
|
| 262 |
+
'Widgets': {
|
| 263 |
+
'image': ['The image file to be loaded.'] + common_descriptions['VHS_PATH'],
|
| 264 |
+
'force_size': ['Allows for conveniently scaling the input without requiring an additional node. Provides options to maintain aspect ratio or conveniently target common training formats for Animate Diff', {'custom_width': 'Allows for an arbitrary width to be entered, cropping to maintain aspect ratio if both are set',
|
| 265 |
+
'custom_height': 'Allows for an arbitrary height to be entered, cropping to maintain aspect ratio if both are set'}],
|
| 266 |
+
'videopreview': 'Displays a preview for the selected video input. Will only be shown if Advanced Previews is enabled. This preview will reflect the image_load_cap, skip_first_images, and select_every_nth values chosen. Additional preview options can be accessed with right click.',
|
| 267 |
+
}
|
| 268 |
+
}],
|
| 269 |
+
"VHS_LoadAudio": ['Load Audio (Path) 🎥🅥🅗🅢', short_desc('Loads an audio file from an arbitrary path'),
|
| 270 |
+
{'Outputs': {
|
| 271 |
+
'audio': 'The loaded audio',
|
| 272 |
+
},
|
| 273 |
+
'Widgets': {
|
| 274 |
+
'audio_file': ['The audio file to be loaded.'] + common_descriptions['VHS_PATH'],
|
| 275 |
+
'seek_seconds': 'An offset from the start of the sound file that the audio should start from',
|
| 276 |
+
}
|
| 277 |
+
}],
|
| 278 |
+
"VHS_LoadAudioUpload": ['Load Audio (Upload) 🎥🅥🅗🅢', short_desc('Loads an audio file from the input directory'),
|
| 279 |
+
"Very similar in functionality to the built-in LoadAudio. It was originally added before VHS swapped to use Comfy's internal AUDIO format, but provides the additional options for start time and duration",
|
| 280 |
+
{'Outputs': {
|
| 281 |
+
'audio': 'The loaded audio',
|
| 282 |
+
},
|
| 283 |
+
'Widgets': {
|
| 284 |
+
'audio': 'The audio file to be loaded.',
|
| 285 |
+
'start_time': 'An offset from the start of the sound file that the audio should start from',
|
| 286 |
+
'duration': 'A maximum limit for the audio. Disabled if 0',
|
| 287 |
+
'choose audio to upload': 'An upload button is provided to upload an audio file to the input folder',
|
| 288 |
+
}
|
| 289 |
+
}],
|
| 290 |
+
"VHS_AudioToVHSAudio": ['Audio to legacy VHS_AUDIO 🎥🅥🅗🅢', short_desc('utility function for compatibility with external nodes'),
|
| 291 |
+
"VHS used to use an internal VHS_AUDIO format for routing audio between inputs and outputs. This format was intended to only be used internally and was designed with a focus on performance over ease of use. Since ComfyUI now has an internal AUDIO format, VHS now uses this format. However, some custom node packs were made that are external to both ComfyUI and VHS that use VHS_AUDIO. This node was added so that those external nodes can still function",
|
| 292 |
+
{'Inputs': {
|
| 293 |
+
'audio': 'An input in the standardized AUDIO format',
|
| 294 |
+
},
|
| 295 |
+
'Outputs': {
|
| 296 |
+
'vhs_audio': 'An output in the legacy VHS_AUDIO format for use with external nodes',
|
| 297 |
+
},
|
| 298 |
+
}],
|
| 299 |
+
"VHS_VHSAudioToAudio": ['Legacy VHS_AUDIO to Audio 🎥🅥🅗🅢', short_desc('utility function for compatibility with external nodes'),
|
| 300 |
+
"VHS used to use an internal VHS_AUDIO format for routing audio between inputs and outputs. This format was intended to only be used internally and was designed with a focus on performance over ease of use. Since ComfyUI now has an internal AUDIO format, VHS now uses this format. However, some custom node packs were made that are external to both ComfyUI and VHS that use VHS_AUDIO. This node was added so that those external nodes can still function",
|
| 301 |
+
{'Inputs': {
|
| 302 |
+
'vhs_audio': 'An input in the legacy VHS_AUDIO format produced by an external node',
|
| 303 |
+
},
|
| 304 |
+
'Outputs': {
|
| 305 |
+
'vhs_audio': 'An output in the standardized AUDIO format',
|
| 306 |
+
},
|
| 307 |
+
}],
|
| 308 |
+
"VHS_PruneOutputs": ['Prune Outputs 🎥🅥🅗🅢', short_desc('Automates deletion of undesired outputs from a Video Combine node.'),
|
| 309 |
+
'Video Combine produces a number of file outputs in addition to the final output. Some of these, such as a video file without audio included, are implementation limitations and are not feasible to solve. As an alternative, the Prune Outputs node is added to automate the deletion of these file outputs if they are not desired',
|
| 310 |
+
{'Inputs': {
|
| 311 |
+
'filenames': 'A connection from a Video Combine node to indicate which outputs should be pruned',
|
| 312 |
+
},
|
| 313 |
+
'Widgets': {
|
| 314 |
+
'options': ['Which files should be deleted',
|
| 315 |
+
{'Intermediate': 'Delete any files that were required for intermediate processing but are not the final output, like the no-audio output file when audio is included',
|
| 316 |
+
'Intermediate and Utility': 'Delete all produced files that aren\'t the final output, including the first frame png',
|
| 317 |
+
}]}
|
| 318 |
+
}],
|
| 319 |
+
"VHS_BatchManager": ['Meta Batch Manager 🎥🅥🅗🅢', short_desc('Split the processing of a very long video into sets of smaller Meta Batches'),
|
| 320 |
+
"The Meta Batch Manager allows for extremely long input videos to be processed when all other methods for fitting the content in RAM fail. It does not effect VRAM usage.",
|
| 321 |
+
"It must be connected to at least one Input (a Load Video or Load Images) AND at least one Video Combine",
|
| 322 |
+
image("https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite/assets/4284322/7cb3fb7e-59d8-4cb2-a09f-9c6698de8b1f"),
|
| 323 |
+
"It functions by holding both the inputs and ouputs open between executions, and automatically requeue's the workflow until one of the inputs is unable to provide additional images.",
|
| 324 |
+
"Because each sub execution only contains a subset of the total frames, each sub execution creates a hard window which temporal smoothing can not be applied across. This results in jumps in the output.",
|
| 325 |
+
{'Outputs': {
|
| 326 |
+
'meta_batch': 'Add all connected nodes to this Meta Batch',
|
| 327 |
+
},
|
| 328 |
+
'Widgets': {
|
| 329 |
+
'frames_per_batch': 'How many frames to process for each sub execution. If loading as image, each frame will use about 50MB of RAM (not VRAM), and this can safely be set in the 100-1000 range, depending on available memory. When loading and combining from latent space (no blue image noodles exist), this value can be much higher, around the 2,000 to 20,000 range',
|
| 330 |
+
}
|
| 331 |
+
}],
|
| 332 |
+
"VHS_VideoInfo": ['Video Info 🎥🅥🅗🅢', short_desc('Splits information on a video into a numerous outputs'),
|
| 333 |
+
{'Inputs': {
|
| 334 |
+
'video_info': 'A connection to a Load Video node',
|
| 335 |
+
},
|
| 336 |
+
'Outputs': {
|
| 337 |
+
'source_fps🟨': 'The frame rate of the video',
|
| 338 |
+
'source_frame_count🟨': 'How many total frames the video contains before accounting for frame rate or select_every_nth',
|
| 339 |
+
'source_duration🟨': 'The length of images just returned in seconds',
|
| 340 |
+
'source_width🟨': 'The width',
|
| 341 |
+
'source_height🟨': 'The height',
|
| 342 |
+
'loaded_fps🟦': 'The frame rate after accounting for force_rate and select_every_nth. This output is of particular use as it can be connected to the converted frame_rate input of a Video Combine node to ensure audio remains synchronized.',
|
| 343 |
+
'loaded_frame_count🟦': 'The number of frames returned by the current execution. Identical to the frame_count returned by the node itself',
|
| 344 |
+
'loaded_duration🟦': 'The duration in seconds of returned images after accounting for frame_load_cap',
|
| 345 |
+
'loaded_width🟦': 'The width of the video after scaling. These coordinates are in image space even if loading to latent space',
|
| 346 |
+
'loaded_height🟦': 'The height of the video after scaling. These coordinates are in image space even if loading to latent space',
|
| 347 |
+
},
|
| 348 |
+
}],
|
| 349 |
+
"VHS_VideoInfoSource": ['Video Info Source 🎥🅥🅗🅢', short_desc('Splits information on a video into a numerous outputs describing the file itself without accounting for load options'),
|
| 350 |
+
{'Inputs': {
|
| 351 |
+
'video_info': 'A connection to a Load Video node',
|
| 352 |
+
},
|
| 353 |
+
'Outputs': {
|
| 354 |
+
'source_fps🟨': 'The frame rate of the video',
|
| 355 |
+
'source_frame_count🟨': 'How many total frames the video contains before accounting for frame rate or select_every_nth',
|
| 356 |
+
'source_duration🟨': 'The length of images just returned in seconds',
|
| 357 |
+
'source_width🟨': 'The original width',
|
| 358 |
+
'source_height🟨': 'The original height',
|
| 359 |
+
}
|
| 360 |
+
}],
|
| 361 |
+
"VHS_VideoInfoLoaded": ['Video Info Loaded 🎥🅥🅗🅢', short_desc('Splits information on a video into a numerous outputs describing the file itself after accounting for load options'),
|
| 362 |
+
{'Inputs': {
|
| 363 |
+
'video_info': 'A connection to a Load Video node',
|
| 364 |
+
},
|
| 365 |
+
'Outputs': {
|
| 366 |
+
'loaded_fps🟦': 'The frame rate after accounting for force_rate and select_every_nth. This output is of particular use as it can be connected to the converted frame_rate input of a Video Combine node to ensure audio remains synchronized.',
|
| 367 |
+
'loaded_frame_count🟦': 'The number of frames returned by the current execution. Identical to the frame_count returned by the node itself',
|
| 368 |
+
'loaded_duration🟦': 'The duration in seconds of returned images after accounting for frame_load_cap',
|
| 369 |
+
'loaded_width🟦': 'The width of the video after scaling. This is the dimension of the corresponding image even if loading as a latent directly',
|
| 370 |
+
'loaded_height🟦': 'The height of the video after scaling. This is the dimension of the corresponding image even if loading as a latent directly',
|
| 371 |
+
}
|
| 372 |
+
}],
|
| 373 |
+
"VHS_SelectFilename": ['VAE Select Filename 🎥🅥🅗🅢', short_desc('Select a single filename from the VHS_FILENAMES output by a Video Combine and return it as a string'),
|
| 374 |
+
'Take care when combining this node with Prune Outputs. The VHS_FILENAMES object is immutable and will always contain the full list of output files, but execution order is undefined behavior (currently, Prune Outputs will generally execute first) and SelectFilename may return a path to a file that no longer exists.',
|
| 375 |
+
{'Inputs': {
|
| 376 |
+
'filenames': 'A VHS_FILENAMES from a Video Combine node',
|
| 377 |
+
},
|
| 378 |
+
'Outputs': {
|
| 379 |
+
'filename': 'A string representation of the full output path for the chosen file',
|
| 380 |
+
},
|
| 381 |
+
'Widgets': {
|
| 382 |
+
'index': 'The index of which file should be selected. The default, -1, chooses the most complete output',
|
| 383 |
+
},
|
| 384 |
+
}],
|
| 385 |
+
# Batched Nodes
|
| 386 |
+
"VHS_VAEEncodeBatched": ['VAE Encode Batched 🎥🅥🅗🅢', short_desc('Encode images as latents with a manually specified batch size.'),
|
| 387 |
+
"Some people have ran into VRAM issues when encoding or decoding large batches of images. As a workaround, this node lets you manually set a batch size when encoding images.",
|
| 388 |
+
"Unless these issues have been encountered, it is simpler to use the native VAE Encode or to encode directly from a Load Video",
|
| 389 |
+
{'Inputs': {
|
| 390 |
+
'pixels': 'The images to be encoded.',
|
| 391 |
+
'vae': 'The VAE to use when encoding.',
|
| 392 |
+
},
|
| 393 |
+
'Outputs': {
|
| 394 |
+
'LATENT': 'The encoded latents.',
|
| 395 |
+
},
|
| 396 |
+
'Widgets': {
|
| 397 |
+
'per_batch': 'The maximum number of images to encode in each batch.',
|
| 398 |
+
},
|
| 399 |
+
}],
|
| 400 |
+
"VHS_VAEDecodeBatched": ['VAE Decode Batched 🎥🅥🅗🅢', short_desc('Decode latents to images with a manually specified batch size'),
|
| 401 |
+
"Some people have ran into VRAM issues when encoding or decoding large batches of images. As a workaround, this node lets you manually set a batch size when decoding latents.",
|
| 402 |
+
"Unless these issues have been encountered, it is simpler to use the native VAE Decode or to decode from a Video Combine directly",
|
| 403 |
+
{'Inputs': {
|
| 404 |
+
'samples': 'The latents to be decoded.',
|
| 405 |
+
'vae': 'The VAE to use when decoding.',
|
| 406 |
+
},
|
| 407 |
+
'Outputs': {
|
| 408 |
+
'IMAGE': 'The decoded images.',
|
| 409 |
+
},
|
| 410 |
+
'Widgets': {
|
| 411 |
+
'per_batch': 'The maximum number of images to decode in each batch.',
|
| 412 |
+
},
|
| 413 |
+
}],
|
| 414 |
+
# Latent and Image nodes
|
| 415 |
+
"VHS_SplitLatents": ['Split Latents 🎥🅥🅗🅢', short_desc('Split a set of latents into two groups'),
|
| 416 |
+
{'Inputs': {
|
| 417 |
+
'latents': 'The latents to be split.',
|
| 418 |
+
},
|
| 419 |
+
'Outputs': {
|
| 420 |
+
'LATENT_A': 'The first group of latents',
|
| 421 |
+
'A_count': 'The number of latents in group A. This will be equal to split_index unless the latents input has length less than split_index',
|
| 422 |
+
'LATENT_B': 'The second group of latents',
|
| 423 |
+
'B_count': 'The number of latents in group B'
|
| 424 |
+
},
|
| 425 |
+
'Widgets': {
|
| 426 |
+
'split_index': 'The index of the first latent that will be in the second output groups.',
|
| 427 |
+
},
|
| 428 |
+
|
| 429 |
+
}],
|
| 430 |
+
"VHS_SplitImages": ['Split Images 🎥🅥🅗🅢', short_desc('Split a set of images into two groups'),
|
| 431 |
+
{'Inputs': {
|
| 432 |
+
'images': 'The images to be split.',
|
| 433 |
+
},
|
| 434 |
+
'Outputs': {
|
| 435 |
+
'IMAGE_A': 'The first group of images',
|
| 436 |
+
'A_count': 'The number of images in group A. This will be equal to split_index unless the images input has length less than split_index',
|
| 437 |
+
'IMAGE_B': 'The second group of images',
|
| 438 |
+
'B_count': 'The number of images in group B'
|
| 439 |
+
},
|
| 440 |
+
'Widgets': {
|
| 441 |
+
'split_index': 'The index of the first latent that will be in the second output groups.',
|
| 442 |
+
},
|
| 443 |
+
|
| 444 |
+
}],
|
| 445 |
+
"VHS_SplitMasks": ['Split Masks 🎥🅥🅗🅢', short_desc('Split a set of masks into two groups'),
|
| 446 |
+
{'Inputs': {
|
| 447 |
+
'mask': 'The masks to be split.',
|
| 448 |
+
},
|
| 449 |
+
'Outputs': {
|
| 450 |
+
'MASK_A': 'The first group of masks',
|
| 451 |
+
'A_count': 'The number of masks in group A. This will be equal to split_index unless the mask input has length less than split_index',
|
| 452 |
+
'MASK_B': 'The second group of masks',
|
| 453 |
+
'B_count': 'The number of masks in group B'
|
| 454 |
+
},
|
| 455 |
+
'Widgets': {
|
| 456 |
+
'split_index': 'The index of the first latent that will be in the second output groups.',
|
| 457 |
+
},
|
| 458 |
+
|
| 459 |
+
}],
|
| 460 |
+
"VHS_MergeLatents": ['Merge Latents 🎥🅥🅗🅢', short_desc('Combine two groups of latents into a single group of latents'),
|
| 461 |
+
{'Inputs': {
|
| 462 |
+
'latents_A': 'The first group of latents',
|
| 463 |
+
'latents_B': 'The first group of latents',
|
| 464 |
+
},
|
| 465 |
+
'Outputs': {
|
| 466 |
+
'LATENT': 'The combined group of latents',
|
| 467 |
+
'count': 'The length of the combined group',
|
| 468 |
+
},
|
| 469 |
+
'Widgets': {
|
| 470 |
+
'merge_strategy': common_descriptions['merge_strategy'],
|
| 471 |
+
'scale_method': common_descriptions['scale_method'],
|
| 472 |
+
'crop': common_descriptions['crop_method'],
|
| 473 |
+
},
|
| 474 |
+
|
| 475 |
+
}],
|
| 476 |
+
"VHS_MergeImages": ['Merge Images 🎥🅥🅗🅢', short_desc('Combine two groups of images into a single group of images'),
|
| 477 |
+
{'Inputs': {
|
| 478 |
+
'images_A': 'The first group of images',
|
| 479 |
+
'images_B': 'The first group of images',
|
| 480 |
+
},
|
| 481 |
+
'Outputs': {
|
| 482 |
+
'IMAGE': 'The combined group of images',
|
| 483 |
+
'count': 'The length of the combined group',
|
| 484 |
+
},
|
| 485 |
+
'Widgets': {
|
| 486 |
+
'merge_strategy': common_descriptions['merge_strategy'],
|
| 487 |
+
'scale_method': common_descriptions['scale_method'],
|
| 488 |
+
'crop': common_descriptions['crop_method'],
|
| 489 |
+
},
|
| 490 |
+
|
| 491 |
+
}],
|
| 492 |
+
"VHS_MergeMasks": ['Merge Masks 🎥🅥🅗🅢', short_desc('Combine two groups of masks into a single group of masks'),
|
| 493 |
+
{'Inputs': {
|
| 494 |
+
'mask_A': 'The first group of masks',
|
| 495 |
+
'mask_B': 'The first group of masks',
|
| 496 |
+
},
|
| 497 |
+
'Outputs': {
|
| 498 |
+
'MASK': 'The combined group of masks',
|
| 499 |
+
'count': 'The length of the combined group',
|
| 500 |
+
},
|
| 501 |
+
'Widgets': {
|
| 502 |
+
'merge_strategy': common_descriptions['merge_strategy'],
|
| 503 |
+
'scale_method': common_descriptions['scale_method'],
|
| 504 |
+
'crop': common_descriptions['crop_method'],
|
| 505 |
+
},
|
| 506 |
+
|
| 507 |
+
}],
|
| 508 |
+
"VHS_GetLatentCount": format_type(common_descriptions['GetCount'], 'latent'),
|
| 509 |
+
"VHS_GetImageCount": format_type(common_descriptions['GetCount'], 'image'),
|
| 510 |
+
"VHS_GetMaskCount": format_type(common_descriptions['GetCount'], 'mask'),
|
| 511 |
+
"VHS_DuplicateLatents": ['Repeat Latents 🎥🅥🅗🅢', short_desc('Append copies of a latent to itself so it repeats'),
|
| 512 |
+
{'Inputs': {
|
| 513 |
+
'latents': 'The latents to be repeated',
|
| 514 |
+
},
|
| 515 |
+
'Outputs': {
|
| 516 |
+
'LATENT': 'The latent with repeats',
|
| 517 |
+
'count': 'The number of latents in the output. Equal to the length of the input latent * multiply_by',
|
| 518 |
+
},
|
| 519 |
+
'Widgets': {
|
| 520 |
+
'multiply_by': 'Controls the number of times the latent should repeat. 1, the default, means no change.',
|
| 521 |
+
},
|
| 522 |
+
}],
|
| 523 |
+
"VHS_DuplicateImages": ['Repeat Images 🎥🅥🅗🅢', short_desc('Append copies of a image to itself so it repeats'),
|
| 524 |
+
{'Inputs': {
|
| 525 |
+
'IMAGES': 'The image to be repeated',
|
| 526 |
+
},
|
| 527 |
+
'Outputs': {
|
| 528 |
+
'IMAGE': 'The image with repeats',
|
| 529 |
+
'count': 'The number of image in the output. Equal to the length of the input image * multiply_by',
|
| 530 |
+
},
|
| 531 |
+
'Widgets': {
|
| 532 |
+
'multiply_by': 'Controls the number of times the mask should repeat. 1, the default, means no change.',
|
| 533 |
+
},
|
| 534 |
+
}],
|
| 535 |
+
"VHS_DuplicateMasks": ['Repeat Masks 🎥🅥🅗🅢', short_desc('Append copies of a mask to itself so it repeats'),
|
| 536 |
+
{'Inputs': {
|
| 537 |
+
'masks': 'The masks to be repeated',
|
| 538 |
+
},
|
| 539 |
+
'Outputs': {
|
| 540 |
+
'LATENT': 'The mask with repeats',
|
| 541 |
+
'count': 'The number of mask in the output. Equal to the length of the input mask * multiply_by',
|
| 542 |
+
},
|
| 543 |
+
'Widgets': {
|
| 544 |
+
'multiply_by': 'Controls the number of times the mask should repeat. 1, the default, means no change.',
|
| 545 |
+
},
|
| 546 |
+
}],
|
| 547 |
+
"VHS_SelectEveryNthLatent": format_type(common_descriptions['SelectEveryNth'], 'latent'),
|
| 548 |
+
"VHS_SelectEveryNthImage": format_type(common_descriptions['SelectEveryNth'], 'image'),
|
| 549 |
+
#TODO: fix discrepency of input being mask instead of masks?
|
| 550 |
+
"VHS_SelectEveryNthMask": format_type(common_descriptions['SelectEveryNth'], 'mask', lowers='mask'),
|
| 551 |
+
#TODO: port documentation for select nodes to new system
|
| 552 |
+
#"VHS_SelectLatents": None,
|
| 553 |
+
#"VHS_SelectImages": None,
|
| 554 |
+
#"VHS_SelectMasks": None,
|
| 555 |
+
"VHS_Unbatch": ['Unbatch 🎥🅥🅗🅢', short_desc('Unbatch a list of items into a single concatenated item'),
|
| 556 |
+
"Useful for when you want a single video output from a complex workflow",
|
| 557 |
+
"Has no relation to the Meta Batch system of VHS",
|
| 558 |
+
{'Inputs': {
|
| 559 |
+
'batched': 'Any input which may or may not be batched',
|
| 560 |
+
},
|
| 561 |
+
'Outputs': {
|
| 562 |
+
'unbatched': 'A single output element. Torch tensors are concatenated across dim 0, all other types are added which functions as concatenation for strings and arrays, but may give undesired results for other types',
|
| 563 |
+
},
|
| 564 |
+
}],
|
| 565 |
+
"VHS_SelectLatest": ['Select Latest 🎥🅥🅗🅢', short_desc('Experimental virtual node to select the most recently modified file from a given folder'),
|
| 566 |
+
"Assists in the creation of workflows where outputs from one execution are used elsewhere in subsequent executions.",
|
| 567 |
+
{'Inputs': {
|
| 568 |
+
'filename_prefix': 'A path which can consist of a combination of folders and a prefix which candidate files must match',
|
| 569 |
+
'filename_postfix': 'A string which chich the selected file must end with. Useful for limiting to a target extension.',
|
| 570 |
+
},
|
| 571 |
+
'Outputs': {
|
| 572 |
+
'Filename': 'A string representing a file path to the most recently modified file.',
|
| 573 |
+
},
|
| 574 |
+
}],
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
def as_html(entry, depth=0):
|
| 578 |
+
if isinstance(entry, dict):
|
| 579 |
+
size = 0.8 if depth < 2 else 1
|
| 580 |
+
html = ''
|
| 581 |
+
for k in entry:
|
| 582 |
+
if k == "collapsed":
|
| 583 |
+
continue
|
| 584 |
+
collapse_single = k.endswith("_collapsed")
|
| 585 |
+
if collapse_single:
|
| 586 |
+
name = k[:-len("_collapsed")]
|
| 587 |
+
else:
|
| 588 |
+
name = k
|
| 589 |
+
collapse_flag = ' VHS_precollapse' if entry.get("collapsed", False) or collapse_single else ''
|
| 590 |
+
html += f'<div vhs_title=\"{name}\" style=\"display: flex; font-size: {size}em\" class=\"VHS_collapse{collapse_flag}\"><div style=\"color: #AAA; height: 1.5em;\">[<span style=\"font-family: monospace\">-</span>]</div><div style=\"width: 100%\">{name}: {as_html(entry[k], depth=depth+1)}</div></div>'
|
| 591 |
+
return html
|
| 592 |
+
if isinstance(entry, list):
|
| 593 |
+
if depth == 0:
|
| 594 |
+
depth += 1
|
| 595 |
+
size = .8
|
| 596 |
+
else:
|
| 597 |
+
size = 1
|
| 598 |
+
html = ''
|
| 599 |
+
html += entry[0]
|
| 600 |
+
for i in entry[1:]:
|
| 601 |
+
html += f'<div style=\"font-size: {size}em\">{as_html(i, depth=depth)}</div>'
|
| 602 |
+
return html
|
| 603 |
+
return str(entry)
|
| 604 |
+
|
| 605 |
+
def format_descriptions(nodes):
|
| 606 |
+
for k in descriptions:
|
| 607 |
+
if k.endswith("_collapsed"):
|
| 608 |
+
k = k[:-len("_collapsed")]
|
| 609 |
+
nodes[k].DESCRIPTION = as_html(descriptions[k])
|
| 610 |
+
undocumented_nodes = []
|
| 611 |
+
for k in nodes:
|
| 612 |
+
if not hasattr(nodes[k], "DESCRIPTION"):
|
| 613 |
+
undocumented_nodes.append(k)
|
| 614 |
+
if len(undocumented_nodes) > 0:
|
| 615 |
+
logger.warning('Some nodes have not been documented %s', undocumented_nodes)
|
| 616 |
+
|
videohelpersuite/image_latent_nodes.py
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from torch import Tensor
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
import comfy.utils
|
| 5 |
+
|
| 6 |
+
from .utils import BIGMIN, BIGMAX, select_indexes_from_str, convert_str_to_indexes, select_indexes
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class MergeStrategies:
|
| 10 |
+
MATCH_A = "match A"
|
| 11 |
+
MATCH_B = "match B"
|
| 12 |
+
MATCH_SMALLER = "match smaller"
|
| 13 |
+
MATCH_LARGER = "match larger"
|
| 14 |
+
|
| 15 |
+
list_all = [MATCH_A, MATCH_B, MATCH_SMALLER, MATCH_LARGER]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class ScaleMethods:
|
| 19 |
+
NEAREST_EXACT = "nearest-exact"
|
| 20 |
+
BILINEAR = "bilinear"
|
| 21 |
+
AREA = "area"
|
| 22 |
+
BICUBIC = "bicubic"
|
| 23 |
+
BISLERP = "bislerp"
|
| 24 |
+
|
| 25 |
+
list_all = [NEAREST_EXACT, BILINEAR, AREA, BICUBIC, BISLERP]
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class CropMethods:
|
| 29 |
+
DISABLED = "disabled"
|
| 30 |
+
CENTER = "center"
|
| 31 |
+
|
| 32 |
+
list_all = [DISABLED, CENTER]
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class SplitLatents:
|
| 36 |
+
@classmethod
|
| 37 |
+
def INPUT_TYPES(s):
|
| 38 |
+
return {
|
| 39 |
+
"required": {
|
| 40 |
+
"latents": ("LATENT",),
|
| 41 |
+
"split_index": ("INT", {"default": 0, "step": 1, "min": BIGMIN, "max": BIGMAX}),
|
| 42 |
+
},
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/latent"
|
| 46 |
+
|
| 47 |
+
RETURN_TYPES = ("LATENT", "INT", "LATENT", "INT")
|
| 48 |
+
RETURN_NAMES = ("LATENT_A", "A_count", "LATENT_B", "B_count")
|
| 49 |
+
FUNCTION = "split_latents"
|
| 50 |
+
|
| 51 |
+
def split_latents(self, latents: dict[str, Tensor], split_index: int):
|
| 52 |
+
latents_len = len(latents["samples"])
|
| 53 |
+
group_a = latents.copy()
|
| 54 |
+
group_b = latents.copy()
|
| 55 |
+
for key, val in latents.items():
|
| 56 |
+
if type(val) == Tensor and len(val) == latents_len:
|
| 57 |
+
group_a[key] = latents[key][:split_index]
|
| 58 |
+
group_b[key] = latents[key][split_index:]
|
| 59 |
+
return (group_a, group_a["samples"].size(0), group_b, group_b["samples"].size(0))
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
class SplitImages:
|
| 63 |
+
@classmethod
|
| 64 |
+
def INPUT_TYPES(s):
|
| 65 |
+
return {
|
| 66 |
+
"required": {
|
| 67 |
+
"images": ("IMAGE",),
|
| 68 |
+
"split_index": ("INT", {"default": 0, "step": 1, "min": BIGMIN, "max": BIGMAX}),
|
| 69 |
+
},
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/image"
|
| 73 |
+
|
| 74 |
+
RETURN_TYPES = ("IMAGE", "INT", "IMAGE", "INT")
|
| 75 |
+
RETURN_NAMES = ("IMAGE_A", "A_count", "IMAGE_B", "B_count")
|
| 76 |
+
FUNCTION = "split_images"
|
| 77 |
+
|
| 78 |
+
def split_images(self, images: Tensor, split_index: int):
|
| 79 |
+
group_a = images[:split_index]
|
| 80 |
+
group_b = images[split_index:]
|
| 81 |
+
return (group_a, group_a.size(0), group_b, group_b.size(0))
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
class SplitMasks:
|
| 85 |
+
@classmethod
|
| 86 |
+
def INPUT_TYPES(s):
|
| 87 |
+
return {
|
| 88 |
+
"required": {
|
| 89 |
+
"mask": ("MASK",),
|
| 90 |
+
"split_index": ("INT", {"default": 0, "step": 1, "min": BIGMIN, "max": BIGMAX}),
|
| 91 |
+
},
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/mask"
|
| 95 |
+
|
| 96 |
+
RETURN_TYPES = ("MASK", "INT", "MASK", "INT")
|
| 97 |
+
RETURN_NAMES = ("MASK_A", "A_count", "MASK_B", "B_count")
|
| 98 |
+
FUNCTION = "split_masks"
|
| 99 |
+
|
| 100 |
+
def split_masks(self, mask: Tensor, split_index: int):
|
| 101 |
+
group_a = mask[:split_index]
|
| 102 |
+
group_b = mask[split_index:]
|
| 103 |
+
return (group_a, group_a.size(0), group_b, group_b.size(0))
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class MergeLatents:
|
| 107 |
+
@classmethod
|
| 108 |
+
def INPUT_TYPES(s):
|
| 109 |
+
return {
|
| 110 |
+
"required": {
|
| 111 |
+
"latents_A": ("LATENT",),
|
| 112 |
+
"latents_B": ("LATENT",),
|
| 113 |
+
"merge_strategy": (MergeStrategies.list_all,),
|
| 114 |
+
"scale_method": (ScaleMethods.list_all,),
|
| 115 |
+
"crop": (CropMethods.list_all,),
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/latent"
|
| 120 |
+
|
| 121 |
+
RETURN_TYPES = ("LATENT", "INT",)
|
| 122 |
+
RETURN_NAMES = ("LATENT", "count",)
|
| 123 |
+
FUNCTION = "merge"
|
| 124 |
+
|
| 125 |
+
def merge(self, latents_A: dict, latents_B: dict, merge_strategy: str, scale_method: str, crop: str):
|
| 126 |
+
latents = []
|
| 127 |
+
latents_A = latents_A.copy()["samples"]
|
| 128 |
+
latents_B = latents_B.copy()["samples"]
|
| 129 |
+
|
| 130 |
+
# TODO: handle other properties on latents besides just "samples"
|
| 131 |
+
# if not same dimensions, do scaling
|
| 132 |
+
if latents_A.shape[3] != latents_B.shape[3] or latents_A.shape[2] != latents_B.shape[2]:
|
| 133 |
+
A_size = latents_A.shape[3] * latents_A.shape[2]
|
| 134 |
+
B_size = latents_B.shape[3] * latents_B.shape[2]
|
| 135 |
+
# determine which to use
|
| 136 |
+
use_A_as_template = True
|
| 137 |
+
if merge_strategy == MergeStrategies.MATCH_A:
|
| 138 |
+
pass
|
| 139 |
+
elif merge_strategy == MergeStrategies.MATCH_B:
|
| 140 |
+
use_A_as_template = False
|
| 141 |
+
elif merge_strategy in (MergeStrategies.MATCH_SMALLER, MergeStrategies.MATCH_LARGER):
|
| 142 |
+
if A_size <= B_size:
|
| 143 |
+
use_A_as_template = True if merge_strategy == MergeStrategies.MATCH_SMALLER else False
|
| 144 |
+
# apply scaling
|
| 145 |
+
if use_A_as_template:
|
| 146 |
+
latents_B = comfy.utils.common_upscale(latents_B, latents_A.shape[3], latents_A.shape[2], scale_method, crop)
|
| 147 |
+
else:
|
| 148 |
+
latents_A = comfy.utils.common_upscale(latents_A, latents_B.shape[3], latents_B.shape[2], scale_method, crop)
|
| 149 |
+
|
| 150 |
+
latents.append(latents_A)
|
| 151 |
+
latents.append(latents_B)
|
| 152 |
+
|
| 153 |
+
merged = {"samples": torch.cat(latents, dim=0)}
|
| 154 |
+
return (merged, len(merged["samples"]),)
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
class MergeImages:
|
| 158 |
+
@classmethod
|
| 159 |
+
def INPUT_TYPES(s):
|
| 160 |
+
return {
|
| 161 |
+
"required": {
|
| 162 |
+
"images_A": ("IMAGE",),
|
| 163 |
+
"images_B": ("IMAGE",),
|
| 164 |
+
"merge_strategy": (MergeStrategies.list_all,),
|
| 165 |
+
"scale_method": (ScaleMethods.list_all,),
|
| 166 |
+
"crop": (CropMethods.list_all,),
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/image"
|
| 171 |
+
|
| 172 |
+
RETURN_TYPES = ("IMAGE", "INT",)
|
| 173 |
+
RETURN_NAMES = ("IMAGE", "count",)
|
| 174 |
+
FUNCTION = "merge"
|
| 175 |
+
|
| 176 |
+
def merge(self, images_A: Tensor, images_B: Tensor, merge_strategy: str, scale_method: str, crop: str):
|
| 177 |
+
images = []
|
| 178 |
+
# if not same dimensions, do scaling
|
| 179 |
+
if images_A.shape[3] != images_B.shape[3] or images_A.shape[2] != images_B.shape[2]:
|
| 180 |
+
images_A = images_A.movedim(-1,1)
|
| 181 |
+
images_B = images_B.movedim(-1,1)
|
| 182 |
+
|
| 183 |
+
A_size = images_A.shape[3] * images_A.shape[2]
|
| 184 |
+
B_size = images_B.shape[3] * images_B.shape[2]
|
| 185 |
+
# determine which to use
|
| 186 |
+
use_A_as_template = True
|
| 187 |
+
if merge_strategy == MergeStrategies.MATCH_A:
|
| 188 |
+
pass
|
| 189 |
+
elif merge_strategy == MergeStrategies.MATCH_B:
|
| 190 |
+
use_A_as_template = False
|
| 191 |
+
elif merge_strategy in (MergeStrategies.MATCH_SMALLER, MergeStrategies.MATCH_LARGER):
|
| 192 |
+
if A_size <= B_size:
|
| 193 |
+
use_A_as_template = True if merge_strategy == MergeStrategies.MATCH_SMALLER else False
|
| 194 |
+
# apply scaling
|
| 195 |
+
if use_A_as_template:
|
| 196 |
+
images_B = comfy.utils.common_upscale(images_B, images_A.shape[3], images_A.shape[2], scale_method, crop)
|
| 197 |
+
else:
|
| 198 |
+
images_A = comfy.utils.common_upscale(images_A, images_B.shape[3], images_B.shape[2], scale_method, crop)
|
| 199 |
+
images_A = images_A.movedim(1,-1)
|
| 200 |
+
images_B = images_B.movedim(1,-1)
|
| 201 |
+
|
| 202 |
+
images.append(images_A)
|
| 203 |
+
images.append(images_B)
|
| 204 |
+
all_images = torch.cat(images, dim=0)
|
| 205 |
+
return (all_images, all_images.size(0),)
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
class MergeMasks:
|
| 209 |
+
@classmethod
|
| 210 |
+
def INPUT_TYPES(s):
|
| 211 |
+
return {
|
| 212 |
+
"required": {
|
| 213 |
+
"mask_A": ("MASK",),
|
| 214 |
+
"mask_B": ("MASK",),
|
| 215 |
+
"merge_strategy": (MergeStrategies.list_all,),
|
| 216 |
+
"scale_method": (ScaleMethods.list_all,),
|
| 217 |
+
"crop": (CropMethods.list_all,),
|
| 218 |
+
}
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/mask"
|
| 222 |
+
|
| 223 |
+
RETURN_TYPES = ("MASK", "INT",)
|
| 224 |
+
RETURN_NAMES = ("MASK", "count",)
|
| 225 |
+
FUNCTION = "merge"
|
| 226 |
+
|
| 227 |
+
def merge(self, mask_A: Tensor, mask_B: Tensor, merge_strategy: str, scale_method: str, crop: str):
|
| 228 |
+
masks = []
|
| 229 |
+
# if not same dimensions, do scaling
|
| 230 |
+
if mask_A.shape[2] != mask_B.shape[2] or mask_A.shape[1] != mask_B.shape[1]:
|
| 231 |
+
A_size = mask_A.shape[2] * mask_A.shape[1]
|
| 232 |
+
B_size = mask_B.shape[2] * mask_B.shape[1]
|
| 233 |
+
# determine which to use
|
| 234 |
+
use_A_as_template = True
|
| 235 |
+
if merge_strategy == MergeStrategies.MATCH_A:
|
| 236 |
+
pass
|
| 237 |
+
elif merge_strategy == MergeStrategies.MATCH_B:
|
| 238 |
+
use_A_as_template = False
|
| 239 |
+
elif merge_strategy in (MergeStrategies.MATCH_SMALLER, MergeStrategies.MATCH_LARGER):
|
| 240 |
+
if A_size <= B_size:
|
| 241 |
+
use_A_as_template = True if merge_strategy == MergeStrategies.MATCH_SMALLER else False
|
| 242 |
+
# add dimension where image channels would be expected to work with common_upscale
|
| 243 |
+
mask_A = torch.unsqueeze(mask_A, 1)
|
| 244 |
+
mask_B = torch.unsqueeze(mask_B, 1)
|
| 245 |
+
# apply scaling
|
| 246 |
+
if use_A_as_template:
|
| 247 |
+
mask_B = comfy.utils.common_upscale(mask_B, mask_A.shape[3], mask_A.shape[2], scale_method, crop)
|
| 248 |
+
else:
|
| 249 |
+
mask_A = comfy.utils.common_upscale(mask_A, mask_B.shape[3], mask_B.shape[2], scale_method, crop)
|
| 250 |
+
# undo dimension increase
|
| 251 |
+
mask_A = torch.squeeze(mask_A, 1)
|
| 252 |
+
mask_B = torch.squeeze(mask_B, 1)
|
| 253 |
+
|
| 254 |
+
masks.append(mask_A)
|
| 255 |
+
masks.append(mask_B)
|
| 256 |
+
all_masks = torch.cat(masks, dim=0)
|
| 257 |
+
return (all_masks, all_masks.size(0),)
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
class SelectEveryNthLatent:
|
| 261 |
+
@classmethod
|
| 262 |
+
def INPUT_TYPES(s):
|
| 263 |
+
return {
|
| 264 |
+
"required": {
|
| 265 |
+
"latents": ("LATENT",),
|
| 266 |
+
"select_every_nth": ("INT", {"default": 1, "min": 1, "max": BIGMAX, "step": 1}),
|
| 267 |
+
"skip_first_latents": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1}),
|
| 268 |
+
},
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/latent"
|
| 272 |
+
|
| 273 |
+
RETURN_TYPES = ("LATENT", "INT",)
|
| 274 |
+
RETURN_NAMES = ("LATENT", "count",)
|
| 275 |
+
FUNCTION = "select_latents"
|
| 276 |
+
|
| 277 |
+
def select_latents(self, latents: dict[str, Tensor], select_every_nth: int, skip_first_latents: int):
|
| 278 |
+
latents = latents.copy()
|
| 279 |
+
latents_len = len(latents["samples"])
|
| 280 |
+
for key, val in latents.items():
|
| 281 |
+
if type(val) == Tensor and len(val) == latents_len:
|
| 282 |
+
latents[key] = val[skip_first_latents::select_every_nth]
|
| 283 |
+
return (latents, latents["samples"].size(0))
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
class SelectEveryNthImage:
|
| 287 |
+
@classmethod
|
| 288 |
+
def INPUT_TYPES(s):
|
| 289 |
+
return {
|
| 290 |
+
"required": {
|
| 291 |
+
"images": ("IMAGE",),
|
| 292 |
+
"select_every_nth": ("INT", {"default": 1, "min": 1, "max": BIGMAX, "step": 1}),
|
| 293 |
+
"skip_first_images": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1}),
|
| 294 |
+
|
| 295 |
+
},
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/image"
|
| 299 |
+
|
| 300 |
+
RETURN_TYPES = ("IMAGE", "INT",)
|
| 301 |
+
RETURN_NAMES = ("IMAGE", "count",)
|
| 302 |
+
FUNCTION = "select_images"
|
| 303 |
+
|
| 304 |
+
def select_images(self, images: Tensor, select_every_nth: int, skip_first_images: int):
|
| 305 |
+
sub_images = images[skip_first_images::select_every_nth]
|
| 306 |
+
return (sub_images, sub_images.size(0))
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
class SelectEveryNthMask:
|
| 310 |
+
@classmethod
|
| 311 |
+
def INPUT_TYPES(s):
|
| 312 |
+
return {
|
| 313 |
+
"required": {
|
| 314 |
+
"mask": ("MASK",),
|
| 315 |
+
"select_every_nth": ("INT", {"default": 1, "min": 1, "max": BIGMAX, "step": 1}),
|
| 316 |
+
"skip_first_masks": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1}),
|
| 317 |
+
},
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/mask"
|
| 321 |
+
|
| 322 |
+
RETURN_TYPES = ("MASK", "INT",)
|
| 323 |
+
RETURN_NAMES = ("MASK", "count",)
|
| 324 |
+
FUNCTION = "select_masks"
|
| 325 |
+
|
| 326 |
+
def select_masks(self, mask: Tensor, select_every_nth: int, skip_first_masks: int):
|
| 327 |
+
sub_mask = mask[skip_first_masks::select_every_nth]
|
| 328 |
+
return (sub_mask, sub_mask.size(0))
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
class GetLatentCount:
|
| 332 |
+
@classmethod
|
| 333 |
+
def INPUT_TYPES(s):
|
| 334 |
+
return {
|
| 335 |
+
"required": {
|
| 336 |
+
"latents": ("LATENT",),
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/latent"
|
| 341 |
+
|
| 342 |
+
RETURN_TYPES = ("INT",)
|
| 343 |
+
RETURN_NAMES = ("count",)
|
| 344 |
+
FUNCTION = "count_input"
|
| 345 |
+
|
| 346 |
+
def count_input(self, latents: dict):
|
| 347 |
+
return (latents["samples"].size(0),)
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
class GetImageCount:
|
| 351 |
+
@classmethod
|
| 352 |
+
def INPUT_TYPES(s):
|
| 353 |
+
return {
|
| 354 |
+
"required": {
|
| 355 |
+
"images": ("IMAGE",),
|
| 356 |
+
}
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/image"
|
| 360 |
+
|
| 361 |
+
RETURN_TYPES = ("INT",)
|
| 362 |
+
RETURN_NAMES = ("count",)
|
| 363 |
+
FUNCTION = "count_input"
|
| 364 |
+
|
| 365 |
+
def count_input(self, images: Tensor):
|
| 366 |
+
return (images.size(0),)
|
| 367 |
+
|
| 368 |
+
|
| 369 |
+
class GetMaskCount:
|
| 370 |
+
@classmethod
|
| 371 |
+
def INPUT_TYPES(s):
|
| 372 |
+
return {
|
| 373 |
+
"required": {
|
| 374 |
+
"mask": ("MASK",),
|
| 375 |
+
}
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/mask"
|
| 379 |
+
|
| 380 |
+
RETURN_TYPES = ("INT",)
|
| 381 |
+
RETURN_NAMES = ("count",)
|
| 382 |
+
FUNCTION = "count_input"
|
| 383 |
+
|
| 384 |
+
def count_input(self, mask: Tensor):
|
| 385 |
+
return (mask.size(0),)
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
class RepeatLatents:
|
| 389 |
+
@classmethod
|
| 390 |
+
def INPUT_TYPES(s):
|
| 391 |
+
return {
|
| 392 |
+
"required": {
|
| 393 |
+
"latents": ("LATENT",),
|
| 394 |
+
"multiply_by": ("INT", {"default": 1, "min": 1, "max": BIGMAX, "step": 1})
|
| 395 |
+
}
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/latent"
|
| 399 |
+
|
| 400 |
+
RETURN_TYPES = ("LATENT", "INT",)
|
| 401 |
+
RETURN_NAMES = ("LATENT", "count",)
|
| 402 |
+
FUNCTION = "duplicate_input"
|
| 403 |
+
|
| 404 |
+
def duplicate_input(self, latents: dict[str, Tensor], multiply_by: int):
|
| 405 |
+
latents = latents.copy()
|
| 406 |
+
latents_len = len(latents["samples"])
|
| 407 |
+
for key, val in latents.items():
|
| 408 |
+
if type(val) == Tensor and len(val) == latents_len:
|
| 409 |
+
full_latents = []
|
| 410 |
+
for _ in range(0, multiply_by):
|
| 411 |
+
full_latents.append(latents[key])
|
| 412 |
+
latents[key] = torch.cat(full_latents, dim=0)
|
| 413 |
+
return (latents, latents["samples"].size(0),)
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
class RepeatImages:
|
| 417 |
+
@classmethod
|
| 418 |
+
def INPUT_TYPES(s):
|
| 419 |
+
return {
|
| 420 |
+
"required": {
|
| 421 |
+
"images": ("IMAGE",),
|
| 422 |
+
"multiply_by": ("INT", {"default": 1, "min": 1, "max": BIGMAX, "step": 1})
|
| 423 |
+
}
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/image"
|
| 427 |
+
|
| 428 |
+
RETURN_TYPES = ("IMAGE", "INT",)
|
| 429 |
+
RETURN_NAMES = ("IMAGE", "count",)
|
| 430 |
+
FUNCTION = "duplicate_input"
|
| 431 |
+
|
| 432 |
+
def duplicate_input(self, images: Tensor, multiply_by: int):
|
| 433 |
+
full_images = []
|
| 434 |
+
for n in range(0, multiply_by):
|
| 435 |
+
full_images.append(images)
|
| 436 |
+
new_images = torch.cat(full_images, dim=0)
|
| 437 |
+
return (new_images, new_images.size(0),)
|
| 438 |
+
|
| 439 |
+
|
| 440 |
+
class RepeatMasks:
|
| 441 |
+
@classmethod
|
| 442 |
+
def INPUT_TYPES(s):
|
| 443 |
+
return {
|
| 444 |
+
"required": {
|
| 445 |
+
"mask": ("MASK",),
|
| 446 |
+
"multiply_by": ("INT", {"default": 1, "min": 1, "max": BIGMAX, "step": 1})
|
| 447 |
+
}
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/mask"
|
| 451 |
+
|
| 452 |
+
RETURN_TYPES = ("MASK", "INT",)
|
| 453 |
+
RETURN_NAMES = ("MASK", "count",)
|
| 454 |
+
FUNCTION = "duplicate_input"
|
| 455 |
+
|
| 456 |
+
def duplicate_input(self, mask: Tensor, multiply_by: int):
|
| 457 |
+
full_masks = []
|
| 458 |
+
for n in range(0, multiply_by):
|
| 459 |
+
full_masks.append(mask)
|
| 460 |
+
new_mask = torch.cat(full_masks, dim=0)
|
| 461 |
+
return (new_mask, new_mask.size(0),)
|
| 462 |
+
|
| 463 |
+
|
| 464 |
+
select_description = """Use comma-separated indexes to select items in the given order.
|
| 465 |
+
Supports negative indexes, python-style ranges (end index excluded),
|
| 466 |
+
as well as range step.
|
| 467 |
+
|
| 468 |
+
Acceptable entries (assuming 16 items provided, so idxs 0 to 15 exist):
|
| 469 |
+
0 -> Returns [0]
|
| 470 |
+
-1 -> Returns [15]
|
| 471 |
+
0, 1, 13 -> Returns [0, 1, 13]
|
| 472 |
+
0:5, 13 -> Returns [0, 1, 2, 3, 4, 13]
|
| 473 |
+
0:-1 -> Returns [0, 1, 2, ..., 13, 14]
|
| 474 |
+
0:5:-1 -> Returns [4, 3, 2, 1, 0]
|
| 475 |
+
0:5:2 -> Returns [0, 2, 4]
|
| 476 |
+
::-1 -> Returns [15, 14, 13, ..., 2, 1, 0]
|
| 477 |
+
"""
|
| 478 |
+
class SelectLatents:
|
| 479 |
+
@classmethod
|
| 480 |
+
def INPUT_TYPES(s):
|
| 481 |
+
return {
|
| 482 |
+
"required": {
|
| 483 |
+
"latent": ("LATENT",),
|
| 484 |
+
"indexes": ("STRING", {"default": "0"}),
|
| 485 |
+
"err_if_missing": ("BOOLEAN", {"default": True}),
|
| 486 |
+
"err_if_empty": ("BOOLEAN", {"default": True}),
|
| 487 |
+
},
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
DESCRIPTION = select_description
|
| 491 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/latent"
|
| 492 |
+
|
| 493 |
+
RETURN_TYPES = ("LATENT",)
|
| 494 |
+
FUNCTION = "select"
|
| 495 |
+
|
| 496 |
+
def select(self, latent: dict[str, Tensor], indexes: str, err_if_missing: bool, err_if_empty: bool):
|
| 497 |
+
# latents are a dict and may contain different stuff (like noise_mask), so need to account for it all
|
| 498 |
+
latent = latent.copy()
|
| 499 |
+
latents_len = len(latent["samples"])
|
| 500 |
+
real_idxs = convert_str_to_indexes(indexes, latents_len, allow_missing=not err_if_missing)
|
| 501 |
+
if err_if_empty and len(real_idxs) == 0:
|
| 502 |
+
raise Exception(f"Nothing was selected based on indexes found in '{indexes}'.")
|
| 503 |
+
for key, val in latent.items():
|
| 504 |
+
if type(val) == Tensor and len(val) == latents_len:
|
| 505 |
+
latent[key] = select_indexes(val, real_idxs)
|
| 506 |
+
return (latent,)
|
| 507 |
+
|
| 508 |
+
|
| 509 |
+
class SelectImages:
|
| 510 |
+
@classmethod
|
| 511 |
+
def INPUT_TYPES(s):
|
| 512 |
+
return {
|
| 513 |
+
"required": {
|
| 514 |
+
"image": ("IMAGE",),
|
| 515 |
+
"indexes": ("STRING", {"default": "0"}),
|
| 516 |
+
"err_if_missing": ("BOOLEAN", {"default": True}),
|
| 517 |
+
"err_if_empty": ("BOOLEAN", {"default": True}),
|
| 518 |
+
},
|
| 519 |
+
}
|
| 520 |
+
|
| 521 |
+
DESCRIPTION = select_description
|
| 522 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/image"
|
| 523 |
+
|
| 524 |
+
RETURN_TYPES = ("IMAGE",)
|
| 525 |
+
FUNCTION = "select"
|
| 526 |
+
|
| 527 |
+
def select(self, image: Tensor, indexes: str, err_if_missing: bool, err_if_empty: bool):
|
| 528 |
+
to_return = select_indexes_from_str(input_obj=image, indexes=indexes,
|
| 529 |
+
err_if_missing=err_if_missing, err_if_empty=err_if_empty)
|
| 530 |
+
to_return_type = type(to_return)
|
| 531 |
+
return (to_return,)
|
| 532 |
+
|
| 533 |
+
|
| 534 |
+
class SelectMasks:
|
| 535 |
+
@classmethod
|
| 536 |
+
def INPUT_TYPES(s):
|
| 537 |
+
return {
|
| 538 |
+
"required": {
|
| 539 |
+
"mask": ("MASK",),
|
| 540 |
+
"indexes": ("STRING", {"default": "0"}),
|
| 541 |
+
"err_if_missing": ("BOOLEAN", {"default": True}),
|
| 542 |
+
"err_if_empty": ("BOOLEAN", {"default": True}),
|
| 543 |
+
},
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
DESCRIPTION = select_description
|
| 547 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/mask"
|
| 548 |
+
|
| 549 |
+
RETURN_TYPES = ("MASK",)
|
| 550 |
+
FUNCTION = "select"
|
| 551 |
+
|
| 552 |
+
def select(self, mask: Tensor, indexes: str, err_if_missing: bool, err_if_empty: bool):
|
| 553 |
+
return (select_indexes_from_str(input_obj=mask, indexes=indexes,
|
| 554 |
+
err_if_missing=err_if_missing, err_if_empty=err_if_empty),)
|
videohelpersuite/latent_preview.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image
|
| 2 |
+
import time
|
| 3 |
+
import io
|
| 4 |
+
import struct
|
| 5 |
+
from threading import Thread
|
| 6 |
+
import torch.nn.functional as F
|
| 7 |
+
import torch
|
| 8 |
+
|
| 9 |
+
import latent_preview
|
| 10 |
+
import server
|
| 11 |
+
serv = server.PromptServer.instance
|
| 12 |
+
|
| 13 |
+
from .utils import hook
|
| 14 |
+
|
| 15 |
+
rates_table = {'Mochi': 24//6, 'LTXV': 24//8, 'HunyuanVideo': 24//4,
|
| 16 |
+
'Cosmos1CV8x8x8': 24//8, 'Wan21': 16//4, 'Wan22': 24//4}
|
| 17 |
+
|
| 18 |
+
class WrappedPreviewer(latent_preview.LatentPreviewer):
|
| 19 |
+
def __init__(self, previewer, rate=8):
|
| 20 |
+
self.first_preview = True
|
| 21 |
+
self.last_time = 0
|
| 22 |
+
self.c_index = 0
|
| 23 |
+
self.rate = rate
|
| 24 |
+
if hasattr(previewer, 'taesd'):
|
| 25 |
+
self.taesd = previewer.taesd
|
| 26 |
+
elif hasattr(previewer, 'latent_rgb_factors'):
|
| 27 |
+
self.latent_rgb_factors = previewer.latent_rgb_factors
|
| 28 |
+
self.latent_rgb_factors_bias = previewer.latent_rgb_factors_bias
|
| 29 |
+
else:
|
| 30 |
+
raise Exception('Unsupported preview type for VHS animated previews')
|
| 31 |
+
|
| 32 |
+
def decode_latent_to_preview_image(self, preview_format, x0):
|
| 33 |
+
if x0.ndim == 5:
|
| 34 |
+
#Keep batch major
|
| 35 |
+
x0 = x0.movedim(2,1)
|
| 36 |
+
x0 = x0.reshape((-1,)+x0.shape[-3:])
|
| 37 |
+
num_images = x0.size(0)
|
| 38 |
+
new_time = time.time()
|
| 39 |
+
num_previews = int((new_time - self.last_time) * self.rate)
|
| 40 |
+
self.last_time = self.last_time + num_previews/self.rate
|
| 41 |
+
if num_previews > num_images:
|
| 42 |
+
num_previews = num_images
|
| 43 |
+
elif num_previews <= 0:
|
| 44 |
+
return None
|
| 45 |
+
if self.first_preview:
|
| 46 |
+
self.first_preview = False
|
| 47 |
+
serv.send_sync('VHS_latentpreview', {'length':num_images, 'rate': self.rate, 'id': serv.last_node_id})
|
| 48 |
+
self.last_time = new_time + 1/self.rate
|
| 49 |
+
if self.c_index + num_previews > num_images:
|
| 50 |
+
x0 = x0.roll(-self.c_index, 0)[:num_previews]
|
| 51 |
+
else:
|
| 52 |
+
x0 = x0[self.c_index:self.c_index + num_previews]
|
| 53 |
+
Thread(target=self.process_previews, args=(x0, self.c_index,
|
| 54 |
+
num_images)).run()
|
| 55 |
+
self.c_index = (self.c_index + num_previews) % num_images
|
| 56 |
+
return None
|
| 57 |
+
def process_previews(self, image_tensor, ind, leng):
|
| 58 |
+
image_tensor = self.decode_latent_to_preview(image_tensor)
|
| 59 |
+
if image_tensor.size(1) > 512 or image_tensor.size(2) > 512:
|
| 60 |
+
image_tensor = image_tensor.movedim(-1,0)
|
| 61 |
+
if image_tensor.size(2) < image_tensor.size(3):
|
| 62 |
+
height = (512 * image_tensor.size(2)) // image_tensor.size(3)
|
| 63 |
+
image_tensor = F.interpolate(image_tensor, (height,512), mode='bilinear')
|
| 64 |
+
else:
|
| 65 |
+
width = (512 * image_tensor.size(3)) // image_tensor.size(2)
|
| 66 |
+
image_tensor = F.interpolate(image_tensor, (512, width), mode='bilinear')
|
| 67 |
+
image_tensor = image_tensor.movedim(0,-1)
|
| 68 |
+
previews_ubyte = (((image_tensor + 1.0) / 2.0).clamp(0, 1) # change scale from -1..1 to 0..1
|
| 69 |
+
.mul(0xFF) # to 0..255
|
| 70 |
+
).to(device="cpu", dtype=torch.uint8)
|
| 71 |
+
for preview in previews_ubyte:
|
| 72 |
+
i = Image.fromarray(preview.numpy())
|
| 73 |
+
message = io.BytesIO()
|
| 74 |
+
message.write((1).to_bytes(length=4, byteorder='big')*2)
|
| 75 |
+
message.write(ind.to_bytes(length=4, byteorder='big'))
|
| 76 |
+
message.write(struct.pack('16p', serv.last_node_id.encode('ascii')))
|
| 77 |
+
i.save(message, format="JPEG", quality=95, compress_level=1)
|
| 78 |
+
#NOTE: send sync already uses call_soon_threadsafe
|
| 79 |
+
serv.send_sync(server.BinaryEventTypes.PREVIEW_IMAGE,
|
| 80 |
+
message.getvalue(), serv.client_id)
|
| 81 |
+
ind = (ind + 1) % leng
|
| 82 |
+
def decode_latent_to_preview(self, x0):
|
| 83 |
+
if hasattr(self, 'taesd'):
|
| 84 |
+
x_sample = self.taesd.decode(x0).movedim(1, 3)
|
| 85 |
+
return x_sample
|
| 86 |
+
else:
|
| 87 |
+
self.latent_rgb_factors = self.latent_rgb_factors.to(dtype=x0.dtype, device=x0.device)
|
| 88 |
+
if self.latent_rgb_factors_bias is not None:
|
| 89 |
+
self.latent_rgb_factors_bias = self.latent_rgb_factors_bias.to(dtype=x0.dtype, device=x0.device)
|
| 90 |
+
latent_image = F.linear(x0.movedim(1, -1), self.latent_rgb_factors,
|
| 91 |
+
bias=self.latent_rgb_factors_bias)
|
| 92 |
+
return latent_image
|
| 93 |
+
|
| 94 |
+
@hook(latent_preview, 'get_previewer')
|
| 95 |
+
def get_latent_video_previewer(device, latent_format, *args, **kwargs):
|
| 96 |
+
node_id = serv.last_node_id
|
| 97 |
+
previewer = get_latent_video_previewer.__wrapped__(device, latent_format, *args, **kwargs)
|
| 98 |
+
try:
|
| 99 |
+
extra_info = next(serv.prompt_queue.currently_running.values().__iter__()) \
|
| 100 |
+
[3]['extra_pnginfo']['workflow']['extra']
|
| 101 |
+
prev_setting = extra_info.get('VHS_latentpreview', False)
|
| 102 |
+
if extra_info.get('VHS_latentpreviewrate', 0) != 0:
|
| 103 |
+
rate_setting = extra_info['VHS_latentpreviewrate']
|
| 104 |
+
else:
|
| 105 |
+
rate_setting = rates_table.get(latent_format.__class__.__name__, 8)
|
| 106 |
+
except:
|
| 107 |
+
#For safety since there's lots of keys, any of which can fail
|
| 108 |
+
prev_setting = False
|
| 109 |
+
if not prev_setting or not hasattr(previewer, "decode_latent_to_preview"):
|
| 110 |
+
return previewer
|
| 111 |
+
return WrappedPreviewer(previewer, rate_setting)
|
videohelpersuite/load_images_nodes.py
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import hashlib
|
| 3 |
+
import numpy as np
|
| 4 |
+
import torch
|
| 5 |
+
from PIL import Image, ImageOps
|
| 6 |
+
import itertools
|
| 7 |
+
|
| 8 |
+
import folder_paths
|
| 9 |
+
from comfy.k_diffusion.utils import FolderOfImages
|
| 10 |
+
from comfy.utils import common_upscale, ProgressBar
|
| 11 |
+
from .logger import logger
|
| 12 |
+
from .utils import BIGMAX, calculate_file_hash, get_sorted_dir_files_from_directory, validate_path, strip_path
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def is_changed_load_images(directory: str, image_load_cap: int = 0, skip_first_images: int = 0, select_every_nth: int = 1, **kwargs):
|
| 16 |
+
if not os.path.isdir(directory):
|
| 17 |
+
return False
|
| 18 |
+
|
| 19 |
+
dir_files = get_sorted_dir_files_from_directory(directory, skip_first_images, select_every_nth, FolderOfImages.IMG_EXTENSIONS)
|
| 20 |
+
if image_load_cap != 0:
|
| 21 |
+
dir_files = dir_files[:image_load_cap]
|
| 22 |
+
|
| 23 |
+
m = hashlib.sha256()
|
| 24 |
+
for filepath in dir_files:
|
| 25 |
+
m.update(calculate_file_hash(filepath).encode()) # strings must be encoded before hashing
|
| 26 |
+
return m.digest().hex()
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def validate_load_images(directory: str):
|
| 30 |
+
if not os.path.isdir(directory):
|
| 31 |
+
return f"Directory '{directory}' cannot be found."
|
| 32 |
+
dir_files = os.listdir(directory)
|
| 33 |
+
if len(dir_files) == 0:
|
| 34 |
+
return f"No files in directory '{directory}'."
|
| 35 |
+
|
| 36 |
+
return True
|
| 37 |
+
|
| 38 |
+
def images_generator(directory: str, image_load_cap: int = 0, skip_first_images: int = 0, select_every_nth: int = 1, meta_batch=None, unique_id=None):
|
| 39 |
+
if not os.path.isdir(directory):
|
| 40 |
+
raise FileNotFoundError(f"Directory '{directory} cannot be found.")
|
| 41 |
+
dir_files = get_sorted_dir_files_from_directory(directory, skip_first_images, select_every_nth, FolderOfImages.IMG_EXTENSIONS)
|
| 42 |
+
|
| 43 |
+
if len(dir_files) == 0:
|
| 44 |
+
raise FileNotFoundError(f"No files in directory '{directory}'.")
|
| 45 |
+
if image_load_cap > 0:
|
| 46 |
+
dir_files = dir_files[:image_load_cap]
|
| 47 |
+
sizes = {}
|
| 48 |
+
has_alpha = False
|
| 49 |
+
for image_path in dir_files:
|
| 50 |
+
i = Image.open(image_path)
|
| 51 |
+
#exif_transpose can only ever rotate, but rotating can swap width/height
|
| 52 |
+
i = ImageOps.exif_transpose(i)
|
| 53 |
+
has_alpha |= 'A' in i.getbands()
|
| 54 |
+
count = sizes.get(i.size, 0)
|
| 55 |
+
sizes[i.size] = count +1
|
| 56 |
+
size = max(sizes.items(), key=lambda x: x[1])[0]
|
| 57 |
+
yield size[0], size[1], has_alpha
|
| 58 |
+
if meta_batch is not None:
|
| 59 |
+
yield min(image_load_cap, len(dir_files)) or len(dir_files)
|
| 60 |
+
|
| 61 |
+
iformat = "RGBA" if has_alpha else "RGB"
|
| 62 |
+
def load_image(file_path):
|
| 63 |
+
i = Image.open(file_path)
|
| 64 |
+
i = ImageOps.exif_transpose(i)
|
| 65 |
+
i = i.convert(iformat)
|
| 66 |
+
i = np.array(i, dtype=np.float32)
|
| 67 |
+
#This nonsense provides a nearly 50% speedup on my system
|
| 68 |
+
torch.from_numpy(i).div_(255)
|
| 69 |
+
if i.shape[0] != size[1] or i.shape[1] != size[0]:
|
| 70 |
+
i = torch.from_numpy(i).movedim(-1, 0).unsqueeze(0)
|
| 71 |
+
i = common_upscale(i, size[0], size[1], "lanczos", "center")
|
| 72 |
+
i = i.squeeze(0).movedim(0, -1).numpy()
|
| 73 |
+
if has_alpha:
|
| 74 |
+
i[:,:,-1] = 1 - i[:,:,-1]
|
| 75 |
+
return i
|
| 76 |
+
|
| 77 |
+
total_images = len(dir_files)
|
| 78 |
+
processed_images = 0
|
| 79 |
+
pbar = ProgressBar(total_images)
|
| 80 |
+
images = map(load_image, dir_files)
|
| 81 |
+
try:
|
| 82 |
+
prev_image = next(images)
|
| 83 |
+
while True:
|
| 84 |
+
next_image = next(images)
|
| 85 |
+
yield prev_image
|
| 86 |
+
processed_images += 1
|
| 87 |
+
pbar.update_absolute(processed_images, total_images)
|
| 88 |
+
prev_image = next_image
|
| 89 |
+
except StopIteration:
|
| 90 |
+
pass
|
| 91 |
+
if meta_batch is not None:
|
| 92 |
+
meta_batch.inputs.pop(unique_id)
|
| 93 |
+
meta_batch.has_closed_inputs = True
|
| 94 |
+
if prev_image is not None:
|
| 95 |
+
yield prev_image
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def load_images(directory: str, image_load_cap: int = 0, skip_first_images: int = 0, select_every_nth: int = 1, meta_batch=None, unique_id=None):
|
| 99 |
+
if meta_batch is None or unique_id not in meta_batch.inputs:
|
| 100 |
+
gen = images_generator(directory, image_load_cap, skip_first_images, select_every_nth, meta_batch, unique_id)
|
| 101 |
+
(width, height, has_alpha) = next(gen)
|
| 102 |
+
if meta_batch is not None:
|
| 103 |
+
meta_batch.inputs[unique_id] = (gen, width, height, has_alpha)
|
| 104 |
+
meta_batch.total_frames = min(meta_batch.total_frames, next(gen))
|
| 105 |
+
else:
|
| 106 |
+
gen, width, height, has_alpha = meta_batch.inputs[unique_id]
|
| 107 |
+
|
| 108 |
+
if meta_batch is not None:
|
| 109 |
+
gen = itertools.islice(gen, meta_batch.frames_per_batch)
|
| 110 |
+
images = torch.from_numpy(np.fromiter(gen, np.dtype((np.float32, (height, width, 3 + has_alpha)))))
|
| 111 |
+
if has_alpha:
|
| 112 |
+
#tensors are not continuous. Rewrite will be required if this is an issue
|
| 113 |
+
masks = images[:,:,:,3]
|
| 114 |
+
images = images[:,:,:,:3]
|
| 115 |
+
else:
|
| 116 |
+
masks = torch.zeros((images.size(0), 64, 64), dtype=torch.float32, device="cpu")
|
| 117 |
+
if len(images) == 0:
|
| 118 |
+
raise FileNotFoundError(f"No images could be loaded from directory '{directory}'.")
|
| 119 |
+
return images, masks, images.size(0)
|
| 120 |
+
|
| 121 |
+
class LoadImagesFromDirectoryUpload:
|
| 122 |
+
@classmethod
|
| 123 |
+
def INPUT_TYPES(s):
|
| 124 |
+
input_dir = folder_paths.get_input_directory()
|
| 125 |
+
directories = []
|
| 126 |
+
for item in os.listdir(input_dir):
|
| 127 |
+
if not os.path.isfile(os.path.join(input_dir, item)) and item != "clipspace":
|
| 128 |
+
directories.append(item)
|
| 129 |
+
return {
|
| 130 |
+
"required": {
|
| 131 |
+
"directory": (directories,),
|
| 132 |
+
},
|
| 133 |
+
"optional": {
|
| 134 |
+
"image_load_cap": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1}),
|
| 135 |
+
"skip_first_images": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1}),
|
| 136 |
+
"select_every_nth": ("INT", {"default": 1, "min": 1, "max": BIGMAX, "step": 1}),
|
| 137 |
+
"meta_batch": ("VHS_BatchManager",),
|
| 138 |
+
},
|
| 139 |
+
"hidden": {
|
| 140 |
+
"unique_id": "UNIQUE_ID"
|
| 141 |
+
},
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
RETURN_TYPES = ("IMAGE", "MASK", "INT")
|
| 145 |
+
RETURN_NAMES = ("IMAGE", "MASK", "frame_count")
|
| 146 |
+
FUNCTION = "load_images"
|
| 147 |
+
|
| 148 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 149 |
+
|
| 150 |
+
def load_images(self, directory: str, **kwargs):
|
| 151 |
+
directory = folder_paths.get_annotated_filepath(strip_path(directory))
|
| 152 |
+
return load_images(directory, **kwargs)
|
| 153 |
+
|
| 154 |
+
@classmethod
|
| 155 |
+
def IS_CHANGED(s, directory: str, **kwargs):
|
| 156 |
+
directory = folder_paths.get_annotated_filepath(strip_path(directory))
|
| 157 |
+
return is_changed_load_images(directory, **kwargs)
|
| 158 |
+
|
| 159 |
+
@classmethod
|
| 160 |
+
def VALIDATE_INPUTS(s, directory: str, **kwargs):
|
| 161 |
+
directory = folder_paths.get_annotated_filepath(strip_path(directory))
|
| 162 |
+
return validate_load_images(directory)
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
class LoadImagesFromDirectoryPath:
|
| 166 |
+
@classmethod
|
| 167 |
+
def INPUT_TYPES(s):
|
| 168 |
+
return {
|
| 169 |
+
"required": {
|
| 170 |
+
"directory": ("STRING", {"placeholder": "X://path/to/images", "vhs_path_extensions": []}),
|
| 171 |
+
},
|
| 172 |
+
"optional": {
|
| 173 |
+
"image_load_cap": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1}),
|
| 174 |
+
"skip_first_images": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1}),
|
| 175 |
+
"select_every_nth": ("INT", {"default": 1, "min": 1, "max": BIGMAX, "step": 1}),
|
| 176 |
+
"meta_batch": ("VHS_BatchManager",),
|
| 177 |
+
},
|
| 178 |
+
"hidden": {
|
| 179 |
+
"unique_id": "UNIQUE_ID"
|
| 180 |
+
},
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
RETURN_TYPES = ("IMAGE", "MASK", "INT")
|
| 184 |
+
RETURN_NAMES = ("IMAGE", "MASK", "frame_count")
|
| 185 |
+
FUNCTION = "load_images"
|
| 186 |
+
|
| 187 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 188 |
+
|
| 189 |
+
def load_images(self, directory: str, **kwargs):
|
| 190 |
+
directory = strip_path(directory)
|
| 191 |
+
if directory is None or validate_load_images(directory) != True:
|
| 192 |
+
raise Exception("directory is not valid: " + directory)
|
| 193 |
+
|
| 194 |
+
return load_images(directory, **kwargs)
|
| 195 |
+
|
| 196 |
+
@classmethod
|
| 197 |
+
def IS_CHANGED(s, directory: str, **kwargs):
|
| 198 |
+
if directory is None:
|
| 199 |
+
return "input"
|
| 200 |
+
return is_changed_load_images(directory, **kwargs)
|
| 201 |
+
|
| 202 |
+
@classmethod
|
| 203 |
+
def VALIDATE_INPUTS(s, directory: str, **kwargs):
|
| 204 |
+
if directory is None:
|
| 205 |
+
return True
|
| 206 |
+
return validate_load_images(strip_path(directory))
|
videohelpersuite/load_video_nodes.py
ADDED
|
@@ -0,0 +1,671 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import itertools
|
| 3 |
+
import numpy as np
|
| 4 |
+
import torch
|
| 5 |
+
from PIL import Image, ImageOps
|
| 6 |
+
import cv2
|
| 7 |
+
import psutil
|
| 8 |
+
import subprocess
|
| 9 |
+
import re
|
| 10 |
+
import time
|
| 11 |
+
|
| 12 |
+
import folder_paths
|
| 13 |
+
from comfy.utils import common_upscale, ProgressBar
|
| 14 |
+
import nodes
|
| 15 |
+
from comfy.k_diffusion.utils import FolderOfImages
|
| 16 |
+
from .logger import logger
|
| 17 |
+
from .utils import BIGMAX, DIMMAX, calculate_file_hash, get_sorted_dir_files_from_directory,\
|
| 18 |
+
lazy_get_audio, hash_path, validate_path, strip_path, try_download_video, \
|
| 19 |
+
is_url, imageOrLatent, ffmpeg_path, ENCODE_ARGS, floatOrInt
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
video_extensions = ['webm', 'mp4', 'mkv', 'gif', 'mov']
|
| 23 |
+
|
| 24 |
+
VHSLoadFormats = {
|
| 25 |
+
'None': {},
|
| 26 |
+
'AnimateDiff': {'target_rate': 8, 'dim': (8,0,512,512)},
|
| 27 |
+
'Mochi': {'target_rate': 24, 'dim': (16,0,848,480), 'frames':(6,1)},
|
| 28 |
+
'LTXV': {'target_rate': 24, 'dim': (32,0,768,512), 'frames':(8,1)},
|
| 29 |
+
'Hunyuan': {'target_rate': 24, 'dim': (16,0,848,480), 'frames':(4,1)},
|
| 30 |
+
'Cosmos': {'target_rate': 24, 'dim': (16,0,1280,704), 'frames':(8,1)},
|
| 31 |
+
'Wan': {'target_rate': 16, 'dim': (8,0,832,480), 'frames':(4,1)},
|
| 32 |
+
}
|
| 33 |
+
"""
|
| 34 |
+
External plugins may add additional formats to nodes.VHSLoadFormats
|
| 35 |
+
In addition to shorthand options, direct widget names will map a given dict to options.
|
| 36 |
+
Adding a third arguement to a frames tuple can enable strict checks on number
|
| 37 |
+
of loaded frames, i.e (8,1,True)
|
| 38 |
+
"""
|
| 39 |
+
if not hasattr(nodes, 'VHSLoadFormats'):
|
| 40 |
+
nodes.VHSLoadFormats = {}
|
| 41 |
+
|
| 42 |
+
def get_load_formats():
|
| 43 |
+
#TODO: check if {**extra_config.VHSLoafFormats, **VHSLoadFormats} has minimum version
|
| 44 |
+
formats = {}
|
| 45 |
+
formats.update(nodes.VHSLoadFormats)
|
| 46 |
+
formats.update(VHSLoadFormats)
|
| 47 |
+
return (list(formats.keys()),
|
| 48 |
+
{'default': 'AnimateDiff', 'formats': formats})
|
| 49 |
+
def get_format(format):
|
| 50 |
+
if format in VHSLoadFormats:
|
| 51 |
+
return VHSLoadFormats[format]
|
| 52 |
+
return nodes.VHSLoadFormats.get(format, {})
|
| 53 |
+
|
| 54 |
+
def is_gif(filename) -> bool:
|
| 55 |
+
file_parts = filename.split('.')
|
| 56 |
+
return len(file_parts) > 1 and file_parts[-1] == "gif"
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def target_size(width, height, custom_width, custom_height, downscale_ratio=8) -> tuple[int, int]:
|
| 60 |
+
if downscale_ratio is None:
|
| 61 |
+
downscale_ratio = 8
|
| 62 |
+
if custom_width == 0 and custom_height == 0:
|
| 63 |
+
pass
|
| 64 |
+
elif custom_height == 0:
|
| 65 |
+
height *= custom_width/width
|
| 66 |
+
width = custom_width
|
| 67 |
+
elif custom_width == 0:
|
| 68 |
+
width *= custom_height/height
|
| 69 |
+
height = custom_height
|
| 70 |
+
else:
|
| 71 |
+
width = custom_width
|
| 72 |
+
height = custom_height
|
| 73 |
+
width = int(width/downscale_ratio + 0.5) * downscale_ratio
|
| 74 |
+
height = int(height/downscale_ratio + 0.5) * downscale_ratio
|
| 75 |
+
return (width, height)
|
| 76 |
+
|
| 77 |
+
def cv_frame_generator(video, force_rate, frame_load_cap, skip_first_frames,
|
| 78 |
+
select_every_nth, meta_batch=None, unique_id=None):
|
| 79 |
+
video_cap = cv2.VideoCapture(video)
|
| 80 |
+
if not video_cap.isOpened() or not video_cap.grab():
|
| 81 |
+
raise ValueError(f"{video} could not be loaded with cv.")
|
| 82 |
+
|
| 83 |
+
# extract video metadata
|
| 84 |
+
fps = video_cap.get(cv2.CAP_PROP_FPS)
|
| 85 |
+
width = int(video_cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
| 86 |
+
height = int(video_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
| 87 |
+
total_frames = int(video_cap.get(cv2.CAP_PROP_FRAME_COUNT))
|
| 88 |
+
duration = total_frames / fps
|
| 89 |
+
|
| 90 |
+
width = 0
|
| 91 |
+
|
| 92 |
+
if width <=0 or height <=0:
|
| 93 |
+
_, frame = video_cap.retrieve()
|
| 94 |
+
height, width, _ = frame.shape
|
| 95 |
+
|
| 96 |
+
# set video_cap to look at start_index frame
|
| 97 |
+
total_frame_count = 0
|
| 98 |
+
total_frames_evaluated = -1
|
| 99 |
+
frames_added = 0
|
| 100 |
+
base_frame_time = 1 / fps
|
| 101 |
+
prev_frame = None
|
| 102 |
+
|
| 103 |
+
if force_rate == 0:
|
| 104 |
+
target_frame_time = base_frame_time
|
| 105 |
+
else:
|
| 106 |
+
target_frame_time = 1/force_rate
|
| 107 |
+
|
| 108 |
+
if total_frames > 0:
|
| 109 |
+
if force_rate != 0:
|
| 110 |
+
yieldable_frames = int(total_frames / fps * force_rate)
|
| 111 |
+
else:
|
| 112 |
+
yieldable_frames = total_frames
|
| 113 |
+
if select_every_nth:
|
| 114 |
+
yieldable_frames //= select_every_nth
|
| 115 |
+
if frame_load_cap != 0:
|
| 116 |
+
yieldable_frames = min(frame_load_cap, yieldable_frames)
|
| 117 |
+
else:
|
| 118 |
+
yieldable_frames = 0
|
| 119 |
+
yield (width, height, fps, duration, total_frames, target_frame_time, yieldable_frames)
|
| 120 |
+
pbar = ProgressBar(yieldable_frames)
|
| 121 |
+
time_offset=target_frame_time
|
| 122 |
+
while video_cap.isOpened():
|
| 123 |
+
if time_offset < target_frame_time:
|
| 124 |
+
is_returned = video_cap.grab()
|
| 125 |
+
# if didn't return frame, video has ended
|
| 126 |
+
if not is_returned:
|
| 127 |
+
break
|
| 128 |
+
time_offset += base_frame_time
|
| 129 |
+
if time_offset < target_frame_time:
|
| 130 |
+
continue
|
| 131 |
+
time_offset -= target_frame_time
|
| 132 |
+
# if not at start_index, skip doing anything with frame
|
| 133 |
+
total_frame_count += 1
|
| 134 |
+
if total_frame_count <= skip_first_frames:
|
| 135 |
+
continue
|
| 136 |
+
else:
|
| 137 |
+
total_frames_evaluated += 1
|
| 138 |
+
|
| 139 |
+
# if should not be selected, skip doing anything with frame
|
| 140 |
+
if total_frames_evaluated%select_every_nth != 0:
|
| 141 |
+
continue
|
| 142 |
+
|
| 143 |
+
# opencv loads images in BGR format (yuck), so need to convert to RGB for ComfyUI use
|
| 144 |
+
# follow up: can videos ever have an alpha channel?
|
| 145 |
+
# To my testing: No. opencv has no support for alpha
|
| 146 |
+
unused, frame = video_cap.retrieve()
|
| 147 |
+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
| 148 |
+
# convert frame to comfyui's expected format
|
| 149 |
+
# TODO: frame contains no exif information. Check if opencv2 has already applied
|
| 150 |
+
frame = np.array(frame, dtype=np.float32)
|
| 151 |
+
torch.from_numpy(frame).div_(255)
|
| 152 |
+
if prev_frame is not None:
|
| 153 |
+
inp = yield prev_frame
|
| 154 |
+
if inp is not None:
|
| 155 |
+
#ensure the finally block is called
|
| 156 |
+
return
|
| 157 |
+
prev_frame = frame
|
| 158 |
+
frames_added += 1
|
| 159 |
+
if pbar is not None:
|
| 160 |
+
pbar.update_absolute(frames_added, yieldable_frames)
|
| 161 |
+
# if cap exists and we've reached it, stop processing frames
|
| 162 |
+
if frame_load_cap > 0 and frames_added >= frame_load_cap:
|
| 163 |
+
break
|
| 164 |
+
if meta_batch is not None:
|
| 165 |
+
meta_batch.inputs.pop(unique_id)
|
| 166 |
+
meta_batch.has_closed_inputs = True
|
| 167 |
+
if prev_frame is not None:
|
| 168 |
+
yield prev_frame
|
| 169 |
+
|
| 170 |
+
def ffmpeg_frame_generator(video, force_rate, frame_load_cap, start_time,
|
| 171 |
+
custom_width, custom_height, downscale_ratio=8,
|
| 172 |
+
meta_batch=None, unique_id=None):
|
| 173 |
+
args_input = ["-i", video]
|
| 174 |
+
args_dummy = [ffmpeg_path] + args_input +['-c', 'copy', '-frames:v', '1', "-f", "null", "-"]
|
| 175 |
+
size_base = None
|
| 176 |
+
fps_base = None
|
| 177 |
+
try:
|
| 178 |
+
dummy_res = subprocess.run(args_dummy, stdout=subprocess.DEVNULL,
|
| 179 |
+
stderr=subprocess.PIPE, check=True)
|
| 180 |
+
except subprocess.CalledProcessError as e:
|
| 181 |
+
raise Exception("An error occurred in the ffmpeg subprocess:\n" \
|
| 182 |
+
+ e.stderr.decode(*ENCODE_ARGS))
|
| 183 |
+
lines = dummy_res.stderr.decode(*ENCODE_ARGS)
|
| 184 |
+
if "Video: vp9 " in lines:
|
| 185 |
+
args_input = ["-c:v", "libvpx-vp9"] + args_input
|
| 186 |
+
args_dummy = [ffmpeg_path] + args_input +['-c', 'copy', '-frames:v', '1', "-f", "null", "-"]
|
| 187 |
+
try:
|
| 188 |
+
dummy_res = subprocess.run(args_dummy, stdout=subprocess.DEVNULL,
|
| 189 |
+
stderr=subprocess.PIPE, check=True)
|
| 190 |
+
except subprocess.CalledProcessError as e:
|
| 191 |
+
raise Exception("An error occurred in the ffmpeg subprocess:\n" \
|
| 192 |
+
+ e.stderr.decode(*ENCODE_ARGS))
|
| 193 |
+
lines = dummy_res.stderr.decode(*ENCODE_ARGS)
|
| 194 |
+
|
| 195 |
+
for line in lines.split('\n'):
|
| 196 |
+
match = re.search("^ *Stream .* Video.*, ([1-9]|\\d{2,})x(\\d+)", line)
|
| 197 |
+
if match is not None:
|
| 198 |
+
size_base = [int(match.group(1)), int(match.group(2))]
|
| 199 |
+
fps_match = re.search(", ([\\d\\.]+) fps", line)
|
| 200 |
+
if fps_match:
|
| 201 |
+
fps_base = float(fps_match.group(1))
|
| 202 |
+
else:
|
| 203 |
+
fps_base = 1
|
| 204 |
+
alpha = re.search("(yuva|rgba|bgra)", line) is not None
|
| 205 |
+
break
|
| 206 |
+
else:
|
| 207 |
+
raise Exception("Failed to parse video/image information. FFMPEG output:\n" + lines)
|
| 208 |
+
|
| 209 |
+
durs_match = re.search("Duration: (\\d+:\\d+:\\d+\\.\\d+),", lines)
|
| 210 |
+
if durs_match:
|
| 211 |
+
durs = durs_match.group(1).split(':')
|
| 212 |
+
duration = int(durs[0])*360 + int(durs[1])*60 + float(durs[2])
|
| 213 |
+
else:
|
| 214 |
+
duration = 0
|
| 215 |
+
|
| 216 |
+
if start_time > 0:
|
| 217 |
+
if start_time > 4:
|
| 218 |
+
post_seek = ['-ss', '4']
|
| 219 |
+
args_input = ['-ss', str(start_time - 4)] + args_input
|
| 220 |
+
else:
|
| 221 |
+
post_seek = ['-ss', str(start_time)]
|
| 222 |
+
else:
|
| 223 |
+
post_seek = []
|
| 224 |
+
args_all_frames = [ffmpeg_path, "-v", "error", "-an"] + \
|
| 225 |
+
args_input + ["-pix_fmt", "rgba64le"] + post_seek
|
| 226 |
+
|
| 227 |
+
vfilters = []
|
| 228 |
+
if force_rate != 0:
|
| 229 |
+
vfilters.append("fps=fps="+str(force_rate))
|
| 230 |
+
if custom_width != 0 or custom_height != 0:
|
| 231 |
+
size = target_size(size_base[0], size_base[1], custom_width,
|
| 232 |
+
custom_height, downscale_ratio=downscale_ratio)
|
| 233 |
+
ar = float(size[0])/float(size[1])
|
| 234 |
+
if abs(size_base[0]*ar-size_base[1]) >= 1:
|
| 235 |
+
#Aspect ratio is changed. Crop to new aspect ratio before scale
|
| 236 |
+
vfilters.append(f"crop=if(gt({ar}\\,a)\\,iw\\,ih*{ar}):if(gt({ar}\\,a)\\,iw/{ar}\\,ih)")
|
| 237 |
+
size_arg = ':'.join(map(str,size))
|
| 238 |
+
vfilters.append(f"scale={size_arg}")
|
| 239 |
+
else:
|
| 240 |
+
size = size_base
|
| 241 |
+
if len(vfilters) > 0:
|
| 242 |
+
args_all_frames += ["-vf", ",".join(vfilters)]
|
| 243 |
+
yieldable_frames = (force_rate or fps_base)*duration
|
| 244 |
+
if frame_load_cap > 0:
|
| 245 |
+
args_all_frames += ["-frames:v", str(frame_load_cap)]
|
| 246 |
+
yieldable_frames = min(yieldable_frames, frame_load_cap)
|
| 247 |
+
yield (size_base[0], size_base[1], fps_base, duration, fps_base * duration,
|
| 248 |
+
1/(force_rate or fps_base), yieldable_frames, size[0], size[1], alpha)
|
| 249 |
+
|
| 250 |
+
args_all_frames += ["-f", "rawvideo", "-"]
|
| 251 |
+
pbar = ProgressBar(yieldable_frames)
|
| 252 |
+
try:
|
| 253 |
+
with subprocess.Popen(args_all_frames, stdout=subprocess.PIPE) as proc:
|
| 254 |
+
#Manually buffer enough bytes for an image
|
| 255 |
+
bpi = size[0] * size[1] * 8
|
| 256 |
+
current_bytes = bytearray(bpi)
|
| 257 |
+
current_offset=0
|
| 258 |
+
prev_frame = None
|
| 259 |
+
while True:
|
| 260 |
+
bytes_read = proc.stdout.read(bpi - current_offset)
|
| 261 |
+
if bytes_read is None:#sleep to wait for more data
|
| 262 |
+
time.sleep(.1)
|
| 263 |
+
continue
|
| 264 |
+
if len(bytes_read) == 0:#EOF
|
| 265 |
+
break
|
| 266 |
+
current_bytes[current_offset:len(bytes_read)] = bytes_read
|
| 267 |
+
current_offset+=len(bytes_read)
|
| 268 |
+
if current_offset == bpi:
|
| 269 |
+
if prev_frame is not None:
|
| 270 |
+
yield prev_frame
|
| 271 |
+
pbar.update(1)
|
| 272 |
+
prev_frame = np.frombuffer(current_bytes, dtype=np.dtype(np.uint16).newbyteorder("<")).reshape(size[1], size[0], 4) / (2**16-1)
|
| 273 |
+
if not alpha:
|
| 274 |
+
prev_frame = prev_frame[:, :, :-1]
|
| 275 |
+
current_offset = 0
|
| 276 |
+
except BrokenPipeError as e:
|
| 277 |
+
raise Exception("An error occured in the ffmpeg subprocess:\n" \
|
| 278 |
+
+ proc.stderr.read().decode(*ENCODE_ARGS))
|
| 279 |
+
if meta_batch is not None:
|
| 280 |
+
meta_batch.inputs.pop(unique_id)
|
| 281 |
+
meta_batch.has_closed_inputs = True
|
| 282 |
+
if prev_frame is not None:
|
| 283 |
+
yield prev_frame
|
| 284 |
+
|
| 285 |
+
#Python 3.12 adds an itertools.batched, but it's easily replicated for legacy support
|
| 286 |
+
def batched(it, n):
|
| 287 |
+
while batch := tuple(itertools.islice(it, n)):
|
| 288 |
+
yield batch
|
| 289 |
+
def batched_vae_encode(images, vae, frames_per_batch):
|
| 290 |
+
for batch in batched(images, frames_per_batch):
|
| 291 |
+
image_batch = torch.from_numpy(np.array(batch))
|
| 292 |
+
yield from vae.encode(image_batch).numpy()
|
| 293 |
+
def resized_cv_frame_gen(custom_width, custom_height, downscale_ratio, **kwargs):
|
| 294 |
+
gen = cv_frame_generator(**kwargs)
|
| 295 |
+
info = next(gen)
|
| 296 |
+
width, height = info[0], info[1]
|
| 297 |
+
frames_per_batch = (1920 * 1080 * 16) // (width * height) or 1
|
| 298 |
+
if kwargs.get('meta_batch', None) is not None:
|
| 299 |
+
frames_per_batch = min(frames_per_batch, kwargs['meta_batch'].frames_per_batch)
|
| 300 |
+
if custom_width != 0 or custom_height != 0 or downscale_ratio is not None:
|
| 301 |
+
new_size = target_size(width, height, custom_width, custom_height, downscale_ratio)
|
| 302 |
+
yield (*info, new_size[0], new_size[1], False)
|
| 303 |
+
if new_size[0] != width or new_size[1] != height:
|
| 304 |
+
def rescale(frame):
|
| 305 |
+
s = torch.from_numpy(np.fromiter(frame, np.dtype((np.float32, (height, width, 3)))))
|
| 306 |
+
s = s.movedim(-1,1)
|
| 307 |
+
s = common_upscale(s, new_size[0], new_size[1], "lanczos", "center")
|
| 308 |
+
return s.movedim(1,-1).numpy()
|
| 309 |
+
yield from itertools.chain.from_iterable(map(rescale, batched(gen, frames_per_batch)))
|
| 310 |
+
return
|
| 311 |
+
else:
|
| 312 |
+
yield (*info, info[0], info[1], False)
|
| 313 |
+
yield from gen
|
| 314 |
+
|
| 315 |
+
def load_video(meta_batch=None, unique_id=None, memory_limit_mb=None, vae=None,
|
| 316 |
+
generator=resized_cv_frame_gen, format='None', **kwargs):
|
| 317 |
+
if 'force_size' in kwargs:
|
| 318 |
+
kwargs.pop('force_size')
|
| 319 |
+
logger.warn("force_size has been removed. Did you reload the webpage after updating?")
|
| 320 |
+
format = get_format(format)
|
| 321 |
+
kwargs['video'] = strip_path(kwargs['video'])
|
| 322 |
+
if vae is not None:
|
| 323 |
+
downscale_ratio = getattr(vae, "downscale_ratio", 8)
|
| 324 |
+
else:
|
| 325 |
+
downscale_ratio = format.get('dim', (1,))[0]
|
| 326 |
+
if meta_batch is None or unique_id not in meta_batch.inputs:
|
| 327 |
+
gen = generator(meta_batch=meta_batch, unique_id=unique_id, downscale_ratio=downscale_ratio, **kwargs)
|
| 328 |
+
(width, height, fps, duration, total_frames, target_frame_time, yieldable_frames, new_width, new_height, alpha) = next(gen)
|
| 329 |
+
|
| 330 |
+
if meta_batch is not None:
|
| 331 |
+
meta_batch.inputs[unique_id] = (gen, width, height, fps, duration, total_frames, target_frame_time, yieldable_frames, new_width, new_height, alpha)
|
| 332 |
+
if yieldable_frames:
|
| 333 |
+
meta_batch.total_frames = min(meta_batch.total_frames, yieldable_frames)
|
| 334 |
+
|
| 335 |
+
else:
|
| 336 |
+
(gen, width, height, fps, duration, total_frames, target_frame_time, yieldable_frames, new_width, new_height, alpha) = meta_batch.inputs[unique_id]
|
| 337 |
+
|
| 338 |
+
memory_limit = None
|
| 339 |
+
if memory_limit_mb is not None:
|
| 340 |
+
memory_limit *= 2 ** 20
|
| 341 |
+
else:
|
| 342 |
+
#TODO: verify if garbage collection should be performed here.
|
| 343 |
+
#leaves ~128 MB unreserved for safety
|
| 344 |
+
try:
|
| 345 |
+
memory_limit = (psutil.virtual_memory().available + psutil.swap_memory().free) - 2 ** 27
|
| 346 |
+
except:
|
| 347 |
+
logger.warn("Failed to calculate available memory. Memory load limit has been disabled")
|
| 348 |
+
memory_limit = BIGMAX
|
| 349 |
+
if vae is not None:
|
| 350 |
+
#space required to load as f32, exist as latent with wiggle room, decode to f32
|
| 351 |
+
max_loadable_frames = int(memory_limit//(width*height*3*(4+4+1/10)))
|
| 352 |
+
else:
|
| 353 |
+
#TODO: use better estimate for when vae is not None
|
| 354 |
+
#Consider completely ignoring for load_latent case?
|
| 355 |
+
max_loadable_frames = int(memory_limit//(width*height*3*(.1)))
|
| 356 |
+
if meta_batch is not None:
|
| 357 |
+
if 'frames' in format:
|
| 358 |
+
if meta_batch.frames_per_batch % format['frames'][0] != format['frames'][1]:
|
| 359 |
+
error = (meta_batch.frames_per_batch - format['frames'][1]) % format['frames'][0]
|
| 360 |
+
suggested = meta_batch.frames_per_batch - error
|
| 361 |
+
if error > format['frames'][0] / 2:
|
| 362 |
+
suggested += format['frames'][0]
|
| 363 |
+
raise RuntimeError(f"The chosen frames per batch is incompatible with the selected format. Try {suggested}")
|
| 364 |
+
if meta_batch.frames_per_batch > max_loadable_frames:
|
| 365 |
+
raise RuntimeError(f"Meta Batch set to {meta_batch.frames_per_batch} frames but only {max_loadable_frames} can fit in memory")
|
| 366 |
+
gen = itertools.islice(gen, meta_batch.frames_per_batch)
|
| 367 |
+
else:
|
| 368 |
+
original_gen = gen
|
| 369 |
+
gen = itertools.islice(gen, max_loadable_frames)
|
| 370 |
+
frames_per_batch = (1920 * 1080 * 16) // (width * height) or 1
|
| 371 |
+
if vae is not None:
|
| 372 |
+
gen = batched_vae_encode(gen, vae, frames_per_batch)
|
| 373 |
+
vw,vh = new_width//downscale_ratio, new_height//downscale_ratio
|
| 374 |
+
channels = getattr(vae, 'latent_channels', 4)
|
| 375 |
+
images = torch.from_numpy(np.fromiter(gen, np.dtype((np.float32, (channels,vh,vw)))))
|
| 376 |
+
else:
|
| 377 |
+
#Some minor wizardry to eliminate a copy and reduce max memory by a factor of ~2
|
| 378 |
+
images = torch.from_numpy(np.fromiter(gen, np.dtype((np.float32, (new_height, new_width, 4 if alpha else 3)))))
|
| 379 |
+
if meta_batch is None and memory_limit is not None:
|
| 380 |
+
try:
|
| 381 |
+
next(original_gen)
|
| 382 |
+
raise RuntimeError(f"Memory limit hit after loading {len(images)} frames. Stopping execution.")
|
| 383 |
+
except StopIteration:
|
| 384 |
+
pass
|
| 385 |
+
if len(images) == 0:
|
| 386 |
+
raise RuntimeError("No frames generated")
|
| 387 |
+
if 'frames' in format and len(images) % format['frames'][0] != format['frames'][1]:
|
| 388 |
+
err_msg = f"The number of frames loaded {len(images)}, does not match the requirements of the currently selected format."
|
| 389 |
+
if len(format['frames']) > 2 and format['frames'][2]:
|
| 390 |
+
raise RuntimeError(err_msg)
|
| 391 |
+
div, mod = format['frames'][:2]
|
| 392 |
+
frames = (len(images) - mod) // div * div + mod
|
| 393 |
+
images = images[:frames]
|
| 394 |
+
#Commenting out log message since it's displayed in UI. consider further
|
| 395 |
+
#logger.warn(err_msg + f" Output has been truncated to {len(images)} frames.")
|
| 396 |
+
if 'start_time' in kwargs:
|
| 397 |
+
start_time = kwargs['start_time']
|
| 398 |
+
else:
|
| 399 |
+
start_time = kwargs['skip_first_frames'] * target_frame_time
|
| 400 |
+
target_frame_time *= kwargs.get('select_every_nth', 1)
|
| 401 |
+
#Setup lambda for lazy audio capture
|
| 402 |
+
audio = lazy_get_audio(kwargs['video'], start_time, kwargs['frame_load_cap']*target_frame_time)
|
| 403 |
+
#Adjust target_frame_time for select_every_nth
|
| 404 |
+
video_info = {
|
| 405 |
+
"source_fps": fps,
|
| 406 |
+
"source_frame_count": total_frames,
|
| 407 |
+
"source_duration": duration,
|
| 408 |
+
"source_width": width,
|
| 409 |
+
"source_height": height,
|
| 410 |
+
"loaded_fps": 1/target_frame_time,
|
| 411 |
+
"loaded_frame_count": len(images),
|
| 412 |
+
"loaded_duration": len(images) * target_frame_time,
|
| 413 |
+
"loaded_width": new_width,
|
| 414 |
+
"loaded_height": new_height,
|
| 415 |
+
}
|
| 416 |
+
if vae is None:
|
| 417 |
+
return (images, len(images), audio, video_info)
|
| 418 |
+
else:
|
| 419 |
+
return ({"samples": images}, len(images), audio, video_info)
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
class LoadVideoUpload:
|
| 424 |
+
@classmethod
|
| 425 |
+
def INPUT_TYPES(s):
|
| 426 |
+
input_dir = folder_paths.get_input_directory()
|
| 427 |
+
files = []
|
| 428 |
+
for f in os.listdir(input_dir):
|
| 429 |
+
if os.path.isfile(os.path.join(input_dir, f)):
|
| 430 |
+
file_parts = f.split('.')
|
| 431 |
+
if len(file_parts) > 1 and (file_parts[-1].lower() in video_extensions):
|
| 432 |
+
files.append(f)
|
| 433 |
+
return {"required": {
|
| 434 |
+
"video": (sorted(files),),
|
| 435 |
+
"force_rate": (floatOrInt, {"default": 0, "min": 0, "max": 60, "step": 1, "disable": 0}),
|
| 436 |
+
"custom_width": ("INT", {"default": 0, "min": 0, "max": DIMMAX, 'disable': 0}),
|
| 437 |
+
"custom_height": ("INT", {"default": 0, "min": 0, "max": DIMMAX, 'disable': 0}),
|
| 438 |
+
"frame_load_cap": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1, "disable": 0}),
|
| 439 |
+
"skip_first_frames": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1}),
|
| 440 |
+
"select_every_nth": ("INT", {"default": 1, "min": 1, "max": BIGMAX, "step": 1}),
|
| 441 |
+
},
|
| 442 |
+
"optional": {
|
| 443 |
+
"meta_batch": ("VHS_BatchManager",),
|
| 444 |
+
"vae": ("VAE",),
|
| 445 |
+
"format": get_load_formats(),
|
| 446 |
+
},
|
| 447 |
+
"hidden": {
|
| 448 |
+
"force_size": "STRING",
|
| 449 |
+
"unique_id": "UNIQUE_ID"
|
| 450 |
+
},
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 454 |
+
|
| 455 |
+
RETURN_TYPES = (imageOrLatent, "INT", "AUDIO", "VHS_VIDEOINFO")
|
| 456 |
+
RETURN_NAMES = ("IMAGE", "frame_count", "audio", "video_info")
|
| 457 |
+
|
| 458 |
+
FUNCTION = "load_video"
|
| 459 |
+
|
| 460 |
+
def load_video(self, **kwargs):
|
| 461 |
+
kwargs['video'] = folder_paths.get_annotated_filepath(strip_path(kwargs['video']))
|
| 462 |
+
return load_video(**kwargs)
|
| 463 |
+
|
| 464 |
+
@classmethod
|
| 465 |
+
def IS_CHANGED(s, video, **kwargs):
|
| 466 |
+
image_path = folder_paths.get_annotated_filepath(video)
|
| 467 |
+
return calculate_file_hash(image_path)
|
| 468 |
+
|
| 469 |
+
@classmethod
|
| 470 |
+
def VALIDATE_INPUTS(s, video):
|
| 471 |
+
if not folder_paths.exists_annotated_filepath(video):
|
| 472 |
+
return "Invalid video file: {}".format(video)
|
| 473 |
+
return True
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
class LoadVideoPath:
|
| 477 |
+
@classmethod
|
| 478 |
+
def INPUT_TYPES(s):
|
| 479 |
+
return {
|
| 480 |
+
"required": {
|
| 481 |
+
"video": ("STRING", {"placeholder": "X://insert/path/here.mp4", "vhs_path_extensions": video_extensions}),
|
| 482 |
+
"force_rate": (floatOrInt, {"default": 0, "min": 0, "max": 60, "step": 1, "disable": 0}),
|
| 483 |
+
"custom_width": ("INT", {"default": 0, "min": 0, "max": DIMMAX, 'disable': 0}),
|
| 484 |
+
"custom_height": ("INT", {"default": 0, "min": 0, "max": DIMMAX, 'disable': 0}),
|
| 485 |
+
"frame_load_cap": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1, "disable": 0}),
|
| 486 |
+
"skip_first_frames": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1}),
|
| 487 |
+
"select_every_nth": ("INT", {"default": 1, "min": 1, "max": BIGMAX, "step": 1}),
|
| 488 |
+
},
|
| 489 |
+
"optional": {
|
| 490 |
+
"meta_batch": ("VHS_BatchManager",),
|
| 491 |
+
"vae": ("VAE",),
|
| 492 |
+
"format": get_load_formats(),
|
| 493 |
+
},
|
| 494 |
+
"hidden": {
|
| 495 |
+
"force_size": "STRING",
|
| 496 |
+
"unique_id": "UNIQUE_ID"
|
| 497 |
+
},
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 501 |
+
|
| 502 |
+
RETURN_TYPES = (imageOrLatent, "INT", "AUDIO", "VHS_VIDEOINFO")
|
| 503 |
+
RETURN_NAMES = ("IMAGE", "frame_count", "audio", "video_info")
|
| 504 |
+
|
| 505 |
+
FUNCTION = "load_video"
|
| 506 |
+
|
| 507 |
+
def load_video(self, **kwargs):
|
| 508 |
+
if kwargs['video'] is None or validate_path(kwargs['video']) != True:
|
| 509 |
+
raise Exception("video is not a valid path: " + kwargs['video'])
|
| 510 |
+
if is_url(kwargs['video']):
|
| 511 |
+
kwargs['video'] = try_download_video(kwargs['video']) or kwargs['video']
|
| 512 |
+
return load_video(**kwargs)
|
| 513 |
+
|
| 514 |
+
@classmethod
|
| 515 |
+
def IS_CHANGED(s, video, **kwargs):
|
| 516 |
+
return hash_path(video)
|
| 517 |
+
|
| 518 |
+
@classmethod
|
| 519 |
+
def VALIDATE_INPUTS(s, video):
|
| 520 |
+
return validate_path(video, allow_none=True)
|
| 521 |
+
|
| 522 |
+
class LoadVideoFFmpegUpload:
|
| 523 |
+
@classmethod
|
| 524 |
+
def INPUT_TYPES(s):
|
| 525 |
+
input_dir = folder_paths.get_input_directory()
|
| 526 |
+
files = []
|
| 527 |
+
for f in os.listdir(input_dir):
|
| 528 |
+
if os.path.isfile(os.path.join(input_dir, f)):
|
| 529 |
+
file_parts = f.split('.')
|
| 530 |
+
if len(file_parts) > 1 and (file_parts[-1].lower() in video_extensions):
|
| 531 |
+
files.append(f)
|
| 532 |
+
return {"required": {
|
| 533 |
+
"video": (sorted(files),),
|
| 534 |
+
"force_rate": (floatOrInt, {"default": 0, "min": 0, "max": 60, "step": 1, "disable": 0}),
|
| 535 |
+
"custom_width": ("INT", {"default": 0, "min": 0, "max": DIMMAX, 'disable': 0}),
|
| 536 |
+
"custom_height": ("INT", {"default": 0, "min": 0, "max": DIMMAX, 'disable': 0}),
|
| 537 |
+
"frame_load_cap": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1, "disable": 0}),
|
| 538 |
+
"start_time": ("FLOAT", {"default": 0, "min": 0, "max": BIGMAX, "step": .001, "widgetType": "VHSTIMESTAMP"}),
|
| 539 |
+
},
|
| 540 |
+
"optional": {
|
| 541 |
+
"meta_batch": ("VHS_BatchManager",),
|
| 542 |
+
"vae": ("VAE",),
|
| 543 |
+
"format": get_load_formats(),
|
| 544 |
+
},
|
| 545 |
+
"hidden": {
|
| 546 |
+
"force_size": "STRING",
|
| 547 |
+
"unique_id": "UNIQUE_ID"
|
| 548 |
+
|
| 549 |
+
},
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 553 |
+
|
| 554 |
+
RETURN_TYPES = (imageOrLatent, "MASK", "AUDIO", "VHS_VIDEOINFO")
|
| 555 |
+
RETURN_NAMES = ("IMAGE", "mask", "audio", "video_info")
|
| 556 |
+
|
| 557 |
+
FUNCTION = "load_video"
|
| 558 |
+
|
| 559 |
+
def load_video(self, **kwargs):
|
| 560 |
+
kwargs['video'] = folder_paths.get_annotated_filepath(strip_path(kwargs['video']))
|
| 561 |
+
image, _, audio, video_info = load_video(**kwargs, generator=ffmpeg_frame_generator)
|
| 562 |
+
if image.size(3) == 4:
|
| 563 |
+
return (image[:,:,:,:3], 1-image[:,:,:,3], audio, video_info)
|
| 564 |
+
return (image, torch.zeros(image.size(0), 64, 64, device="cpu"), audio, video_info)
|
| 565 |
+
|
| 566 |
+
@classmethod
|
| 567 |
+
def IS_CHANGED(s, video, **kwargs):
|
| 568 |
+
image_path = folder_paths.get_annotated_filepath(video)
|
| 569 |
+
return calculate_file_hash(image_path)
|
| 570 |
+
|
| 571 |
+
@classmethod
|
| 572 |
+
def VALIDATE_INPUTS(s, video):
|
| 573 |
+
if not folder_paths.exists_annotated_filepath(video):
|
| 574 |
+
return "Invalid video file: {}".format(video)
|
| 575 |
+
return True
|
| 576 |
+
|
| 577 |
+
|
| 578 |
+
class LoadVideoFFmpegPath:
|
| 579 |
+
@classmethod
|
| 580 |
+
def INPUT_TYPES(s):
|
| 581 |
+
return {
|
| 582 |
+
"required": {
|
| 583 |
+
"video": ("STRING", {"placeholder": "X://insert/path/here.mp4", "vhs_path_extensions": video_extensions}),
|
| 584 |
+
"force_rate": (floatOrInt, {"default": 0, "min": 0, "max": 60, "step": 1, "disable": 0}),
|
| 585 |
+
"custom_width": ("INT", {"default": 0, "min": 0, "max": DIMMAX, 'disable': 0}),
|
| 586 |
+
"custom_height": ("INT", {"default": 0, "min": 0, "max": DIMMAX, 'disable': 0}),
|
| 587 |
+
"frame_load_cap": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1, "disable": 0}),
|
| 588 |
+
"start_time": ("FLOAT", {"default": 0, "min": 0, "max": BIGMAX, "step": .001, "widgetType": "VHSTIMESTAMP"}),
|
| 589 |
+
},
|
| 590 |
+
"optional": {
|
| 591 |
+
"meta_batch": ("VHS_BatchManager",),
|
| 592 |
+
"vae": ("VAE",),
|
| 593 |
+
"format": get_load_formats(),
|
| 594 |
+
},
|
| 595 |
+
"hidden": {
|
| 596 |
+
"force_size": "STRING",
|
| 597 |
+
"unique_id": "UNIQUE_ID"
|
| 598 |
+
},
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 602 |
+
|
| 603 |
+
RETURN_TYPES = (imageOrLatent, "MASK", "AUDIO", "VHS_VIDEOINFO")
|
| 604 |
+
RETURN_NAMES = ("IMAGE", "mask", "audio", "video_info")
|
| 605 |
+
|
| 606 |
+
FUNCTION = "load_video"
|
| 607 |
+
|
| 608 |
+
def load_video(self, **kwargs):
|
| 609 |
+
if kwargs['video'] is None or validate_path(kwargs['video']) != True:
|
| 610 |
+
raise Exception("video is not a valid path: " + kwargs['video'])
|
| 611 |
+
if is_url(kwargs['video']):
|
| 612 |
+
kwargs['video'] = try_download_video(kwargs['video']) or kwargs['video']
|
| 613 |
+
image, _, audio, video_info = load_video(**kwargs, generator=ffmpeg_frame_generator)
|
| 614 |
+
if isinstance(image, dict):
|
| 615 |
+
return (image, None, audio, video_info)
|
| 616 |
+
if image.size(3) == 4:
|
| 617 |
+
return (image[:,:,:,:3], 1-image[:,:,:,3], audio, video_info)
|
| 618 |
+
return (image, torch.zeros(image.size(0), 64, 64, device="cpu"), audio, video_info)
|
| 619 |
+
|
| 620 |
+
@classmethod
|
| 621 |
+
def IS_CHANGED(s, video, **kwargs):
|
| 622 |
+
return hash_path(video)
|
| 623 |
+
|
| 624 |
+
@classmethod
|
| 625 |
+
def VALIDATE_INPUTS(s, video):
|
| 626 |
+
return validate_path(video, allow_none=True)
|
| 627 |
+
|
| 628 |
+
class LoadImagePath:
|
| 629 |
+
@classmethod
|
| 630 |
+
def INPUT_TYPES(s):
|
| 631 |
+
return {
|
| 632 |
+
"required": {
|
| 633 |
+
"image": ("STRING", {"placeholder": "X://insert/path/here.png", "vhs_path_extensions": list(FolderOfImages.IMG_EXTENSIONS)}),
|
| 634 |
+
"custom_width": ("INT", {"default": 0, "min": 0, "max": DIMMAX, "step": 8, 'disable': 0}),
|
| 635 |
+
"custom_height": ("INT", {"default": 0, "min": 0, "max": DIMMAX, "step": 8, 'disable': 0}),
|
| 636 |
+
},
|
| 637 |
+
"optional": {
|
| 638 |
+
"vae": ("VAE",),
|
| 639 |
+
},
|
| 640 |
+
"hidden": {
|
| 641 |
+
"force_size": "STRING",
|
| 642 |
+
},
|
| 643 |
+
}
|
| 644 |
+
|
| 645 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 646 |
+
|
| 647 |
+
RETURN_TYPES = (imageOrLatent, "MASK")
|
| 648 |
+
RETURN_NAMES = ("IMAGE", "mask")
|
| 649 |
+
|
| 650 |
+
FUNCTION = "load_image"
|
| 651 |
+
|
| 652 |
+
def load_image(self, **kwargs):
|
| 653 |
+
if kwargs['image'] is None or validate_path(kwargs['image']) != True:
|
| 654 |
+
raise Exception("image is not a valid path: " + kwargs['image'])
|
| 655 |
+
kwargs.update({'video': kwargs['image'], 'force_rate': 0, 'frame_load_cap': 0,
|
| 656 |
+
'start_time': 0})
|
| 657 |
+
kwargs.pop('image')
|
| 658 |
+
image, _, _, _ = load_video(**kwargs, generator=ffmpeg_frame_generator)
|
| 659 |
+
if isinstance(image, dict):
|
| 660 |
+
return (image, None)
|
| 661 |
+
if image.size(3) == 4:
|
| 662 |
+
return (image[:,:,:,:3], 1-image[:,:,:,3])
|
| 663 |
+
return (image, torch.zeros(image.size(0), 64, 64, device="cpu"))
|
| 664 |
+
|
| 665 |
+
@classmethod
|
| 666 |
+
def IS_CHANGED(s, image, **kwargs):
|
| 667 |
+
return hash_path(image)
|
| 668 |
+
|
| 669 |
+
@classmethod
|
| 670 |
+
def VALIDATE_INPUTS(s, image):
|
| 671 |
+
return validate_path(image, allow_none=True)
|
videohelpersuite/logger.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
import copy
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class ColoredFormatter(logging.Formatter):
|
| 7 |
+
COLORS = {
|
| 8 |
+
"DEBUG": "\033[0;36m", # CYAN
|
| 9 |
+
"INFO": "\033[0;32m", # GREEN
|
| 10 |
+
"WARNING": "\033[0;33m", # YELLOW
|
| 11 |
+
"ERROR": "\033[0;31m", # RED
|
| 12 |
+
"CRITICAL": "\033[0;37;41m", # WHITE ON RED
|
| 13 |
+
"RESET": "\033[0m", # RESET COLOR
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
def format(self, record):
|
| 17 |
+
colored_record = copy.copy(record)
|
| 18 |
+
levelname = colored_record.levelname
|
| 19 |
+
seq = self.COLORS.get(levelname, self.COLORS["RESET"])
|
| 20 |
+
colored_record.levelname = f"{seq}{levelname}{self.COLORS['RESET']}"
|
| 21 |
+
return super().format(colored_record)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# Create a new logger
|
| 25 |
+
logger = logging.getLogger("VideoHelperSuite")
|
| 26 |
+
logger.propagate = False
|
| 27 |
+
|
| 28 |
+
# Add handler if we don't have one.
|
| 29 |
+
if not logger.handlers:
|
| 30 |
+
handler = logging.StreamHandler(sys.stdout)
|
| 31 |
+
handler.setFormatter(ColoredFormatter("[%(name)s] - %(levelname)s - %(message)s"))
|
| 32 |
+
logger.addHandler(handler)
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
import json
|
| 4 |
+
import subprocess
|
| 5 |
+
import numpy as np
|
| 6 |
+
import re
|
| 7 |
+
import datetime
|
| 8 |
+
from typing import List
|
| 9 |
+
import torch
|
| 10 |
+
from PIL import Image, ExifTags
|
| 11 |
+
from PIL.PngImagePlugin import PngInfo
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
from string import Template
|
| 14 |
+
import itertools
|
| 15 |
+
import functools
|
| 16 |
+
|
| 17 |
+
import folder_paths
|
| 18 |
+
from .logger import logger
|
| 19 |
+
from .image_latent_nodes import *
|
| 20 |
+
from .load_video_nodes import LoadVideoUpload, LoadVideoPath, LoadVideoFFmpegUpload, LoadVideoFFmpegPath, LoadImagePath
|
| 21 |
+
from .load_images_nodes import LoadImagesFromDirectoryUpload, LoadImagesFromDirectoryPath
|
| 22 |
+
from .batched_nodes import VAEEncodeBatched, VAEDecodeBatched
|
| 23 |
+
from .utils import ffmpeg_path, get_audio, hash_path, validate_path, requeue_workflow, \
|
| 24 |
+
gifski_path, calculate_file_hash, strip_path, try_download_video, is_url, \
|
| 25 |
+
imageOrLatent, BIGMAX, merge_filter_args, ENCODE_ARGS, floatOrInt, cached, \
|
| 26 |
+
ContainsAll
|
| 27 |
+
from comfy.utils import ProgressBar
|
| 28 |
+
|
| 29 |
+
if 'VHS_video_formats' not in folder_paths.folder_names_and_paths:
|
| 30 |
+
folder_paths.folder_names_and_paths["VHS_video_formats"] = ((),{".json"})
|
| 31 |
+
if len(folder_paths.folder_names_and_paths['VHS_video_formats'][1]) == 0:
|
| 32 |
+
folder_paths.folder_names_and_paths["VHS_video_formats"][1].add(".json")
|
| 33 |
+
audio_extensions = ['mp3', 'mp4', 'wav', 'ogg']
|
| 34 |
+
|
| 35 |
+
def flatten_list(l):
|
| 36 |
+
ret = []
|
| 37 |
+
for e in l:
|
| 38 |
+
if isinstance(e, list):
|
| 39 |
+
ret.extend(e)
|
| 40 |
+
else:
|
| 41 |
+
ret.append(e)
|
| 42 |
+
return ret
|
| 43 |
+
|
| 44 |
+
def iterate_format(video_format, for_widgets=True):
|
| 45 |
+
"""Provides an iterator over widgets, or arguments"""
|
| 46 |
+
def indirector(cont, index):
|
| 47 |
+
if isinstance(cont[index], list) and (not for_widgets
|
| 48 |
+
or len(cont[index])> 1 and not isinstance(cont[index][1], dict)):
|
| 49 |
+
inp = yield cont[index]
|
| 50 |
+
if inp is not None:
|
| 51 |
+
cont[index] = inp
|
| 52 |
+
yield
|
| 53 |
+
for k in video_format:
|
| 54 |
+
if k == "extra_widgets":
|
| 55 |
+
if for_widgets:
|
| 56 |
+
yield from video_format["extra_widgets"]
|
| 57 |
+
elif k.endswith("_pass"):
|
| 58 |
+
for i in range(len(video_format[k])):
|
| 59 |
+
yield from indirector(video_format[k], i)
|
| 60 |
+
if not for_widgets:
|
| 61 |
+
video_format[k] = flatten_list(video_format[k])
|
| 62 |
+
else:
|
| 63 |
+
yield from indirector(video_format, k)
|
| 64 |
+
|
| 65 |
+
base_formats_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "video_formats")
|
| 66 |
+
@cached(5)
|
| 67 |
+
def get_video_formats():
|
| 68 |
+
format_files = {}
|
| 69 |
+
for format_name in folder_paths.get_filename_list("VHS_video_formats"):
|
| 70 |
+
format_files[format_name] = folder_paths.get_full_path("VHS_video_formats", format_name)
|
| 71 |
+
for item in os.scandir(base_formats_dir):
|
| 72 |
+
if not item.is_file() or not item.name.endswith('.json'):
|
| 73 |
+
continue
|
| 74 |
+
format_files[item.name[:-5]] = item.path
|
| 75 |
+
formats = []
|
| 76 |
+
format_widgets = {}
|
| 77 |
+
for format_name, path in format_files.items():
|
| 78 |
+
with open(path, 'r') as stream:
|
| 79 |
+
video_format = json.load(stream)
|
| 80 |
+
if "gifski_pass" in video_format and gifski_path is None:
|
| 81 |
+
#Skip format
|
| 82 |
+
continue
|
| 83 |
+
widgets = list(iterate_format(video_format))
|
| 84 |
+
formats.append("video/" + format_name)
|
| 85 |
+
if (len(widgets) > 0):
|
| 86 |
+
format_widgets["video/"+ format_name] = widgets
|
| 87 |
+
return formats, format_widgets
|
| 88 |
+
|
| 89 |
+
def apply_format_widgets(format_name, kwargs):
|
| 90 |
+
if os.path.exists(os.path.join(base_formats_dir, format_name + ".json")):
|
| 91 |
+
video_format_path = os.path.join(base_formats_dir, format_name + ".json")
|
| 92 |
+
else:
|
| 93 |
+
video_format_path = folder_paths.get_full_path("VHS_video_formats", format_name)
|
| 94 |
+
with open(video_format_path, 'r') as stream:
|
| 95 |
+
video_format = json.load(stream)
|
| 96 |
+
for w in iterate_format(video_format):
|
| 97 |
+
if w[0] not in kwargs:
|
| 98 |
+
if len(w) > 2 and 'default' in w[2]:
|
| 99 |
+
default = w[2]['default']
|
| 100 |
+
else:
|
| 101 |
+
if type(w[1]) is list:
|
| 102 |
+
default = w[1][0]
|
| 103 |
+
else:
|
| 104 |
+
#NOTE: This doesn't respect max/min, but should be good enough as a fallback to a fallback to a fallback
|
| 105 |
+
default = {"BOOLEAN": False, "INT": 0, "FLOAT": 0, "STRING": ""}[w[1]]
|
| 106 |
+
kwargs[w[0]] = default
|
| 107 |
+
logger.warn(f"Missing input for {w[0][0]} has been set to {default}")
|
| 108 |
+
wit = iterate_format(video_format, False)
|
| 109 |
+
for w in wit:
|
| 110 |
+
while isinstance(w, list):
|
| 111 |
+
if len(w) == 1:
|
| 112 |
+
#TODO: mapping=kwargs should be safer, but results in key errors, investigate why
|
| 113 |
+
w = [Template(x).substitute(**kwargs) for x in w[0]]
|
| 114 |
+
break
|
| 115 |
+
elif isinstance(w[1], dict):
|
| 116 |
+
w = w[1][str(kwargs[w[0]])]
|
| 117 |
+
elif len(w) > 3:
|
| 118 |
+
w = Template(w[3]).substitute(val=kwargs[w[0]])
|
| 119 |
+
else:
|
| 120 |
+
w = str(kwargs[w[0]])
|
| 121 |
+
wit.send(w)
|
| 122 |
+
return video_format
|
| 123 |
+
|
| 124 |
+
def tensor_to_int(tensor, bits):
|
| 125 |
+
tensor = tensor.cpu().numpy() * (2**bits-1) + 0.5
|
| 126 |
+
return np.clip(tensor, 0, (2**bits-1))
|
| 127 |
+
def tensor_to_shorts(tensor):
|
| 128 |
+
return tensor_to_int(tensor, 16).astype(np.uint16)
|
| 129 |
+
def tensor_to_bytes(tensor):
|
| 130 |
+
return tensor_to_int(tensor, 8).astype(np.uint8)
|
| 131 |
+
|
| 132 |
+
def ffmpeg_process(args, video_format, video_metadata, file_path, env):
|
| 133 |
+
|
| 134 |
+
res = None
|
| 135 |
+
frame_data = yield
|
| 136 |
+
total_frames_output = 0
|
| 137 |
+
if video_format.get('save_metadata', 'False') != 'False':
|
| 138 |
+
os.makedirs(folder_paths.get_temp_directory(), exist_ok=True)
|
| 139 |
+
metadata = json.dumps(video_metadata)
|
| 140 |
+
metadata_path = os.path.join(folder_paths.get_temp_directory(), "metadata.txt")
|
| 141 |
+
#metadata from file should escape = ; # \ and newline
|
| 142 |
+
metadata = metadata.replace("\\","\\\\")
|
| 143 |
+
metadata = metadata.replace(";","\\;")
|
| 144 |
+
metadata = metadata.replace("#","\\#")
|
| 145 |
+
metadata = metadata.replace("=","\\=")
|
| 146 |
+
metadata = metadata.replace("\n","\\\n")
|
| 147 |
+
metadata = "comment=" + metadata
|
| 148 |
+
with open(metadata_path, "w") as f:
|
| 149 |
+
f.write(";FFMETADATA1\n")
|
| 150 |
+
f.write(metadata)
|
| 151 |
+
m_args = args[:1] + ["-i", metadata_path] + args[1:] + ["-metadata", "creation_time=now"]
|
| 152 |
+
with subprocess.Popen(m_args + [file_path], stderr=subprocess.PIPE,
|
| 153 |
+
stdin=subprocess.PIPE, env=env) as proc:
|
| 154 |
+
try:
|
| 155 |
+
while frame_data is not None:
|
| 156 |
+
proc.stdin.write(frame_data)
|
| 157 |
+
#TODO: skip flush for increased speed
|
| 158 |
+
frame_data = yield
|
| 159 |
+
total_frames_output+=1
|
| 160 |
+
proc.stdin.flush()
|
| 161 |
+
proc.stdin.close()
|
| 162 |
+
res = proc.stderr.read()
|
| 163 |
+
except BrokenPipeError as e:
|
| 164 |
+
err = proc.stderr.read()
|
| 165 |
+
#Check if output file exists. If it does, the re-execution
|
| 166 |
+
#will also fail. This obscures the cause of the error
|
| 167 |
+
#and seems to never occur concurrent to the metadata issue
|
| 168 |
+
if os.path.exists(file_path):
|
| 169 |
+
raise Exception("An error occurred in the ffmpeg subprocess:\n" \
|
| 170 |
+
+ err.decode(*ENCODE_ARGS))
|
| 171 |
+
#Res was not set
|
| 172 |
+
print(err.decode(*ENCODE_ARGS), end="", file=sys.stderr)
|
| 173 |
+
logger.warn("An error occurred when saving with metadata")
|
| 174 |
+
if res != b'':
|
| 175 |
+
with subprocess.Popen(args + [file_path], stderr=subprocess.PIPE,
|
| 176 |
+
stdin=subprocess.PIPE, env=env) as proc:
|
| 177 |
+
try:
|
| 178 |
+
while frame_data is not None:
|
| 179 |
+
proc.stdin.write(frame_data)
|
| 180 |
+
frame_data = yield
|
| 181 |
+
total_frames_output+=1
|
| 182 |
+
proc.stdin.flush()
|
| 183 |
+
proc.stdin.close()
|
| 184 |
+
res = proc.stderr.read()
|
| 185 |
+
except BrokenPipeError as e:
|
| 186 |
+
res = proc.stderr.read()
|
| 187 |
+
raise Exception("An error occurred in the ffmpeg subprocess:\n" \
|
| 188 |
+
+ res.decode(*ENCODE_ARGS))
|
| 189 |
+
yield total_frames_output
|
| 190 |
+
if len(res) > 0:
|
| 191 |
+
print(res.decode(*ENCODE_ARGS), end="", file=sys.stderr)
|
| 192 |
+
|
| 193 |
+
def gifski_process(args, dimensions, frame_rate, video_format, file_path, env):
|
| 194 |
+
frame_data = yield
|
| 195 |
+
with subprocess.Popen(args + video_format['main_pass'] + ['-f', 'yuv4mpegpipe', '-'],
|
| 196 |
+
stderr=subprocess.PIPE, stdin=subprocess.PIPE,
|
| 197 |
+
stdout=subprocess.PIPE, env=env) as procff:
|
| 198 |
+
with subprocess.Popen([gifski_path] + video_format['gifski_pass']
|
| 199 |
+
+ ['-W', f'{dimensions[0]}', '-H', f'{dimensions[1]}']
|
| 200 |
+
+ ['-r', f'{frame_rate}']
|
| 201 |
+
+ ['-q', '-o', file_path, '-'], stderr=subprocess.PIPE,
|
| 202 |
+
stdin=procff.stdout, stdout=subprocess.PIPE,
|
| 203 |
+
env=env) as procgs:
|
| 204 |
+
try:
|
| 205 |
+
while frame_data is not None:
|
| 206 |
+
procff.stdin.write(frame_data)
|
| 207 |
+
frame_data = yield
|
| 208 |
+
procff.stdin.flush()
|
| 209 |
+
procff.stdin.close()
|
| 210 |
+
resff = procff.stderr.read()
|
| 211 |
+
resgs = procgs.stderr.read()
|
| 212 |
+
outgs = procgs.stdout.read()
|
| 213 |
+
except BrokenPipeError as e:
|
| 214 |
+
procff.stdin.close()
|
| 215 |
+
resff = procff.stderr.read()
|
| 216 |
+
resgs = procgs.stderr.read()
|
| 217 |
+
raise Exception("An error occurred while creating gifski output\n" \
|
| 218 |
+
+ "Make sure you are using gifski --version >=1.32.0\nffmpeg: " \
|
| 219 |
+
+ resff.decode(*ENCODE_ARGS) + '\ngifski: ' + resgs.decode(*ENCODE_ARGS))
|
| 220 |
+
if len(resff) > 0:
|
| 221 |
+
print(resff.decode(*ENCODE_ARGS), end="", file=sys.stderr)
|
| 222 |
+
if len(resgs) > 0:
|
| 223 |
+
print(resgs.decode(*ENCODE_ARGS), end="", file=sys.stderr)
|
| 224 |
+
#should always be empty as the quiet flag is passed
|
| 225 |
+
if len(outgs) > 0:
|
| 226 |
+
print(outgs.decode(*ENCODE_ARGS))
|
| 227 |
+
|
| 228 |
+
def to_pingpong(inp):
|
| 229 |
+
if not hasattr(inp, "__getitem__"):
|
| 230 |
+
inp = list(inp)
|
| 231 |
+
yield from inp
|
| 232 |
+
for i in range(len(inp)-2,0,-1):
|
| 233 |
+
yield inp[i]
|
| 234 |
+
|
| 235 |
+
class VideoCombine:
|
| 236 |
+
@classmethod
|
| 237 |
+
def INPUT_TYPES(s):
|
| 238 |
+
ffmpeg_formats, format_widgets = get_video_formats()
|
| 239 |
+
format_widgets["image/webp"] = [['lossless', "BOOLEAN", {'default': True}]]
|
| 240 |
+
return {
|
| 241 |
+
"required": {
|
| 242 |
+
"images": (imageOrLatent,),
|
| 243 |
+
"frame_rate": (
|
| 244 |
+
floatOrInt,
|
| 245 |
+
{"default": 8, "min": 1, "step": 1},
|
| 246 |
+
),
|
| 247 |
+
"loop_count": ("INT", {"default": 0, "min": 0, "max": 100, "step": 1}),
|
| 248 |
+
"filename_prefix": ("STRING", {"default": "AnimateDiff"}),
|
| 249 |
+
"format": (["image/gif", "image/webp"] + ffmpeg_formats, {'formats': format_widgets}),
|
| 250 |
+
"pingpong": ("BOOLEAN", {"default": False}),
|
| 251 |
+
"save_output": ("BOOLEAN", {"default": True}),
|
| 252 |
+
},
|
| 253 |
+
"optional": {
|
| 254 |
+
"audio": ("AUDIO",),
|
| 255 |
+
"meta_batch": ("VHS_BatchManager",),
|
| 256 |
+
"vae": ("VAE",),
|
| 257 |
+
},
|
| 258 |
+
"hidden": ContainsAll({
|
| 259 |
+
"prompt": "PROMPT",
|
| 260 |
+
"extra_pnginfo": "EXTRA_PNGINFO",
|
| 261 |
+
"unique_id": "UNIQUE_ID"
|
| 262 |
+
}),
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
RETURN_TYPES = ("VHS_FILENAMES",)
|
| 266 |
+
RETURN_NAMES = ("Filenames",)
|
| 267 |
+
OUTPUT_NODE = True
|
| 268 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 269 |
+
FUNCTION = "combine_video"
|
| 270 |
+
|
| 271 |
+
def combine_video(
|
| 272 |
+
self,
|
| 273 |
+
frame_rate: int,
|
| 274 |
+
loop_count: int,
|
| 275 |
+
images=None,
|
| 276 |
+
latents=None,
|
| 277 |
+
filename_prefix="AnimateDiff",
|
| 278 |
+
format="image/gif",
|
| 279 |
+
pingpong=False,
|
| 280 |
+
save_output=True,
|
| 281 |
+
prompt=None,
|
| 282 |
+
extra_pnginfo=None,
|
| 283 |
+
audio=None,
|
| 284 |
+
unique_id=None,
|
| 285 |
+
manual_format_widgets=None,
|
| 286 |
+
meta_batch=None,
|
| 287 |
+
vae=None,
|
| 288 |
+
**kwargs
|
| 289 |
+
):
|
| 290 |
+
if latents is not None:
|
| 291 |
+
images = latents
|
| 292 |
+
if images is None:
|
| 293 |
+
return ((save_output, []),)
|
| 294 |
+
if vae is not None:
|
| 295 |
+
if isinstance(images, dict):
|
| 296 |
+
images = images['samples']
|
| 297 |
+
else:
|
| 298 |
+
vae = None
|
| 299 |
+
|
| 300 |
+
if isinstance(images, torch.Tensor) and images.size(0) == 0:
|
| 301 |
+
return ((save_output, []),)
|
| 302 |
+
num_frames = len(images)
|
| 303 |
+
pbar = ProgressBar(num_frames)
|
| 304 |
+
if vae is not None:
|
| 305 |
+
downscale_ratio = getattr(vae, "downscale_ratio", 8)
|
| 306 |
+
width = images.size(-1)*downscale_ratio
|
| 307 |
+
height = images.size(-2)*downscale_ratio
|
| 308 |
+
frames_per_batch = (1920 * 1080 * 16) // (width * height) or 1
|
| 309 |
+
#Python 3.12 adds an itertools.batched, but it's easily replicated for legacy support
|
| 310 |
+
def batched(it, n):
|
| 311 |
+
while batch := tuple(itertools.islice(it, n)):
|
| 312 |
+
yield batch
|
| 313 |
+
def batched_encode(images, vae, frames_per_batch):
|
| 314 |
+
for batch in batched(iter(images), frames_per_batch):
|
| 315 |
+
image_batch = torch.from_numpy(np.array(batch))
|
| 316 |
+
yield from vae.decode(image_batch)
|
| 317 |
+
images = batched_encode(images, vae, frames_per_batch)
|
| 318 |
+
first_image = next(images)
|
| 319 |
+
#repush first_image
|
| 320 |
+
images = itertools.chain([first_image], images)
|
| 321 |
+
#A single image has 3 dimensions. Discard higher dimensions
|
| 322 |
+
while len(first_image.shape) > 3:
|
| 323 |
+
first_image = first_image[0]
|
| 324 |
+
else:
|
| 325 |
+
first_image = images[0]
|
| 326 |
+
images = iter(images)
|
| 327 |
+
# get output information
|
| 328 |
+
output_dir = (
|
| 329 |
+
folder_paths.get_output_directory()
|
| 330 |
+
if save_output
|
| 331 |
+
else folder_paths.get_temp_directory()
|
| 332 |
+
)
|
| 333 |
+
(
|
| 334 |
+
full_output_folder,
|
| 335 |
+
filename,
|
| 336 |
+
_,
|
| 337 |
+
subfolder,
|
| 338 |
+
_,
|
| 339 |
+
) = folder_paths.get_save_image_path(filename_prefix, output_dir)
|
| 340 |
+
output_files = []
|
| 341 |
+
|
| 342 |
+
metadata = PngInfo()
|
| 343 |
+
video_metadata = {}
|
| 344 |
+
if prompt is not None:
|
| 345 |
+
metadata.add_text("prompt", json.dumps(prompt))
|
| 346 |
+
video_metadata["prompt"] = json.dumps(prompt)
|
| 347 |
+
if extra_pnginfo is not None:
|
| 348 |
+
for x in extra_pnginfo:
|
| 349 |
+
metadata.add_text(x, json.dumps(extra_pnginfo[x]))
|
| 350 |
+
video_metadata[x] = extra_pnginfo[x]
|
| 351 |
+
extra_options = extra_pnginfo.get('workflow', {}).get('extra', {})
|
| 352 |
+
else:
|
| 353 |
+
extra_options = {}
|
| 354 |
+
metadata.add_text("CreationTime", datetime.datetime.now().isoformat(" ")[:19])
|
| 355 |
+
|
| 356 |
+
if meta_batch is not None and unique_id in meta_batch.outputs:
|
| 357 |
+
(counter, output_process) = meta_batch.outputs[unique_id]
|
| 358 |
+
else:
|
| 359 |
+
# comfy counter workaround
|
| 360 |
+
max_counter = 0
|
| 361 |
+
|
| 362 |
+
# Loop through the existing files
|
| 363 |
+
matcher = re.compile(f"{re.escape(filename)}_(\\d+)\\D*\\..+", re.IGNORECASE)
|
| 364 |
+
for existing_file in os.listdir(full_output_folder):
|
| 365 |
+
# Check if the file matches the expected format
|
| 366 |
+
match = matcher.fullmatch(existing_file)
|
| 367 |
+
if match:
|
| 368 |
+
# Extract the numeric portion of the filename
|
| 369 |
+
file_counter = int(match.group(1))
|
| 370 |
+
# Update the maximum counter value if necessary
|
| 371 |
+
if file_counter > max_counter:
|
| 372 |
+
max_counter = file_counter
|
| 373 |
+
|
| 374 |
+
# Increment the counter by 1 to get the next available value
|
| 375 |
+
counter = max_counter + 1
|
| 376 |
+
output_process = None
|
| 377 |
+
|
| 378 |
+
# save first frame as png to keep metadata
|
| 379 |
+
first_image_file = f"{filename}_{counter:05}.png"
|
| 380 |
+
file_path = os.path.join(full_output_folder, first_image_file)
|
| 381 |
+
if extra_options.get('VHS_MetadataImage', True) != False:
|
| 382 |
+
Image.fromarray(tensor_to_bytes(first_image)).save(
|
| 383 |
+
file_path,
|
| 384 |
+
pnginfo=metadata,
|
| 385 |
+
compress_level=4,
|
| 386 |
+
)
|
| 387 |
+
output_files.append(file_path)
|
| 388 |
+
|
| 389 |
+
format_type, format_ext = format.split("/")
|
| 390 |
+
if format_type == "image":
|
| 391 |
+
if meta_batch is not None:
|
| 392 |
+
raise Exception("Pillow('image/') formats are not compatible with batched output")
|
| 393 |
+
image_kwargs = {}
|
| 394 |
+
if format_ext == "gif":
|
| 395 |
+
image_kwargs['disposal'] = 2
|
| 396 |
+
if format_ext == "webp":
|
| 397 |
+
#Save timestamp information
|
| 398 |
+
exif = Image.Exif()
|
| 399 |
+
exif[ExifTags.IFD.Exif] = {36867: datetime.datetime.now().isoformat(" ")[:19]}
|
| 400 |
+
image_kwargs['exif'] = exif
|
| 401 |
+
image_kwargs['lossless'] = kwargs.get("lossless", True)
|
| 402 |
+
file = f"{filename}_{counter:05}.{format_ext}"
|
| 403 |
+
file_path = os.path.join(full_output_folder, file)
|
| 404 |
+
if pingpong:
|
| 405 |
+
images = to_pingpong(images)
|
| 406 |
+
def frames_gen(images):
|
| 407 |
+
for i in images:
|
| 408 |
+
pbar.update(1)
|
| 409 |
+
yield Image.fromarray(tensor_to_bytes(i))
|
| 410 |
+
frames = frames_gen(images)
|
| 411 |
+
# Use pillow directly to save an animated image
|
| 412 |
+
next(frames).save(
|
| 413 |
+
file_path,
|
| 414 |
+
format=format_ext.upper(),
|
| 415 |
+
save_all=True,
|
| 416 |
+
append_images=frames,
|
| 417 |
+
duration=round(1000 / frame_rate),
|
| 418 |
+
loop=loop_count,
|
| 419 |
+
compress_level=4,
|
| 420 |
+
**image_kwargs
|
| 421 |
+
)
|
| 422 |
+
output_files.append(file_path)
|
| 423 |
+
else:
|
| 424 |
+
# Use ffmpeg to save a video
|
| 425 |
+
if ffmpeg_path is None:
|
| 426 |
+
raise ProcessLookupError(f"ffmpeg is required for video outputs and could not be found.\nIn order to use video outputs, you must either:\n- Install imageio-ffmpeg with pip,\n- Place a ffmpeg executable in {os.path.abspath('')}, or\n- Install ffmpeg and add it to the system path.")
|
| 427 |
+
|
| 428 |
+
if manual_format_widgets is not None:
|
| 429 |
+
logger.warn("Format args can now be passed directly. The manual_format_widgets argument is now deprecated")
|
| 430 |
+
kwargs.update(manual_format_widgets)
|
| 431 |
+
|
| 432 |
+
has_alpha = first_image.shape[-1] == 4
|
| 433 |
+
kwargs["has_alpha"] = has_alpha
|
| 434 |
+
video_format = apply_format_widgets(format_ext, kwargs)
|
| 435 |
+
dim_alignment = video_format.get("dim_alignment", 2)
|
| 436 |
+
if (first_image.shape[1] % dim_alignment) or (first_image.shape[0] % dim_alignment):
|
| 437 |
+
#output frames must be padded
|
| 438 |
+
to_pad = (-first_image.shape[1] % dim_alignment,
|
| 439 |
+
-first_image.shape[0] % dim_alignment)
|
| 440 |
+
padding = (to_pad[0]//2, to_pad[0] - to_pad[0]//2,
|
| 441 |
+
to_pad[1]//2, to_pad[1] - to_pad[1]//2)
|
| 442 |
+
padfunc = torch.nn.ReplicationPad2d(padding)
|
| 443 |
+
def pad(image):
|
| 444 |
+
image = image.permute((2,0,1))#HWC to CHW
|
| 445 |
+
padded = padfunc(image.to(dtype=torch.float32))
|
| 446 |
+
return padded.permute((1,2,0))
|
| 447 |
+
images = map(pad, images)
|
| 448 |
+
dimensions = (-first_image.shape[1] % dim_alignment + first_image.shape[1],
|
| 449 |
+
-first_image.shape[0] % dim_alignment + first_image.shape[0])
|
| 450 |
+
logger.warn("Output images were not of valid resolution and have had padding applied")
|
| 451 |
+
else:
|
| 452 |
+
dimensions = (first_image.shape[1], first_image.shape[0])
|
| 453 |
+
if pingpong:
|
| 454 |
+
if meta_batch is not None:
|
| 455 |
+
logger.error("pingpong is incompatible with batched output")
|
| 456 |
+
images = to_pingpong(images)
|
| 457 |
+
if num_frames > 2:
|
| 458 |
+
num_frames += num_frames -2
|
| 459 |
+
pbar.total = num_frames
|
| 460 |
+
if loop_count > 0:
|
| 461 |
+
loop_args = ["-vf", "loop=loop=" + str(loop_count)+":size=" + str(num_frames)]
|
| 462 |
+
else:
|
| 463 |
+
loop_args = []
|
| 464 |
+
if video_format.get('input_color_depth', '8bit') == '16bit':
|
| 465 |
+
images = map(tensor_to_shorts, images)
|
| 466 |
+
if has_alpha:
|
| 467 |
+
i_pix_fmt = 'rgba64'
|
| 468 |
+
else:
|
| 469 |
+
i_pix_fmt = 'rgb48'
|
| 470 |
+
else:
|
| 471 |
+
images = map(tensor_to_bytes, images)
|
| 472 |
+
if has_alpha:
|
| 473 |
+
i_pix_fmt = 'rgba'
|
| 474 |
+
else:
|
| 475 |
+
i_pix_fmt = 'rgb24'
|
| 476 |
+
file = f"{filename}_{counter:05}.{video_format['extension']}"
|
| 477 |
+
file_path = os.path.join(full_output_folder, file)
|
| 478 |
+
bitrate_arg = []
|
| 479 |
+
bitrate = video_format.get('bitrate')
|
| 480 |
+
if bitrate is not None:
|
| 481 |
+
bitrate_arg = ["-b:v", str(bitrate) + "M" if video_format.get('megabit') == 'True' else str(bitrate) + "K"]
|
| 482 |
+
args = [ffmpeg_path, "-v", "error", "-f", "rawvideo", "-pix_fmt", i_pix_fmt,
|
| 483 |
+
# The image data is in an undefined generic RGB color space, which in practice means sRGB.
|
| 484 |
+
# sRGB has the same primaries and matrix as BT.709, but a different transfer function (gamma),
|
| 485 |
+
# called by the sRGB standard name IEC 61966-2-1. However, video hosting platforms like YouTube
|
| 486 |
+
# standardize on full BT.709 and will convert the colors accordingly. This last minute change
|
| 487 |
+
# in colors can be confusing to users. We can counter it by lying about the transfer function
|
| 488 |
+
# on a per format basis, i.e. for video we will lie to FFmpeg that it is already BT.709. Also,
|
| 489 |
+
# because the input data is in RGB (not YUV) it is more efficient (fewer scale filter invocations)
|
| 490 |
+
# to specify the input color space as RGB and then later, if the format actually wants YUV,
|
| 491 |
+
# to convert it to BT.709 YUV via FFmpeg's -vf "scale=out_color_matrix=bt709".
|
| 492 |
+
"-color_range", "pc", "-colorspace", "rgb", "-color_primaries", "bt709",
|
| 493 |
+
"-color_trc", video_format.get("fake_trc", "iec61966-2-1"),
|
| 494 |
+
"-s", f"{dimensions[0]}x{dimensions[1]}", "-r", str(frame_rate), "-i", "-"] \
|
| 495 |
+
+ loop_args
|
| 496 |
+
|
| 497 |
+
images = map(lambda x: x.tobytes(), images)
|
| 498 |
+
env=os.environ.copy()
|
| 499 |
+
if "environment" in video_format:
|
| 500 |
+
env.update(video_format["environment"])
|
| 501 |
+
|
| 502 |
+
if "pre_pass" in video_format:
|
| 503 |
+
if meta_batch is not None:
|
| 504 |
+
#Performing a prepass requires keeping access to all frames.
|
| 505 |
+
#Potential solutions include keeping just output frames in
|
| 506 |
+
#memory or using 3 passes with intermediate file, but
|
| 507 |
+
#very long gifs probably shouldn't be encouraged
|
| 508 |
+
raise Exception("Formats which require a pre_pass are incompatible with Batch Manager.")
|
| 509 |
+
images = [b''.join(images)]
|
| 510 |
+
os.makedirs(folder_paths.get_temp_directory(), exist_ok=True)
|
| 511 |
+
in_args_len = args.index("-i") + 2 # The index after ["-i", "-"]
|
| 512 |
+
pre_pass_args = args[:in_args_len] + video_format['pre_pass']
|
| 513 |
+
merge_filter_args(pre_pass_args)
|
| 514 |
+
try:
|
| 515 |
+
subprocess.run(pre_pass_args, input=images[0], env=env,
|
| 516 |
+
capture_output=True, check=True)
|
| 517 |
+
except subprocess.CalledProcessError as e:
|
| 518 |
+
raise Exception("An error occurred in the ffmpeg prepass:\n" \
|
| 519 |
+
+ e.stderr.decode(*ENCODE_ARGS))
|
| 520 |
+
if "inputs_main_pass" in video_format:
|
| 521 |
+
in_args_len = args.index("-i") + 2 # The index after ["-i", "-"]
|
| 522 |
+
args = args[:in_args_len] + video_format['inputs_main_pass'] + args[in_args_len:]
|
| 523 |
+
|
| 524 |
+
if output_process is None:
|
| 525 |
+
if 'gifski_pass' in video_format:
|
| 526 |
+
format = 'image/gif'
|
| 527 |
+
output_process = gifski_process(args, dimensions, frame_rate, video_format, file_path, env)
|
| 528 |
+
audio = None
|
| 529 |
+
else:
|
| 530 |
+
args += video_format['main_pass'] + bitrate_arg
|
| 531 |
+
merge_filter_args(args)
|
| 532 |
+
output_process = ffmpeg_process(args, video_format, video_metadata, file_path, env)
|
| 533 |
+
#Proceed to first yield
|
| 534 |
+
output_process.send(None)
|
| 535 |
+
if meta_batch is not None:
|
| 536 |
+
meta_batch.outputs[unique_id] = (counter, output_process)
|
| 537 |
+
|
| 538 |
+
for image in images:
|
| 539 |
+
pbar.update(1)
|
| 540 |
+
output_process.send(image)
|
| 541 |
+
if meta_batch is not None:
|
| 542 |
+
requeue_workflow((meta_batch.unique_id, not meta_batch.has_closed_inputs))
|
| 543 |
+
if meta_batch is None or meta_batch.has_closed_inputs:
|
| 544 |
+
#Close pipe and wait for termination.
|
| 545 |
+
try:
|
| 546 |
+
total_frames_output = output_process.send(None)
|
| 547 |
+
output_process.send(None)
|
| 548 |
+
except StopIteration:
|
| 549 |
+
pass
|
| 550 |
+
if meta_batch is not None:
|
| 551 |
+
meta_batch.outputs.pop(unique_id)
|
| 552 |
+
if len(meta_batch.outputs) == 0:
|
| 553 |
+
meta_batch.reset()
|
| 554 |
+
else:
|
| 555 |
+
#batch is unfinished
|
| 556 |
+
#TODO: Check if empty output breaks other custom nodes
|
| 557 |
+
return {"ui": {"unfinished_batch": [True]}, "result": ((save_output, []),)}
|
| 558 |
+
|
| 559 |
+
output_files.append(file_path)
|
| 560 |
+
|
| 561 |
+
|
| 562 |
+
a_waveform = None
|
| 563 |
+
if audio is not None:
|
| 564 |
+
try:
|
| 565 |
+
#safely check if audio produced by VHS_LoadVideo actually exists
|
| 566 |
+
a_waveform = audio['waveform']
|
| 567 |
+
except:
|
| 568 |
+
pass
|
| 569 |
+
if a_waveform is not None:
|
| 570 |
+
# Create audio file if input was provided
|
| 571 |
+
output_file_with_audio = f"{filename}_{counter:05}-audio.{video_format['extension']}"
|
| 572 |
+
output_file_with_audio_path = os.path.join(full_output_folder, output_file_with_audio)
|
| 573 |
+
if "audio_pass" not in video_format:
|
| 574 |
+
logger.warn("Selected video format does not have explicit audio support")
|
| 575 |
+
video_format["audio_pass"] = ["-c:a", "libopus"]
|
| 576 |
+
|
| 577 |
+
|
| 578 |
+
# FFmpeg command with audio re-encoding
|
| 579 |
+
#TODO: expose audio quality options if format widgets makes it in
|
| 580 |
+
#Reconsider forcing apad/shortest
|
| 581 |
+
channels = audio['waveform'].size(1)
|
| 582 |
+
min_audio_dur = total_frames_output / frame_rate + 1
|
| 583 |
+
if video_format.get('trim_to_audio', 'False') != 'False':
|
| 584 |
+
apad = []
|
| 585 |
+
else:
|
| 586 |
+
apad = ["-af", "apad=whole_dur="+str(min_audio_dur)]
|
| 587 |
+
mux_args = [ffmpeg_path, "-v", "error", "-n", "-i", file_path,
|
| 588 |
+
"-ar", str(audio['sample_rate']), "-ac", str(channels),
|
| 589 |
+
"-f", "f32le", "-i", "-", "-c:v", "copy"] \
|
| 590 |
+
+ video_format["audio_pass"] \
|
| 591 |
+
+ apad + ["-shortest", output_file_with_audio_path]
|
| 592 |
+
|
| 593 |
+
audio_data = audio['waveform'].squeeze(0).transpose(0,1) \
|
| 594 |
+
.numpy().tobytes()
|
| 595 |
+
merge_filter_args(mux_args, '-af')
|
| 596 |
+
try:
|
| 597 |
+
res = subprocess.run(mux_args, input=audio_data,
|
| 598 |
+
env=env, capture_output=True, check=True)
|
| 599 |
+
except subprocess.CalledProcessError as e:
|
| 600 |
+
raise Exception("An error occured in the ffmpeg subprocess:\n" \
|
| 601 |
+
+ e.stderr.decode(*ENCODE_ARGS))
|
| 602 |
+
if res.stderr:
|
| 603 |
+
print(res.stderr.decode(*ENCODE_ARGS), end="", file=sys.stderr)
|
| 604 |
+
output_files.append(output_file_with_audio_path)
|
| 605 |
+
#Return this file with audio to the webui.
|
| 606 |
+
#It will be muted unless opened or saved with right click
|
| 607 |
+
file = output_file_with_audio
|
| 608 |
+
if extra_options.get('VHS_KeepIntermediate', True) == False:
|
| 609 |
+
for intermediate in output_files[1:-1]:
|
| 610 |
+
if os.path.exists(intermediate):
|
| 611 |
+
os.remove(intermediate)
|
| 612 |
+
preview = {
|
| 613 |
+
"filename": file,
|
| 614 |
+
"subfolder": subfolder,
|
| 615 |
+
"type": "output" if save_output else "temp",
|
| 616 |
+
"format": format,
|
| 617 |
+
"frame_rate": frame_rate,
|
| 618 |
+
"workflow": first_image_file,
|
| 619 |
+
"fullpath": output_files[-1],
|
| 620 |
+
}
|
| 621 |
+
if num_frames == 1 and 'png' in format and '%03d' in file:
|
| 622 |
+
preview['format'] = 'image/png'
|
| 623 |
+
preview['filename'] = file.replace('%03d', '001')
|
| 624 |
+
return {"ui": {"gifs": [preview]}, "result": ((save_output, output_files),)}
|
| 625 |
+
|
| 626 |
+
class LoadAudio:
|
| 627 |
+
@classmethod
|
| 628 |
+
def INPUT_TYPES(s):
|
| 629 |
+
#Hide ffmpeg formats if ffmpeg isn't available
|
| 630 |
+
return {
|
| 631 |
+
"required": {
|
| 632 |
+
"audio_file": ("STRING", {"default": "input/", "vhs_path_extensions": ['wav','mp3','ogg','m4a','flac']}),
|
| 633 |
+
},
|
| 634 |
+
"optional" : {
|
| 635 |
+
"seek_seconds": ("FLOAT", {"default": 0, "min": 0, "widgetType": "VHSTIMESTAMP"}),
|
| 636 |
+
"duration": ("FLOAT" , {"default": 0, "min": 0, "max": 10000000, "step": 0.01, "widgetType": "VHSTIMESTAMP"}),
|
| 637 |
+
}
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
RETURN_TYPES = ("AUDIO", "FLOAT")
|
| 641 |
+
RETURN_NAMES = ("audio", "duration")
|
| 642 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/audio"
|
| 643 |
+
FUNCTION = "load_audio"
|
| 644 |
+
def load_audio(self, audio_file, seek_seconds=0, duration=0):
|
| 645 |
+
audio_file = strip_path(audio_file)
|
| 646 |
+
if audio_file is None or validate_path(audio_file) != True:
|
| 647 |
+
raise Exception("audio_file is not a valid path: " + audio_file)
|
| 648 |
+
if is_url(audio_file):
|
| 649 |
+
audio_file = try_download_video(audio_file) or audio_file
|
| 650 |
+
#Eagerly fetch the audio since the user must be using it if the
|
| 651 |
+
#node executes, unlike Load Video
|
| 652 |
+
audio = get_audio(audio_file, start_time=seek_seconds, duration=duration)
|
| 653 |
+
loaded_duration = audio['waveform'].size(2)/audio['sample_rate']
|
| 654 |
+
return (audio, loaded_duration)
|
| 655 |
+
|
| 656 |
+
@classmethod
|
| 657 |
+
def IS_CHANGED(s, audio_file, **kwargs):
|
| 658 |
+
return hash_path(audio_file)
|
| 659 |
+
|
| 660 |
+
@classmethod
|
| 661 |
+
def VALIDATE_INPUTS(s, audio_file, **kwargs):
|
| 662 |
+
return validate_path(audio_file, allow_none=True)
|
| 663 |
+
|
| 664 |
+
class LoadAudioUpload:
|
| 665 |
+
@classmethod
|
| 666 |
+
def INPUT_TYPES(s):
|
| 667 |
+
input_dir = folder_paths.get_input_directory()
|
| 668 |
+
files = []
|
| 669 |
+
for f in os.listdir(input_dir):
|
| 670 |
+
if os.path.isfile(os.path.join(input_dir, f)):
|
| 671 |
+
file_parts = f.split('.')
|
| 672 |
+
if len(file_parts) > 1 and (file_parts[-1] in audio_extensions):
|
| 673 |
+
files.append(f)
|
| 674 |
+
return {"required": {
|
| 675 |
+
"audio": (sorted(files),),},
|
| 676 |
+
"optional": {
|
| 677 |
+
"start_time": ("FLOAT" , {"default": 0, "min": 0, "max": 10000000, "step": 0.01, "widgetType": "VHSTIMESTAMP"}),
|
| 678 |
+
"duration": ("FLOAT" , {"default": 0, "min": 0, "max": 10000000, "step": 0.01, "widgetType": "VHSTIMESTAMP"}),
|
| 679 |
+
},
|
| 680 |
+
}
|
| 681 |
+
|
| 682 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/audio"
|
| 683 |
+
|
| 684 |
+
RETURN_TYPES = ("AUDIO", "FLOAT")
|
| 685 |
+
RETURN_NAMES = ("audio", "duration")
|
| 686 |
+
FUNCTION = "load_audio"
|
| 687 |
+
|
| 688 |
+
def load_audio(self, start_time=0, duration=0, **kwargs):
|
| 689 |
+
audio_file = folder_paths.get_annotated_filepath(strip_path(kwargs['audio']))
|
| 690 |
+
if audio_file is None or validate_path(audio_file) != True:
|
| 691 |
+
raise Exception("audio_file is not a valid path: " + audio_file)
|
| 692 |
+
|
| 693 |
+
audio = get_audio(audio_file, start_time, duration)
|
| 694 |
+
loaded_duration = audio['waveform'].size(2)/audio['sample_rate']
|
| 695 |
+
return (audio, loaded_duration)
|
| 696 |
+
|
| 697 |
+
@classmethod
|
| 698 |
+
def IS_CHANGED(s, audio, **kwargs):
|
| 699 |
+
audio_file = folder_paths.get_annotated_filepath(strip_path(audio))
|
| 700 |
+
return hash_path(audio_file)
|
| 701 |
+
|
| 702 |
+
@classmethod
|
| 703 |
+
def VALIDATE_INPUTS(s, audio, **kwargs):
|
| 704 |
+
audio_file = folder_paths.get_annotated_filepath(strip_path(audio))
|
| 705 |
+
return validate_path(audio_file, allow_none=True)
|
| 706 |
+
class AudioToVHSAudio:
|
| 707 |
+
"""Legacy method for external nodes that utilized VHS_AUDIO,
|
| 708 |
+
VHS_AUDIO is deprecated as a format and should no longer be used"""
|
| 709 |
+
@classmethod
|
| 710 |
+
def INPUT_TYPES(s):
|
| 711 |
+
return {"required": {"audio": ("AUDIO",)}}
|
| 712 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/audio"
|
| 713 |
+
|
| 714 |
+
RETURN_TYPES = ("VHS_AUDIO", )
|
| 715 |
+
RETURN_NAMES = ("vhs_audio",)
|
| 716 |
+
FUNCTION = "convert_audio"
|
| 717 |
+
|
| 718 |
+
def convert_audio(self, audio):
|
| 719 |
+
ar = str(audio['sample_rate'])
|
| 720 |
+
ac = str(audio['waveform'].size(1))
|
| 721 |
+
mux_args = [ffmpeg_path, "-f", "f32le", "-ar", ar, "-ac", ac,
|
| 722 |
+
"-i", "-", "-f", "wav", "-"]
|
| 723 |
+
|
| 724 |
+
audio_data = audio['waveform'].squeeze(0).transpose(0,1) \
|
| 725 |
+
.numpy().tobytes()
|
| 726 |
+
try:
|
| 727 |
+
res = subprocess.run(mux_args, input=audio_data,
|
| 728 |
+
capture_output=True, check=True)
|
| 729 |
+
except subprocess.CalledProcessError as e:
|
| 730 |
+
raise Exception("An error occured in the ffmpeg subprocess:\n" \
|
| 731 |
+
+ e.stderr.decode(*ENCODE_ARGS))
|
| 732 |
+
if res.stderr:
|
| 733 |
+
print(res.stderr.decode(*ENCODE_ARGS), end="", file=sys.stderr)
|
| 734 |
+
return (lambda: res.stdout,)
|
| 735 |
+
|
| 736 |
+
class VHSAudioToAudio:
|
| 737 |
+
"""Legacy method for external nodes that utilized VHS_AUDIO,
|
| 738 |
+
VHS_AUDIO is deprecated as a format and should no longer be used"""
|
| 739 |
+
@classmethod
|
| 740 |
+
def INPUT_TYPES(s):
|
| 741 |
+
return {"required": {"vhs_audio": ("VHS_AUDIO",)}}
|
| 742 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢/audio"
|
| 743 |
+
|
| 744 |
+
RETURN_TYPES = ("AUDIO", )
|
| 745 |
+
RETURN_NAMES = ("audio",)
|
| 746 |
+
FUNCTION = "convert_audio"
|
| 747 |
+
|
| 748 |
+
def convert_audio(self, vhs_audio):
|
| 749 |
+
if not vhs_audio or not vhs_audio():
|
| 750 |
+
raise Exception("audio input is not valid")
|
| 751 |
+
args = [ffmpeg_path, "-i", '-']
|
| 752 |
+
try:
|
| 753 |
+
res = subprocess.run(args + ["-f", "f32le", "-"], input=vhs_audio(),
|
| 754 |
+
capture_output=True, check=True)
|
| 755 |
+
audio = torch.frombuffer(bytearray(res.stdout), dtype=torch.float32)
|
| 756 |
+
except subprocess.CalledProcessError as e:
|
| 757 |
+
raise Exception("An error occured in the ffmpeg subprocess:\n" \
|
| 758 |
+
+ e.stderr.decode(*ENCODE_ARGS))
|
| 759 |
+
match = re.search(', (\\d+) Hz, (\\w+), ',res.stderr.decode(*ENCODE_ARGS))
|
| 760 |
+
if match:
|
| 761 |
+
ar = int(match.group(1))
|
| 762 |
+
#NOTE: Just throwing an error for other channel types right now
|
| 763 |
+
#Will deal with issues if they come
|
| 764 |
+
ac = {"mono": 1, "stereo": 2}[match.group(2)]
|
| 765 |
+
else:
|
| 766 |
+
ar = 44100
|
| 767 |
+
ac = 2
|
| 768 |
+
audio = audio.reshape((-1,ac)).transpose(0,1).unsqueeze(0)
|
| 769 |
+
return ({'waveform': audio, 'sample_rate': ar},)
|
| 770 |
+
|
| 771 |
+
class PruneOutputs:
|
| 772 |
+
@classmethod
|
| 773 |
+
def INPUT_TYPES(s):
|
| 774 |
+
return {
|
| 775 |
+
"required": {
|
| 776 |
+
"filenames": ("VHS_FILENAMES",),
|
| 777 |
+
"options": (["Intermediate", "Intermediate and Utility"],)
|
| 778 |
+
}
|
| 779 |
+
}
|
| 780 |
+
|
| 781 |
+
RETURN_TYPES = ()
|
| 782 |
+
OUTPUT_NODE = True
|
| 783 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 784 |
+
FUNCTION = "prune_outputs"
|
| 785 |
+
|
| 786 |
+
def prune_outputs(self, filenames, options):
|
| 787 |
+
if len(filenames[1]) == 0:
|
| 788 |
+
return ()
|
| 789 |
+
assert(len(filenames[1]) <= 3 and len(filenames[1]) >= 2)
|
| 790 |
+
delete_list = []
|
| 791 |
+
if options in ["Intermediate", "Intermediate and Utility", "All"]:
|
| 792 |
+
delete_list += filenames[1][1:-1]
|
| 793 |
+
if options in ["Intermediate and Utility", "All"]:
|
| 794 |
+
delete_list.append(filenames[1][0])
|
| 795 |
+
if options in ["All"]:
|
| 796 |
+
delete_list.append(filenames[1][-1])
|
| 797 |
+
|
| 798 |
+
output_dirs = [folder_paths.get_output_directory(),
|
| 799 |
+
folder_paths.get_temp_directory()]
|
| 800 |
+
for file in delete_list:
|
| 801 |
+
#Check that path is actually an output directory
|
| 802 |
+
if (os.path.commonpath([output_dirs[0], file]) != output_dirs[0]) \
|
| 803 |
+
and (os.path.commonpath([output_dirs[1], file]) != output_dirs[1]):
|
| 804 |
+
raise Exception("Tried to prune output from invalid directory: " + file)
|
| 805 |
+
if os.path.exists(file):
|
| 806 |
+
os.remove(file)
|
| 807 |
+
return ()
|
| 808 |
+
|
| 809 |
+
class BatchManager:
|
| 810 |
+
def __init__(self, frames_per_batch=-1):
|
| 811 |
+
self.frames_per_batch = frames_per_batch
|
| 812 |
+
self.inputs = {}
|
| 813 |
+
self.outputs = {}
|
| 814 |
+
self.unique_id = None
|
| 815 |
+
self.has_closed_inputs = False
|
| 816 |
+
self.total_frames = float('inf')
|
| 817 |
+
def reset(self):
|
| 818 |
+
self.close_inputs()
|
| 819 |
+
for key in self.outputs:
|
| 820 |
+
if getattr(self.outputs[key][-1], "gi_suspended", False):
|
| 821 |
+
try:
|
| 822 |
+
self.outputs[key][-1].send(None)
|
| 823 |
+
except StopIteration:
|
| 824 |
+
pass
|
| 825 |
+
self.__init__(self.frames_per_batch)
|
| 826 |
+
def has_open_inputs(self):
|
| 827 |
+
return len(self.inputs) > 0
|
| 828 |
+
def close_inputs(self):
|
| 829 |
+
for key in self.inputs:
|
| 830 |
+
if getattr(self.inputs[key][-1], "gi_suspended", False):
|
| 831 |
+
try:
|
| 832 |
+
self.inputs[key][-1].send(1)
|
| 833 |
+
except StopIteration:
|
| 834 |
+
pass
|
| 835 |
+
self.inputs = {}
|
| 836 |
+
|
| 837 |
+
@classmethod
|
| 838 |
+
def INPUT_TYPES(s):
|
| 839 |
+
return {
|
| 840 |
+
"required": {
|
| 841 |
+
"frames_per_batch": ("INT", {"default": 16, "min": 1, "max": BIGMAX, "step": 1})
|
| 842 |
+
},
|
| 843 |
+
"hidden": {
|
| 844 |
+
"prompt": "PROMPT",
|
| 845 |
+
"unique_id": "UNIQUE_ID"
|
| 846 |
+
},
|
| 847 |
+
}
|
| 848 |
+
|
| 849 |
+
RETURN_TYPES = ("VHS_BatchManager",)
|
| 850 |
+
RETURN_NAMES = ("meta_batch",)
|
| 851 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 852 |
+
FUNCTION = "update_batch"
|
| 853 |
+
|
| 854 |
+
def update_batch(self, frames_per_batch, prompt=None, unique_id=None):
|
| 855 |
+
if unique_id is not None and prompt is not None:
|
| 856 |
+
requeue = prompt[unique_id]['inputs'].get('requeue', 0)
|
| 857 |
+
else:
|
| 858 |
+
requeue = 0
|
| 859 |
+
if requeue == 0:
|
| 860 |
+
self.reset()
|
| 861 |
+
self.frames_per_batch = frames_per_batch
|
| 862 |
+
self.unique_id = unique_id
|
| 863 |
+
else:
|
| 864 |
+
num_batches = (self.total_frames+self.frames_per_batch-1)//frames_per_batch
|
| 865 |
+
print(f'Meta-Batch {requeue}/{num_batches}')
|
| 866 |
+
#onExecuted seems to not be called unless some message is sent
|
| 867 |
+
return (self,)
|
| 868 |
+
|
| 869 |
+
|
| 870 |
+
class VideoInfo:
|
| 871 |
+
@classmethod
|
| 872 |
+
def INPUT_TYPES(s):
|
| 873 |
+
return {
|
| 874 |
+
"required": {
|
| 875 |
+
"video_info": ("VHS_VIDEOINFO",),
|
| 876 |
+
}
|
| 877 |
+
}
|
| 878 |
+
|
| 879 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 880 |
+
|
| 881 |
+
RETURN_TYPES = ("FLOAT","INT", "FLOAT", "INT", "INT", "FLOAT","INT", "FLOAT", "INT", "INT")
|
| 882 |
+
RETURN_NAMES = (
|
| 883 |
+
"source_fps🟨",
|
| 884 |
+
"source_frame_count🟨",
|
| 885 |
+
"source_duration🟨",
|
| 886 |
+
"source_width🟨",
|
| 887 |
+
"source_height🟨",
|
| 888 |
+
"loaded_fps🟦",
|
| 889 |
+
"loaded_frame_count🟦",
|
| 890 |
+
"loaded_duration🟦",
|
| 891 |
+
"loaded_width🟦",
|
| 892 |
+
"loaded_height🟦",
|
| 893 |
+
)
|
| 894 |
+
FUNCTION = "get_video_info"
|
| 895 |
+
|
| 896 |
+
def get_video_info(self, video_info):
|
| 897 |
+
keys = ["fps", "frame_count", "duration", "width", "height"]
|
| 898 |
+
|
| 899 |
+
source_info = []
|
| 900 |
+
loaded_info = []
|
| 901 |
+
|
| 902 |
+
for key in keys:
|
| 903 |
+
source_info.append(video_info[f"source_{key}"])
|
| 904 |
+
loaded_info.append(video_info[f"loaded_{key}"])
|
| 905 |
+
|
| 906 |
+
return (*source_info, *loaded_info)
|
| 907 |
+
|
| 908 |
+
|
| 909 |
+
class VideoInfoSource:
|
| 910 |
+
@classmethod
|
| 911 |
+
def INPUT_TYPES(s):
|
| 912 |
+
return {
|
| 913 |
+
"required": {
|
| 914 |
+
"video_info": ("VHS_VIDEOINFO",),
|
| 915 |
+
}
|
| 916 |
+
}
|
| 917 |
+
|
| 918 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 919 |
+
|
| 920 |
+
RETURN_TYPES = ("FLOAT","INT", "FLOAT", "INT", "INT",)
|
| 921 |
+
RETURN_NAMES = (
|
| 922 |
+
"fps🟨",
|
| 923 |
+
"frame_count🟨",
|
| 924 |
+
"duration🟨",
|
| 925 |
+
"width🟨",
|
| 926 |
+
"height🟨",
|
| 927 |
+
)
|
| 928 |
+
FUNCTION = "get_video_info"
|
| 929 |
+
|
| 930 |
+
def get_video_info(self, video_info):
|
| 931 |
+
keys = ["fps", "frame_count", "duration", "width", "height"]
|
| 932 |
+
|
| 933 |
+
source_info = []
|
| 934 |
+
|
| 935 |
+
for key in keys:
|
| 936 |
+
source_info.append(video_info[f"source_{key}"])
|
| 937 |
+
|
| 938 |
+
return (*source_info,)
|
| 939 |
+
|
| 940 |
+
|
| 941 |
+
class VideoInfoLoaded:
|
| 942 |
+
@classmethod
|
| 943 |
+
def INPUT_TYPES(s):
|
| 944 |
+
return {
|
| 945 |
+
"required": {
|
| 946 |
+
"video_info": ("VHS_VIDEOINFO",),
|
| 947 |
+
}
|
| 948 |
+
}
|
| 949 |
+
|
| 950 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 951 |
+
|
| 952 |
+
RETURN_TYPES = ("FLOAT","INT", "FLOAT", "INT", "INT",)
|
| 953 |
+
RETURN_NAMES = (
|
| 954 |
+
"fps🟦",
|
| 955 |
+
"frame_count🟦",
|
| 956 |
+
"duration🟦",
|
| 957 |
+
"width🟦",
|
| 958 |
+
"height🟦",
|
| 959 |
+
)
|
| 960 |
+
FUNCTION = "get_video_info"
|
| 961 |
+
|
| 962 |
+
def get_video_info(self, video_info):
|
| 963 |
+
keys = ["fps", "frame_count", "duration", "width", "height"]
|
| 964 |
+
|
| 965 |
+
loaded_info = []
|
| 966 |
+
|
| 967 |
+
for key in keys:
|
| 968 |
+
loaded_info.append(video_info[f"loaded_{key}"])
|
| 969 |
+
|
| 970 |
+
return (*loaded_info,)
|
| 971 |
+
|
| 972 |
+
class SelectFilename:
|
| 973 |
+
@classmethod
|
| 974 |
+
def INPUT_TYPES(s):
|
| 975 |
+
return {"required": {"filenames": ("VHS_FILENAMES",), "index": ("INT", {"default": -1, "step": 1, "min": -1})}}
|
| 976 |
+
RETURN_TYPES = ("STRING",)
|
| 977 |
+
RETURN_NAMES =("Filename",)
|
| 978 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 979 |
+
FUNCTION = "select_filename"
|
| 980 |
+
|
| 981 |
+
def select_filename(self, filenames, index):
|
| 982 |
+
return (filenames[1][index],)
|
| 983 |
+
class Unbatch:
|
| 984 |
+
class Any(str):
|
| 985 |
+
def __ne__(self, other):
|
| 986 |
+
return False
|
| 987 |
+
@classmethod
|
| 988 |
+
def INPUT_TYPES(s):
|
| 989 |
+
return {"required": {"batched": ("*",)}}
|
| 990 |
+
RETURN_TYPES = (Any('*'),)
|
| 991 |
+
INPUT_IS_LIST = True
|
| 992 |
+
RETURN_NAMES =("unbatched",)
|
| 993 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 994 |
+
FUNCTION = "unbatch"
|
| 995 |
+
def unbatch(self, batched):
|
| 996 |
+
if isinstance(batched[0], torch.Tensor):
|
| 997 |
+
return (torch.cat(batched),)
|
| 998 |
+
if isinstance(batched[0], dict):
|
| 999 |
+
out = batched[0].copy()
|
| 1000 |
+
if 'samples' in out:
|
| 1001 |
+
out['samples'] = torch.cat([x['samples'] for x in batched])
|
| 1002 |
+
if 'waveform' in out:
|
| 1003 |
+
out['waveform'] = torch.cat([x['waveform'] for x in batched])
|
| 1004 |
+
out.pop('batch_index', None)
|
| 1005 |
+
return (out,)
|
| 1006 |
+
return (functools.reduce(lambda x,y: x+y, batched),)
|
| 1007 |
+
@classmethod
|
| 1008 |
+
def VALIDATE_INPUTS(cls, input_types):
|
| 1009 |
+
return True
|
| 1010 |
+
class SelectLatest:
|
| 1011 |
+
@classmethod
|
| 1012 |
+
def INPUT_TYPES(s):
|
| 1013 |
+
return {"required": {"filename_prefix": ("STRING", {'default': 'output/AnimateDiff', 'vhs_path_extensions': []}),
|
| 1014 |
+
"filename_postfix": ("STRING", {"placeholder": ".webm"})}}
|
| 1015 |
+
RETURN_TYPES = ("STRING",)
|
| 1016 |
+
RETURN_NAMES =("Filename",)
|
| 1017 |
+
CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
|
| 1018 |
+
FUNCTION = "select_latest"
|
| 1019 |
+
EXPERIMENTAL = True
|
| 1020 |
+
|
| 1021 |
+
def select_latest(self, filename_prefix, filename_postfix):
|
| 1022 |
+
assert False, "Not Reachable"
|
| 1023 |
+
|
| 1024 |
+
NODE_CLASS_MAPPINGS = {
|
| 1025 |
+
"VHS_VideoCombine": VideoCombine,
|
| 1026 |
+
"VHS_LoadVideo": LoadVideoUpload,
|
| 1027 |
+
"VHS_LoadVideoPath": LoadVideoPath,
|
| 1028 |
+
"VHS_LoadVideoFFmpeg": LoadVideoFFmpegUpload,
|
| 1029 |
+
"VHS_LoadVideoFFmpegPath": LoadVideoFFmpegPath,
|
| 1030 |
+
"VHS_LoadImagePath": LoadImagePath,
|
| 1031 |
+
"VHS_LoadImages": LoadImagesFromDirectoryUpload,
|
| 1032 |
+
"VHS_LoadImagesPath": LoadImagesFromDirectoryPath,
|
| 1033 |
+
"VHS_LoadAudio": LoadAudio,
|
| 1034 |
+
"VHS_LoadAudioUpload": LoadAudioUpload,
|
| 1035 |
+
"VHS_AudioToVHSAudio": AudioToVHSAudio,
|
| 1036 |
+
"VHS_VHSAudioToAudio": VHSAudioToAudio,
|
| 1037 |
+
"VHS_PruneOutputs": PruneOutputs,
|
| 1038 |
+
"VHS_BatchManager": BatchManager,
|
| 1039 |
+
"VHS_VideoInfo": VideoInfo,
|
| 1040 |
+
"VHS_VideoInfoSource": VideoInfoSource,
|
| 1041 |
+
"VHS_VideoInfoLoaded": VideoInfoLoaded,
|
| 1042 |
+
"VHS_SelectFilename": SelectFilename,
|
| 1043 |
+
# Batched Nodes
|
| 1044 |
+
"VHS_VAEEncodeBatched": VAEEncodeBatched,
|
| 1045 |
+
"VHS_VAEDecodeBatched": VAEDecodeBatched,
|
| 1046 |
+
# Latent and Image nodes
|
| 1047 |
+
"VHS_SplitLatents": SplitLatents,
|
| 1048 |
+
"VHS_SplitImages": SplitImages,
|
| 1049 |
+
"VHS_SplitMasks": SplitMasks,
|
| 1050 |
+
"VHS_MergeLatents": MergeLatents,
|
| 1051 |
+
"VHS_MergeImages": MergeImages,
|
| 1052 |
+
"VHS_MergeMasks": MergeMasks,
|
| 1053 |
+
"VHS_GetLatentCount": GetLatentCount,
|
| 1054 |
+
"VHS_GetImageCount": GetImageCount,
|
| 1055 |
+
"VHS_GetMaskCount": GetMaskCount,
|
| 1056 |
+
"VHS_DuplicateLatents": RepeatLatents,
|
| 1057 |
+
"VHS_DuplicateImages": RepeatImages,
|
| 1058 |
+
"VHS_DuplicateMasks": RepeatMasks,
|
| 1059 |
+
"VHS_SelectEveryNthLatent": SelectEveryNthLatent,
|
| 1060 |
+
"VHS_SelectEveryNthImage": SelectEveryNthImage,
|
| 1061 |
+
"VHS_SelectEveryNthMask": SelectEveryNthMask,
|
| 1062 |
+
"VHS_SelectLatents": SelectLatents,
|
| 1063 |
+
"VHS_SelectImages": SelectImages,
|
| 1064 |
+
"VHS_SelectMasks": SelectMasks,
|
| 1065 |
+
"VHS_Unbatch": Unbatch,
|
| 1066 |
+
"VHS_SelectLatest": SelectLatest,
|
| 1067 |
+
}
|
| 1068 |
+
NODE_DISPLAY_NAME_MAPPINGS = {
|
| 1069 |
+
"VHS_VideoCombine": "Video Combine 🎥🅥🅗🅢",
|
| 1070 |
+
"VHS_LoadVideo": "Load Video (Upload) 🎥🅥🅗🅢",
|
| 1071 |
+
"VHS_LoadVideoPath": "Load Video (Path) 🎥🅥🅗🅢",
|
| 1072 |
+
"VHS_LoadVideoFFmpeg": "Load Video FFmpeg (Upload) 🎥🅥🅗🅢",
|
| 1073 |
+
"VHS_LoadVideoFFmpegPath": "Load Video FFmpeg (Path) 🎥🅥🅗🅢",
|
| 1074 |
+
"VHS_LoadImagePath": "Load Image (Path) 🎥🅥🅗🅢",
|
| 1075 |
+
"VHS_LoadImages": "Load Images (Upload) 🎥🅥🅗🅢",
|
| 1076 |
+
"VHS_LoadImagesPath": "Load Images (Path) 🎥🅥🅗🅢",
|
| 1077 |
+
"VHS_LoadAudio": "Load Audio (Path)🎥🅥🅗🅢",
|
| 1078 |
+
"VHS_LoadAudioUpload": "Load Audio (Upload)🎥🅥🅗🅢",
|
| 1079 |
+
"VHS_AudioToVHSAudio": "Audio to legacy VHS_AUDIO🎥🅥🅗🅢",
|
| 1080 |
+
"VHS_VHSAudioToAudio": "Legacy VHS_AUDIO to Audio🎥🅥🅗🅢",
|
| 1081 |
+
"VHS_PruneOutputs": "Prune Outputs 🎥🅥🅗🅢",
|
| 1082 |
+
"VHS_BatchManager": "Meta Batch Manager 🎥🅥🅗🅢",
|
| 1083 |
+
"VHS_VideoInfo": "Video Info 🎥🅥🅗🅢",
|
| 1084 |
+
"VHS_VideoInfoSource": "Video Info (Source) 🎥🅥🅗🅢",
|
| 1085 |
+
"VHS_VideoInfoLoaded": "Video Info (Loaded) 🎥🅥🅗🅢",
|
| 1086 |
+
"VHS_SelectFilename": "Select Filename 🎥🅥🅗🅢",
|
| 1087 |
+
# Batched Nodes
|
| 1088 |
+
"VHS_VAEEncodeBatched": "VAE Encode Batched 🎥🅥🅗🅢",
|
| 1089 |
+
"VHS_VAEDecodeBatched": "VAE Decode Batched 🎥🅥🅗🅢",
|
| 1090 |
+
# Latent and Image nodes
|
| 1091 |
+
"VHS_SplitLatents": "Split Latents 🎥🅥🅗🅢",
|
| 1092 |
+
"VHS_SplitImages": "Split Images 🎥🅥🅗🅢",
|
| 1093 |
+
"VHS_SplitMasks": "Split Masks 🎥🅥🅗🅢",
|
| 1094 |
+
"VHS_MergeLatents": "Merge Latents 🎥🅥🅗🅢",
|
| 1095 |
+
"VHS_MergeImages": "Merge Images 🎥🅥🅗🅢",
|
| 1096 |
+
"VHS_MergeMasks": "Merge Masks 🎥🅥🅗🅢",
|
| 1097 |
+
"VHS_GetLatentCount": "Get Latent Count 🎥🅥🅗🅢",
|
| 1098 |
+
"VHS_GetImageCount": "Get Image Count 🎥🅥🅗🅢",
|
| 1099 |
+
"VHS_GetMaskCount": "Get Mask Count 🎥🅥🅗🅢",
|
| 1100 |
+
"VHS_DuplicateLatents": "Repeat Latents 🎥🅥🅗🅢",
|
| 1101 |
+
"VHS_DuplicateImages": "Repeat Images 🎥🅥🅗🅢",
|
| 1102 |
+
"VHS_DuplicateMasks": "Repeat Masks 🎥🅥🅗🅢",
|
| 1103 |
+
"VHS_SelectEveryNthLatent": "Select Every Nth Latent 🎥🅥🅗🅢",
|
| 1104 |
+
"VHS_SelectEveryNthImage": "Select Every Nth Image 🎥🅥🅗🅢",
|
| 1105 |
+
"VHS_SelectEveryNthMask": "Select Every Nth Mask 🎥🅥🅗🅢",
|
| 1106 |
+
"VHS_SelectLatents": "Select Latents 🎥🅥🅗🅢",
|
| 1107 |
+
"VHS_SelectImages": "Select Images 🎥🅥🅗🅢",
|
| 1108 |
+
"VHS_SelectMasks": "Select Masks 🎥🅥🅗🅢",
|
| 1109 |
+
"VHS_Unbatch": "Unbatch 🎥🅥🅗🅢",
|
| 1110 |
+
"VHS_SelectLatest": "Select Latest 🎥🅥🅗🅢",
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import server
|
| 2 |
+
import folder_paths
|
| 3 |
+
import os
|
| 4 |
+
import subprocess
|
| 5 |
+
import re
|
| 6 |
+
|
| 7 |
+
import asyncio
|
| 8 |
+
import av
|
| 9 |
+
|
| 10 |
+
from .utils import is_url, get_sorted_dir_files_from_directory, ffmpeg_path, \
|
| 11 |
+
validate_sequence, is_safe_path, strip_path, try_download_video, ENCODE_ARGS
|
| 12 |
+
from comfy.k_diffusion.utils import FolderOfImages
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
web = server.web
|
| 16 |
+
|
| 17 |
+
@server.PromptServer.instance.routes.get("/vhs/viewvideo")
|
| 18 |
+
@server.PromptServer.instance.routes.get("/viewvideo")
|
| 19 |
+
async def view_video(request):
|
| 20 |
+
query = request.rel_url.query
|
| 21 |
+
path_res = await resolve_path(query)
|
| 22 |
+
if isinstance(path_res, web.Response):
|
| 23 |
+
return path_res
|
| 24 |
+
file, filename, output_dir = path_res
|
| 25 |
+
|
| 26 |
+
if ffmpeg_path is None:
|
| 27 |
+
#Don't just return file, that provides arbitrary read access to any file
|
| 28 |
+
if is_safe_path(output_dir, strict=True):
|
| 29 |
+
return web.FileResponse(path=file)
|
| 30 |
+
|
| 31 |
+
frame_rate = query.get('frame_rate', 8)
|
| 32 |
+
if query.get('format', 'video') == "folder":
|
| 33 |
+
os.makedirs(folder_paths.get_temp_directory(), exist_ok=True)
|
| 34 |
+
concat_file = os.path.join(folder_paths.get_temp_directory(), "image_sequence_preview.txt")
|
| 35 |
+
skip_first_images = int(query.get('skip_first_images', 0))
|
| 36 |
+
select_every_nth = int(query.get('select_every_nth', 1)) or 1
|
| 37 |
+
valid_images = get_sorted_dir_files_from_directory(file, skip_first_images, select_every_nth, FolderOfImages.IMG_EXTENSIONS)
|
| 38 |
+
if len(valid_images) == 0:
|
| 39 |
+
return web.Response(status=204)
|
| 40 |
+
with open(concat_file, "w") as f:
|
| 41 |
+
f.write("ffconcat version 1.0\n")
|
| 42 |
+
for path in valid_images:
|
| 43 |
+
f.write("file '" + os.path.abspath(path) + "'\n")
|
| 44 |
+
f.write("duration 0.125\n")
|
| 45 |
+
in_args = ["-safe", "0", "-i", concat_file]
|
| 46 |
+
else:
|
| 47 |
+
in_args = ["-i", file]
|
| 48 |
+
if '%' in file:
|
| 49 |
+
in_args = ['-framerate', str(frame_rate)] + in_args
|
| 50 |
+
#Do prepass to pull info
|
| 51 |
+
#breaks skip_first frames if this default is ever actually needed
|
| 52 |
+
base_fps = 30
|
| 53 |
+
try:
|
| 54 |
+
proc = await asyncio.create_subprocess_exec(ffmpeg_path, *in_args, '-t',
|
| 55 |
+
'0','-f', 'null','-', stdout=subprocess.PIPE,
|
| 56 |
+
stderr=subprocess.PIPE, stdin=subprocess.DEVNULL)
|
| 57 |
+
_, res_stderr = await proc.communicate()
|
| 58 |
+
|
| 59 |
+
match = re.search(': Video: (\\w+) .+, (\\d+) fps,', res_stderr.decode(*ENCODE_ARGS))
|
| 60 |
+
if match:
|
| 61 |
+
base_fps = float(match.group(2))
|
| 62 |
+
if match.group(1) == 'vp9':
|
| 63 |
+
#force libvpx for transparency
|
| 64 |
+
in_args = ['-c:v', 'libvpx-vp9'] + in_args
|
| 65 |
+
except subprocess.CalledProcessError as e:
|
| 66 |
+
print("An error occurred in the ffmpeg prepass:\n" \
|
| 67 |
+
+ e.stderr.decode(*ENCODE_ARGS))
|
| 68 |
+
return web.Response(status=500)
|
| 69 |
+
vfilters = []
|
| 70 |
+
target_rate = float(query.get('force_rate', 0)) or base_fps
|
| 71 |
+
modified_rate = target_rate / (float(query.get('select_every_nth',1)) or 1)
|
| 72 |
+
start_time = 0
|
| 73 |
+
if 'start_time' in query:
|
| 74 |
+
start_time = float(query['start_time'])
|
| 75 |
+
elif float(query.get('skip_first_frames', 0)) > 0:
|
| 76 |
+
start_time = float(query.get('skip_first_frames'))/target_rate
|
| 77 |
+
if start_time > 1/modified_rate:
|
| 78 |
+
start_time += 1/modified_rate
|
| 79 |
+
if start_time > 0:
|
| 80 |
+
if start_time > 4:
|
| 81 |
+
post_seek = ['-ss', '4']
|
| 82 |
+
pre_seek = ['-ss', str(start_time - 4)]
|
| 83 |
+
else:
|
| 84 |
+
post_seek = ['-ss', str(start_time)]
|
| 85 |
+
pre_seek = []
|
| 86 |
+
else:
|
| 87 |
+
pre_seek = []
|
| 88 |
+
post_seek = []
|
| 89 |
+
|
| 90 |
+
args = [ffmpeg_path, "-v", "error"] + pre_seek + in_args + post_seek
|
| 91 |
+
if target_rate != 0:
|
| 92 |
+
args += ['-r', str(modified_rate)]
|
| 93 |
+
if query.get('force_size','Disabled') != "Disabled":
|
| 94 |
+
size = query['force_size'].split('x')
|
| 95 |
+
if size[0] == '?' or size[1] == '?':
|
| 96 |
+
size[0] = "-2" if size[0] == '?' else f"'min({size[0]},iw)'"
|
| 97 |
+
size[1] = "-2" if size[1] == '?' else f"'min({size[1]},ih)'"
|
| 98 |
+
else:
|
| 99 |
+
#Aspect ratio is likely changed. A more complex command is required
|
| 100 |
+
#to crop the output to the new aspect ratio
|
| 101 |
+
ar = float(size[0])/float(size[1])
|
| 102 |
+
vfilters.append(f"crop=if(gt({ar}\\,a)\\,iw\\,ih*{ar}):if(gt({ar}\\,a)\\,iw/{ar}\\,ih)")
|
| 103 |
+
size = ':'.join(size)
|
| 104 |
+
vfilters.append(f"scale={size}")
|
| 105 |
+
if len(vfilters) > 0:
|
| 106 |
+
args += ["-vf", ",".join(vfilters)]
|
| 107 |
+
if float(query.get('frame_load_cap', 0)) > 0:
|
| 108 |
+
args += ["-frames:v", query['frame_load_cap'].split('.')[0]]
|
| 109 |
+
#TODO:reconsider adding high frame cap/setting default frame cap on node
|
| 110 |
+
if query.get('deadline', 'realtime') == 'good':
|
| 111 |
+
deadline = 'good'
|
| 112 |
+
else:
|
| 113 |
+
deadline = 'realtime'
|
| 114 |
+
|
| 115 |
+
args += ['-c:v', 'libvpx-vp9','-deadline', deadline, '-cpu-used', '8', '-f', 'webm', '-']
|
| 116 |
+
|
| 117 |
+
try:
|
| 118 |
+
proc = await asyncio.create_subprocess_exec(*args, stdout=subprocess.PIPE,
|
| 119 |
+
stdin=subprocess.DEVNULL)
|
| 120 |
+
try:
|
| 121 |
+
resp = web.StreamResponse()
|
| 122 |
+
resp.content_type = 'video/webm'
|
| 123 |
+
resp.headers["Content-Disposition"] = f"filename=\"{filename}\""
|
| 124 |
+
await resp.prepare(request)
|
| 125 |
+
while len(bytes_read := await proc.stdout.read(2**20)) != 0:
|
| 126 |
+
await resp.write(bytes_read)
|
| 127 |
+
#Of dubious value given frequency of kill calls, but more correct
|
| 128 |
+
await proc.wait()
|
| 129 |
+
except (ConnectionResetError, ConnectionError) as e:
|
| 130 |
+
proc.kill()
|
| 131 |
+
except BrokenPipeError as e:
|
| 132 |
+
pass
|
| 133 |
+
return resp
|
| 134 |
+
@server.PromptServer.instance.routes.get("/vhs/viewaudio")
|
| 135 |
+
async def view_audio(request):
|
| 136 |
+
query = request.rel_url.query
|
| 137 |
+
path_res = await resolve_path(query)
|
| 138 |
+
if isinstance(path_res, web.Response):
|
| 139 |
+
return path_res
|
| 140 |
+
file, filename, output_dir = path_res
|
| 141 |
+
if ffmpeg_path is None:
|
| 142 |
+
#Don't just return file, that provides arbitrary read access to any file
|
| 143 |
+
if is_safe_path(output_dir, strict=True):
|
| 144 |
+
return web.FileResponse(path=file)
|
| 145 |
+
|
| 146 |
+
in_args = ["-i", file]
|
| 147 |
+
start_time = 0
|
| 148 |
+
if 'start_time' in query:
|
| 149 |
+
start_time = float(query['start_time'])
|
| 150 |
+
args = [ffmpeg_path, "-v", "error", '-vn'] + in_args + ['-ss', str(start_time)]
|
| 151 |
+
if float(query.get('duration', 0)) > 0:
|
| 152 |
+
args += ['-t', str(query['duration'])]
|
| 153 |
+
if query.get('deadline', 'realtime') == 'good':
|
| 154 |
+
deadline = 'good'
|
| 155 |
+
else:
|
| 156 |
+
deadline = 'realtime'
|
| 157 |
+
|
| 158 |
+
args += ['-c:a', 'libopus','-deadline', deadline, '-cpu-used', '8', '-f', 'webm', '-']
|
| 159 |
+
try:
|
| 160 |
+
proc = await asyncio.create_subprocess_exec(*args, stdout=subprocess.PIPE,
|
| 161 |
+
stdin=subprocess.DEVNULL)
|
| 162 |
+
try:
|
| 163 |
+
resp = web.StreamResponse()
|
| 164 |
+
resp.content_type = 'audio/webm'
|
| 165 |
+
resp.headers["Content-Disposition"] = f"filename=\"{filename}\""
|
| 166 |
+
await resp.prepare(request)
|
| 167 |
+
while len(bytes_read := await proc.stdout.read(2**20)) != 0:
|
| 168 |
+
await resp.write(bytes_read)
|
| 169 |
+
#Of dubious value given frequency of kill calls, but more correct
|
| 170 |
+
await proc.wait()
|
| 171 |
+
except (ConnectionResetError, ConnectionError) as e:
|
| 172 |
+
proc.kill()
|
| 173 |
+
except BrokenPipeError as e:
|
| 174 |
+
pass
|
| 175 |
+
return resp
|
| 176 |
+
|
| 177 |
+
query_cache = {}
|
| 178 |
+
@server.PromptServer.instance.routes.get("/vhs/queryvideo")
|
| 179 |
+
async def query_video(request):
|
| 180 |
+
query = request.rel_url.query
|
| 181 |
+
filepath = await resolve_path(query)
|
| 182 |
+
#TODO: cache lookup
|
| 183 |
+
if isinstance(filepath, web.Response):
|
| 184 |
+
return filepath
|
| 185 |
+
filepath = filepath[0]
|
| 186 |
+
if filepath.endswith(".webp"):
|
| 187 |
+
# ffmpeg doesn't support decoding animated WebP https://trac.ffmpeg.org/ticket/4907
|
| 188 |
+
return web.json_response({})
|
| 189 |
+
if filepath in query_cache and query_cache[filepath][0] == os.stat(filepath).st_mtime:
|
| 190 |
+
source = query_cache[filepath][1]
|
| 191 |
+
else:
|
| 192 |
+
source = {}
|
| 193 |
+
try:
|
| 194 |
+
with av.open(filepath) as cont:
|
| 195 |
+
stream = cont.streams.video[0]
|
| 196 |
+
source['fps'] = float(stream.average_rate)
|
| 197 |
+
source['duration'] = float(cont.duration / av.time_base)
|
| 198 |
+
|
| 199 |
+
if stream.codec_context.name == 'vp9':
|
| 200 |
+
cc = av.Codec('libvpx-vp9', 'r').create()
|
| 201 |
+
else:
|
| 202 |
+
cc = stream
|
| 203 |
+
def fit():
|
| 204 |
+
for packet in cont.demux(video=0):
|
| 205 |
+
yield from cc.decode(packet)
|
| 206 |
+
frame = next(fit())
|
| 207 |
+
|
| 208 |
+
source['size'] = [frame.width, frame.height]
|
| 209 |
+
source['alpha'] = 'a' in frame.format.name
|
| 210 |
+
source['frames'] = stream.metadata.get('NUMBER_OF_FRAMES', round(source['duration'] * source['fps']))
|
| 211 |
+
query_cache[filepath] = (os.stat(filepath).st_mtime, source)
|
| 212 |
+
except Exception:
|
| 213 |
+
pass
|
| 214 |
+
if not 'frames' in source:
|
| 215 |
+
return web.json_response({})
|
| 216 |
+
loaded = {}
|
| 217 |
+
loaded['duration'] = source['duration']
|
| 218 |
+
loaded['duration'] -= float(query.get('start_time',0))
|
| 219 |
+
loaded['fps'] = float(query.get('force_rate', 0)) or source.get('fps',1)
|
| 220 |
+
loaded['duration'] -= int(query.get('skip_first_frames', 0)) / loaded['fps']
|
| 221 |
+
loaded['fps'] /= int(query.get('select_every_nth', 1)) or 1
|
| 222 |
+
loaded['frames'] = round(loaded['duration'] * loaded['fps'])
|
| 223 |
+
return web.json_response({'source': source, 'loaded': loaded})
|
| 224 |
+
|
| 225 |
+
async def resolve_path(query):
|
| 226 |
+
if "filename" not in query:
|
| 227 |
+
return web.Response(status=204)
|
| 228 |
+
filename = query["filename"]
|
| 229 |
+
|
| 230 |
+
#Path code misformats urls on windows and must be skipped
|
| 231 |
+
if is_url(filename):
|
| 232 |
+
file = await asyncio.to_thread(try_download_video, filename) or file
|
| 233 |
+
filname, output_dir = os.path.split(file)
|
| 234 |
+
return file, filename, output_dir
|
| 235 |
+
else:
|
| 236 |
+
filename, output_dir = folder_paths.annotated_filepath(filename)
|
| 237 |
+
|
| 238 |
+
type = query.get("type", "output")
|
| 239 |
+
if type == "path":
|
| 240 |
+
#special case for path_based nodes
|
| 241 |
+
#NOTE: output_dir may be empty, but non-None
|
| 242 |
+
output_dir, filename = os.path.split(strip_path(filename))
|
| 243 |
+
if output_dir is None:
|
| 244 |
+
output_dir = folder_paths.get_directory_by_type(type)
|
| 245 |
+
|
| 246 |
+
if output_dir is None:
|
| 247 |
+
return web.Response(status=204)
|
| 248 |
+
|
| 249 |
+
if not is_safe_path(output_dir):
|
| 250 |
+
return web.Response(status=204)
|
| 251 |
+
|
| 252 |
+
if "subfolder" in query:
|
| 253 |
+
output_dir = os.path.join(output_dir, query["subfolder"])
|
| 254 |
+
|
| 255 |
+
filename = os.path.basename(filename)
|
| 256 |
+
file = os.path.join(output_dir, filename)
|
| 257 |
+
|
| 258 |
+
if not os.path.exists(file):
|
| 259 |
+
return web.Response(status=204)
|
| 260 |
+
if query.get('format', 'video') == 'folder':
|
| 261 |
+
if not os.path.isdir(file):
|
| 262 |
+
return web.Response(status=204)
|
| 263 |
+
else:
|
| 264 |
+
if not os.path.isfile(file) and not validate_sequence(file):
|
| 265 |
+
return web.Response(status=204)
|
| 266 |
+
return file, filename, output_dir
|
| 267 |
+
|
| 268 |
+
@server.PromptServer.instance.routes.get("/vhs/getpath")
|
| 269 |
+
@server.PromptServer.instance.routes.get("/getpath")
|
| 270 |
+
async def get_path(request):
|
| 271 |
+
query = request.rel_url.query
|
| 272 |
+
if "path" not in query:
|
| 273 |
+
return web.Response(status=204)
|
| 274 |
+
#NOTE: path always ends in `/`, so this is functionally an lstrip
|
| 275 |
+
path = os.path.abspath(strip_path(query["path"]))
|
| 276 |
+
|
| 277 |
+
if not os.path.exists(path) or not is_safe_path(path):
|
| 278 |
+
return web.json_response([])
|
| 279 |
+
|
| 280 |
+
#Use get so None is default instead of keyerror
|
| 281 |
+
valid_extensions = query.get("extensions")
|
| 282 |
+
valid_items = []
|
| 283 |
+
for item in os.scandir(path):
|
| 284 |
+
try:
|
| 285 |
+
if item.is_dir():
|
| 286 |
+
valid_items.append(item.name + "/")
|
| 287 |
+
continue
|
| 288 |
+
if valid_extensions is None or item.name.split(".")[-1].lower() in valid_extensions:
|
| 289 |
+
valid_items.append(item.name)
|
| 290 |
+
except OSError:
|
| 291 |
+
#Broken symlinks can throw a very unhelpful "Invalid argument"
|
| 292 |
+
pass
|
| 293 |
+
valid_items.sort(key=lambda f: os.stat(os.path.join(path,f)).st_mtime)
|
| 294 |
+
return web.json_response(valid_items)
|
videohelpersuite/utils.py
ADDED
|
@@ -0,0 +1,426 @@
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import hashlib
|
| 2 |
+
import os
|
| 3 |
+
from typing import Iterable
|
| 4 |
+
import shutil
|
| 5 |
+
import subprocess
|
| 6 |
+
import re
|
| 7 |
+
import time
|
| 8 |
+
from collections.abc import Mapping
|
| 9 |
+
from typing import Union
|
| 10 |
+
import functools
|
| 11 |
+
import torch
|
| 12 |
+
from torch import Tensor
|
| 13 |
+
|
| 14 |
+
import server
|
| 15 |
+
from .logger import logger
|
| 16 |
+
import folder_paths
|
| 17 |
+
|
| 18 |
+
BIGMIN = -(2**53-1)
|
| 19 |
+
BIGMAX = (2**53-1)
|
| 20 |
+
|
| 21 |
+
DIMMAX = 8192
|
| 22 |
+
|
| 23 |
+
ENCODE_ARGS = ("utf-8", 'backslashreplace')
|
| 24 |
+
|
| 25 |
+
def ffmpeg_suitability(path):
|
| 26 |
+
try:
|
| 27 |
+
version = subprocess.run([path, "-version"], check=True,
|
| 28 |
+
capture_output=True).stdout.decode(*ENCODE_ARGS)
|
| 29 |
+
except:
|
| 30 |
+
return 0
|
| 31 |
+
score = 0
|
| 32 |
+
#rough layout of the importance of various features
|
| 33 |
+
simple_criterion = [("libvpx", 20),("264",10), ("265",3),
|
| 34 |
+
("svtav1",5),("libopus", 1)]
|
| 35 |
+
for criterion in simple_criterion:
|
| 36 |
+
if version.find(criterion[0]) >= 0:
|
| 37 |
+
score += criterion[1]
|
| 38 |
+
#obtain rough compile year from copyright information
|
| 39 |
+
copyright_index = version.find('2000-2')
|
| 40 |
+
if copyright_index >= 0:
|
| 41 |
+
copyright_year = version[copyright_index+6:copyright_index+9]
|
| 42 |
+
if copyright_year.isnumeric():
|
| 43 |
+
score += int(copyright_year)
|
| 44 |
+
return score
|
| 45 |
+
|
| 46 |
+
class MultiInput(str):
|
| 47 |
+
def __new__(cls, string, allowed_types="*"):
|
| 48 |
+
res = super().__new__(cls, string)
|
| 49 |
+
res.allowed_types=allowed_types
|
| 50 |
+
return res
|
| 51 |
+
def __ne__(self, other):
|
| 52 |
+
if self.allowed_types == "*" or other == "*":
|
| 53 |
+
return False
|
| 54 |
+
return other not in self.allowed_types
|
| 55 |
+
imageOrLatent = MultiInput("IMAGE", ["IMAGE", "LATENT"])
|
| 56 |
+
floatOrInt = MultiInput("FLOAT", ["FLOAT", "INT"])
|
| 57 |
+
|
| 58 |
+
class ContainsAll(dict):
|
| 59 |
+
def __contains__(self, other):
|
| 60 |
+
return True
|
| 61 |
+
def __getitem__(self, key):
|
| 62 |
+
return super().get(key, (None, {}))
|
| 63 |
+
|
| 64 |
+
if "VHS_FORCE_FFMPEG_PATH" in os.environ:
|
| 65 |
+
ffmpeg_path = os.environ.get("VHS_FORCE_FFMPEG_PATH")
|
| 66 |
+
else:
|
| 67 |
+
ffmpeg_paths = []
|
| 68 |
+
try:
|
| 69 |
+
from imageio_ffmpeg import get_ffmpeg_exe
|
| 70 |
+
imageio_ffmpeg_path = get_ffmpeg_exe()
|
| 71 |
+
ffmpeg_paths.append(imageio_ffmpeg_path)
|
| 72 |
+
except:
|
| 73 |
+
if "VHS_USE_IMAGEIO_FFMPEG" in os.environ:
|
| 74 |
+
raise
|
| 75 |
+
logger.warn("Failed to import imageio_ffmpeg")
|
| 76 |
+
if "VHS_USE_IMAGEIO_FFMPEG" in os.environ:
|
| 77 |
+
ffmpeg_path = imageio_ffmpeg_path
|
| 78 |
+
else:
|
| 79 |
+
system_ffmpeg = shutil.which("ffmpeg")
|
| 80 |
+
if system_ffmpeg is not None:
|
| 81 |
+
ffmpeg_paths.append(system_ffmpeg)
|
| 82 |
+
if os.path.isfile("ffmpeg"):
|
| 83 |
+
ffmpeg_paths.append(os.path.abspath("ffmpeg"))
|
| 84 |
+
if os.path.isfile("ffmpeg.exe"):
|
| 85 |
+
ffmpeg_paths.append(os.path.abspath("ffmpeg.exe"))
|
| 86 |
+
if len(ffmpeg_paths) == 0:
|
| 87 |
+
logger.error("No valid ffmpeg found.")
|
| 88 |
+
ffmpeg_path = None
|
| 89 |
+
elif len(ffmpeg_paths) == 1:
|
| 90 |
+
#Evaluation of suitability isn't required, can take sole option
|
| 91 |
+
#to reduce startup time
|
| 92 |
+
ffmpeg_path = ffmpeg_paths[0]
|
| 93 |
+
else:
|
| 94 |
+
ffmpeg_path = max(ffmpeg_paths, key=ffmpeg_suitability)
|
| 95 |
+
gifski_path = os.environ.get("VHS_GIFSKI", None)
|
| 96 |
+
if gifski_path is None:
|
| 97 |
+
gifski_path = os.environ.get("JOV_GIFSKI", None)
|
| 98 |
+
if gifski_path is None:
|
| 99 |
+
gifski_path = shutil.which("gifski")
|
| 100 |
+
ytdl_path = os.environ.get("VHS_YTDL", None) or shutil.which('yt-dlp') \
|
| 101 |
+
or shutil.which('youtube-dl')
|
| 102 |
+
download_history = {}
|
| 103 |
+
def try_download_video(url):
|
| 104 |
+
if ytdl_path is None:
|
| 105 |
+
return None
|
| 106 |
+
if url in download_history:
|
| 107 |
+
return download_history[url]
|
| 108 |
+
os.makedirs(folder_paths.get_temp_directory(), exist_ok=True)
|
| 109 |
+
#Format information could be added to only download audio for Load Audio,
|
| 110 |
+
#but this gets hairy if same url is also used for video.
|
| 111 |
+
#Best to just always keep defaults
|
| 112 |
+
#dl_format = ['-f', 'ba'] if is_audio else []
|
| 113 |
+
try:
|
| 114 |
+
res = subprocess.run([ytdl_path, "--print", "after_move:filepath",
|
| 115 |
+
"-P", folder_paths.get_temp_directory(), url],
|
| 116 |
+
capture_output=True, check=True)
|
| 117 |
+
#strip newline
|
| 118 |
+
file = res.stdout.decode(*ENCODE_ARGS)[:-1]
|
| 119 |
+
except subprocess.CalledProcessError as e:
|
| 120 |
+
raise Exception("An error occurred in the yt-dl process:\n" \
|
| 121 |
+
+ e.stderr.decode(*ENCODE_ARGS))
|
| 122 |
+
file = None
|
| 123 |
+
download_history[url] = file
|
| 124 |
+
return file
|
| 125 |
+
|
| 126 |
+
def is_safe_path(path, strict=False):
|
| 127 |
+
if "VHS_STRICT_PATHS" not in os.environ and not strict:
|
| 128 |
+
return True
|
| 129 |
+
basedir = os.path.abspath('.')
|
| 130 |
+
try:
|
| 131 |
+
common_path = os.path.commonpath([basedir, path])
|
| 132 |
+
except:
|
| 133 |
+
#Different drive on windows
|
| 134 |
+
return False
|
| 135 |
+
return common_path == basedir
|
| 136 |
+
|
| 137 |
+
def get_sorted_dir_files_from_directory(directory: str, skip_first_images: int=0, select_every_nth: int=1, extensions: Iterable=None):
|
| 138 |
+
directory = strip_path(directory)
|
| 139 |
+
dir_files = os.listdir(directory)
|
| 140 |
+
dir_files = sorted(dir_files)
|
| 141 |
+
dir_files = [os.path.join(directory, x) for x in dir_files]
|
| 142 |
+
dir_files = list(filter(lambda filepath: os.path.isfile(filepath), dir_files))
|
| 143 |
+
# filter by extension, if needed
|
| 144 |
+
if extensions is not None:
|
| 145 |
+
extensions = list(extensions)
|
| 146 |
+
new_dir_files = []
|
| 147 |
+
for filepath in dir_files:
|
| 148 |
+
ext = "." + filepath.split(".")[-1]
|
| 149 |
+
if ext.lower() in extensions:
|
| 150 |
+
new_dir_files.append(filepath)
|
| 151 |
+
dir_files = new_dir_files
|
| 152 |
+
# start at skip_first_images
|
| 153 |
+
dir_files = dir_files[skip_first_images:]
|
| 154 |
+
dir_files = dir_files[0::select_every_nth]
|
| 155 |
+
return dir_files
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
# modified from https://stackoverflow.com/questions/22058048/hashing-a-file-in-python
|
| 159 |
+
def calculate_file_hash(filename: str, hash_every_n: int = 1):
|
| 160 |
+
#Larger video files were taking >.5 seconds to hash even when cached,
|
| 161 |
+
#so instead the modified time from the filesystem is used as a hash
|
| 162 |
+
h = hashlib.sha256()
|
| 163 |
+
h.update(filename.encode())
|
| 164 |
+
h.update(str(os.path.getmtime(filename)).encode())
|
| 165 |
+
return h.hexdigest()
|
| 166 |
+
|
| 167 |
+
prompt_queue = server.PromptServer.instance.prompt_queue
|
| 168 |
+
def requeue_workflow_unchecked():
|
| 169 |
+
"""Requeues the current workflow without checking for multiple requeues"""
|
| 170 |
+
currently_running = prompt_queue.currently_running
|
| 171 |
+
(_, _, prompt, extra_data, outputs_to_execute) = next(iter(currently_running.values()))
|
| 172 |
+
|
| 173 |
+
#Ensure batch_managers are marked stale
|
| 174 |
+
prompt = prompt.copy()
|
| 175 |
+
for uid in prompt:
|
| 176 |
+
if prompt[uid]['class_type'] == 'VHS_BatchManager':
|
| 177 |
+
prompt[uid]['inputs']['requeue'] = prompt[uid]['inputs'].get('requeue',0)+1
|
| 178 |
+
|
| 179 |
+
#execution.py has guards for concurrency, but server doesn't.
|
| 180 |
+
#TODO: Check that this won't be an issue
|
| 181 |
+
number = -server.PromptServer.instance.number
|
| 182 |
+
server.PromptServer.instance.number += 1
|
| 183 |
+
prompt_id = str(server.uuid.uuid4())
|
| 184 |
+
prompt_queue.put((number, prompt_id, prompt, extra_data, outputs_to_execute))
|
| 185 |
+
|
| 186 |
+
requeue_guard = [None, 0, 0, {}]
|
| 187 |
+
def requeue_workflow(requeue_required=(-1,True)):
|
| 188 |
+
assert(len(prompt_queue.currently_running) == 1)
|
| 189 |
+
global requeue_guard
|
| 190 |
+
(run_number, _, prompt, _, _) = next(iter(prompt_queue.currently_running.values()))
|
| 191 |
+
if requeue_guard[0] != run_number:
|
| 192 |
+
#Calculate a count of how many outputs are managed by a batch manager
|
| 193 |
+
managed_outputs=0
|
| 194 |
+
for bm_uid in prompt:
|
| 195 |
+
if prompt[bm_uid]['class_type'] == 'VHS_BatchManager':
|
| 196 |
+
for output_uid in prompt:
|
| 197 |
+
if prompt[output_uid]['class_type'] in ["VHS_VideoCombine"]:
|
| 198 |
+
for inp in prompt[output_uid]['inputs'].values():
|
| 199 |
+
if inp == [bm_uid, 0]:
|
| 200 |
+
managed_outputs+=1
|
| 201 |
+
requeue_guard = [run_number, 0, managed_outputs, {}]
|
| 202 |
+
requeue_guard[1] = requeue_guard[1]+1
|
| 203 |
+
requeue_guard[3][requeue_required[0]] = requeue_required[1]
|
| 204 |
+
if requeue_guard[1] == requeue_guard[2] and max(requeue_guard[3].values()):
|
| 205 |
+
requeue_workflow_unchecked()
|
| 206 |
+
|
| 207 |
+
def get_audio(file, start_time=0, duration=0):
|
| 208 |
+
args = [ffmpeg_path, "-i", file]
|
| 209 |
+
if start_time > 0:
|
| 210 |
+
args += ["-ss", str(start_time)]
|
| 211 |
+
if duration > 0:
|
| 212 |
+
args += ["-t", str(duration)]
|
| 213 |
+
try:
|
| 214 |
+
#TODO: scan for sample rate and maintain
|
| 215 |
+
res = subprocess.run(args + ["-f", "f32le", "-"],
|
| 216 |
+
capture_output=True, check=True)
|
| 217 |
+
audio = torch.frombuffer(bytearray(res.stdout), dtype=torch.float32)
|
| 218 |
+
match = re.search(', (\\d+) Hz, (\\w+), ',res.stderr.decode(*ENCODE_ARGS))
|
| 219 |
+
except subprocess.CalledProcessError as e:
|
| 220 |
+
raise Exception(f"VHS failed to extract audio from {file}:\n" \
|
| 221 |
+
+ e.stderr.decode(*ENCODE_ARGS))
|
| 222 |
+
if match:
|
| 223 |
+
ar = int(match.group(1))
|
| 224 |
+
#NOTE: Just throwing an error for other channel types right now
|
| 225 |
+
#Will deal with issues if they come
|
| 226 |
+
ac = {"mono": 1, "stereo": 2}[match.group(2)]
|
| 227 |
+
else:
|
| 228 |
+
ar = 44100
|
| 229 |
+
ac = 2
|
| 230 |
+
audio = audio.reshape((-1,ac)).transpose(0,1).unsqueeze(0)
|
| 231 |
+
return {'waveform': audio, 'sample_rate': ar}
|
| 232 |
+
|
| 233 |
+
class LazyAudioMap(Mapping):
|
| 234 |
+
def __init__(self, file, start_time, duration):
|
| 235 |
+
self.file = file
|
| 236 |
+
self.start_time=start_time
|
| 237 |
+
self.duration=duration
|
| 238 |
+
self._dict=None
|
| 239 |
+
def __getitem__(self, key):
|
| 240 |
+
if self._dict is None:
|
| 241 |
+
self._dict = get_audio(self.file, self.start_time, self.duration)
|
| 242 |
+
return self._dict[key]
|
| 243 |
+
def __iter__(self):
|
| 244 |
+
if self._dict is None:
|
| 245 |
+
self._dict = get_audio(self.file, self.start_time, self.duration)
|
| 246 |
+
return iter(self._dict)
|
| 247 |
+
def __len__(self):
|
| 248 |
+
if self._dict is None:
|
| 249 |
+
self._dict = get_audio(self.file, self.start_time, self.duration)
|
| 250 |
+
return len(self._dict)
|
| 251 |
+
def lazy_get_audio(file, start_time=0, duration=0, **kwargs):
|
| 252 |
+
return LazyAudioMap(file, start_time, duration)
|
| 253 |
+
|
| 254 |
+
def is_url(url):
|
| 255 |
+
return url.split("://")[0] in ["http", "https"]
|
| 256 |
+
|
| 257 |
+
def validate_sequence(path):
|
| 258 |
+
#Check if path is a valid ffmpeg sequence that points to at least one file
|
| 259 |
+
(path, file) = os.path.split(path)
|
| 260 |
+
if not os.path.isdir(path):
|
| 261 |
+
return False
|
| 262 |
+
match = re.search('%0?\\d+d', file)
|
| 263 |
+
if not match:
|
| 264 |
+
return False
|
| 265 |
+
seq = match.group()
|
| 266 |
+
if seq == '%d':
|
| 267 |
+
seq = '\\\\d+'
|
| 268 |
+
else:
|
| 269 |
+
seq = '\\\\d{%s}' % seq[1:-1]
|
| 270 |
+
file_matcher = re.compile(re.sub('%0?\\d+d', seq, file))
|
| 271 |
+
for file in os.listdir(path):
|
| 272 |
+
if file_matcher.fullmatch(file):
|
| 273 |
+
return True
|
| 274 |
+
return False
|
| 275 |
+
|
| 276 |
+
def strip_path(path):
|
| 277 |
+
#This leaves whitespace inside quotes and only a single "
|
| 278 |
+
#thus ' ""test"' -> '"test'
|
| 279 |
+
#consider path.strip(string.whitespace+"\"")
|
| 280 |
+
#or weightier re.fullmatch("[\\s\"]*(.+?)[\\s\"]*", path).group(1)
|
| 281 |
+
path = path.strip()
|
| 282 |
+
if path.startswith("\""):
|
| 283 |
+
path = path[1:]
|
| 284 |
+
if path.endswith("\""):
|
| 285 |
+
path = path[:-1]
|
| 286 |
+
return path
|
| 287 |
+
def hash_path(path):
|
| 288 |
+
if path is None:
|
| 289 |
+
return "input"
|
| 290 |
+
if is_url(path):
|
| 291 |
+
return "url"
|
| 292 |
+
if not os.path.isfile(path):
|
| 293 |
+
return "DNE"
|
| 294 |
+
return calculate_file_hash(strip_path(path))
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
def validate_path(path, allow_none=False, allow_url=True):
|
| 298 |
+
if path is None:
|
| 299 |
+
return allow_none
|
| 300 |
+
if is_url(path):
|
| 301 |
+
#Probably not feasible to check if url resolves here
|
| 302 |
+
if not allow_url:
|
| 303 |
+
return "URLs are unsupported for this path"
|
| 304 |
+
return is_safe_path(path)
|
| 305 |
+
if not os.path.isfile(strip_path(path)):
|
| 306 |
+
return "Invalid file path: {}".format(path)
|
| 307 |
+
return is_safe_path(path)
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
def validate_index(index: int, length: int=0, is_range: bool=False, allow_negative=False, allow_missing=False) -> int:
|
| 311 |
+
# if part of range, do nothing
|
| 312 |
+
if is_range:
|
| 313 |
+
return index
|
| 314 |
+
# otherwise, validate index
|
| 315 |
+
# validate not out of range - only when latent_count is passed in
|
| 316 |
+
if length > 0 and index > length-1 and not allow_missing:
|
| 317 |
+
raise IndexError(f"Index '{index}' out of range for {length} item(s).")
|
| 318 |
+
# if negative, validate not out of range
|
| 319 |
+
if index < 0:
|
| 320 |
+
if not allow_negative:
|
| 321 |
+
raise IndexError(f"Negative indeces not allowed, but was '{index}'.")
|
| 322 |
+
conv_index = length+index
|
| 323 |
+
if conv_index < 0 and not allow_missing:
|
| 324 |
+
raise IndexError(f"Index '{index}', converted to '{conv_index}' out of range for {length} item(s).")
|
| 325 |
+
index = conv_index
|
| 326 |
+
return index
|
| 327 |
+
|
| 328 |
+
|
| 329 |
+
def convert_to_index_int(raw_index: str, length: int=0, is_range: bool=False, allow_negative=False, allow_missing=False) -> int:
|
| 330 |
+
try:
|
| 331 |
+
return validate_index(int(raw_index), length=length, is_range=is_range, allow_negative=allow_negative, allow_missing=allow_missing)
|
| 332 |
+
except ValueError as e:
|
| 333 |
+
raise ValueError(f"Index '{raw_index}' must be an integer.", e)
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
def convert_str_to_indexes(indexes_str: str, length: int=0, allow_missing=False) -> list[int]:
|
| 337 |
+
if not indexes_str:
|
| 338 |
+
return []
|
| 339 |
+
int_indexes = list(range(0, length))
|
| 340 |
+
allow_negative = length > 0
|
| 341 |
+
chosen_indexes = []
|
| 342 |
+
# parse string - allow positive ints, negative ints, and ranges separated by ':'
|
| 343 |
+
groups = indexes_str.split(",")
|
| 344 |
+
groups = [g.strip() for g in groups]
|
| 345 |
+
for g in groups:
|
| 346 |
+
# parse range of indeces (e.g. 2:16)
|
| 347 |
+
if ':' in g:
|
| 348 |
+
index_range = g.split(":", 2)
|
| 349 |
+
index_range = [r.strip() for r in index_range]
|
| 350 |
+
|
| 351 |
+
start_index = index_range[0]
|
| 352 |
+
if len(start_index) > 0:
|
| 353 |
+
start_index = convert_to_index_int(start_index, length=length, is_range=True, allow_negative=allow_negative, allow_missing=allow_missing)
|
| 354 |
+
else:
|
| 355 |
+
start_index = 0
|
| 356 |
+
end_index = index_range[1]
|
| 357 |
+
if len(end_index) > 0:
|
| 358 |
+
end_index = convert_to_index_int(end_index, length=length, is_range=True, allow_negative=allow_negative, allow_missing=allow_missing)
|
| 359 |
+
else:
|
| 360 |
+
end_index = length
|
| 361 |
+
# support step as well, to allow things like reversing, every-other, etc.
|
| 362 |
+
step = 1
|
| 363 |
+
if len(index_range) > 2:
|
| 364 |
+
step = index_range[2]
|
| 365 |
+
if len(step) > 0:
|
| 366 |
+
step = convert_to_index_int(step, length=length, is_range=True, allow_negative=True, allow_missing=True)
|
| 367 |
+
else:
|
| 368 |
+
step = 1
|
| 369 |
+
# if latents were passed in, base indeces on known latent count
|
| 370 |
+
if len(int_indexes) > 0:
|
| 371 |
+
chosen_indexes.extend(int_indexes[start_index:end_index][::step])
|
| 372 |
+
# otherwise, assume indeces are valid
|
| 373 |
+
else:
|
| 374 |
+
chosen_indexes.extend(list(range(start_index, end_index, step)))
|
| 375 |
+
# parse individual indeces
|
| 376 |
+
else:
|
| 377 |
+
chosen_indexes.append(convert_to_index_int(g, length=length, allow_negative=allow_negative, allow_missing=allow_missing))
|
| 378 |
+
return chosen_indexes
|
| 379 |
+
|
| 380 |
+
|
| 381 |
+
def select_indexes(input_obj: Union[Tensor, list], idxs: list):
|
| 382 |
+
if type(input_obj) == Tensor:
|
| 383 |
+
return input_obj[idxs]
|
| 384 |
+
else:
|
| 385 |
+
return [input_obj[i] for i in idxs]
|
| 386 |
+
|
| 387 |
+
def merge_filter_args(args, ftype="-vf"):
|
| 388 |
+
#TODO This doesn't account for filter_complex
|
| 389 |
+
#Will likely need to convert all filters to filter complex in the future
|
| 390 |
+
#But that requires source/output deduplication
|
| 391 |
+
try:
|
| 392 |
+
start_index = args.index(ftype)+1
|
| 393 |
+
index = start_index
|
| 394 |
+
while True:
|
| 395 |
+
index = args.index(ftype, index)
|
| 396 |
+
args[start_index] += ',' + args[index+1]
|
| 397 |
+
args.pop(index)
|
| 398 |
+
args.pop(index)
|
| 399 |
+
except ValueError:
|
| 400 |
+
pass
|
| 401 |
+
|
| 402 |
+
def select_indexes_from_str(input_obj: Union[Tensor, list], indexes: str, err_if_missing=True, err_if_empty=True):
|
| 403 |
+
real_idxs = convert_str_to_indexes(indexes, len(input_obj), allow_missing=not err_if_missing)
|
| 404 |
+
if err_if_empty and len(real_idxs) == 0:
|
| 405 |
+
raise Exception(f"Nothing was selected based on indexes found in '{indexes}'.")
|
| 406 |
+
return select_indexes(input_obj, real_idxs)
|
| 407 |
+
|
| 408 |
+
def hook(obj, attr):
|
| 409 |
+
def dec(f):
|
| 410 |
+
f = functools.update_wrapper(f, getattr(obj,attr))
|
| 411 |
+
setattr(obj,attr,f)
|
| 412 |
+
return f
|
| 413 |
+
return dec
|
| 414 |
+
|
| 415 |
+
def cached(duration):
|
| 416 |
+
def dec(f):
|
| 417 |
+
cached_ret = None
|
| 418 |
+
cache_time = 0
|
| 419 |
+
def cached_func():
|
| 420 |
+
nonlocal cache_time, cached_ret
|
| 421 |
+
if time.time() > cache_time + duration or cached_ret is None:
|
| 422 |
+
cache_time = time.time()
|
| 423 |
+
cached_ret = f()
|
| 424 |
+
return cached_ret
|
| 425 |
+
return cached_func
|
| 426 |
+
return dec
|
web/js/VHS.core.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
web/js/videoinfo.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { app } from '../../../scripts/app.js'
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
function getVideoMetadata(file) {
|
| 5 |
+
return new Promise((r) => {
|
| 6 |
+
const reader = new FileReader();
|
| 7 |
+
reader.onload = (event) => {
|
| 8 |
+
const videoData = new Uint8Array(event.target.result);
|
| 9 |
+
const dataView = new DataView(videoData.buffer);
|
| 10 |
+
|
| 11 |
+
let decoder = new TextDecoder();
|
| 12 |
+
// Check for known valid magic strings
|
| 13 |
+
if (dataView.getUint32(0) == 0x1A45DFA3) {
|
| 14 |
+
//webm/mkv (both use EBML/Matroska format)
|
| 15 |
+
//see http://wiki.webmproject.org/webm-metadata/global-metadata
|
| 16 |
+
//and https://www.matroska.org/technical/elements.html
|
| 17 |
+
//contrary to specs, tag seems consistently at start
|
| 18 |
+
//COMMENT + 0x4487 + packed length?
|
| 19 |
+
//length 0x8d8 becomes 0x48d8
|
| 20 |
+
//
|
| 21 |
+
//description for variable length ints https://github.com/ietf-wg-cellar/ebml-specification/blob/master/specification.markdown
|
| 22 |
+
let offset = 4 + 8; //COMMENT is 7 chars + 1 to realign
|
| 23 |
+
while(offset < videoData.length-16) {
|
| 24 |
+
//Check for text tags
|
| 25 |
+
if (dataView.getUint16(offset) == 0x4487) {
|
| 26 |
+
//check that name of tag is COMMENT
|
| 27 |
+
const name = String.fromCharCode(...videoData.slice(offset-7,offset));
|
| 28 |
+
if (name === "COMMENT") {
|
| 29 |
+
let vint = dataView.getUint32(offset+2);
|
| 30 |
+
let n_octets = Math.clz32(vint)+1;
|
| 31 |
+
if (n_octets < 4) {//250MB sanity cutoff
|
| 32 |
+
let length = (vint >> (8*(4-n_octets))) & ~(1 << (7*n_octets));
|
| 33 |
+
const content = decoder.decode(videoData.slice(offset+2+n_octets, offset+2+n_octets+length));
|
| 34 |
+
let json = JSON.parse(content);
|
| 35 |
+
r(json);
|
| 36 |
+
return;
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
offset+=1;
|
| 41 |
+
}
|
| 42 |
+
} else if (dataView.getUint32(4) == 0x66747970 && dataView.getUint32(8) == 0x69736F6D) {
|
| 43 |
+
//mp4
|
| 44 |
+
//see https://developer.apple.com/documentation/quicktime-file-format
|
| 45 |
+
//Seems to make no guarantee for alignment
|
| 46 |
+
let offset = videoData.length-4;
|
| 47 |
+
while (offset > 16) {//rough safe guess
|
| 48 |
+
if (dataView.getUint32(offset) == 0x64617461) {//any data tag
|
| 49 |
+
if (dataView.getUint32(offset - 8) == 0xa9636d74) {//cmt data tag
|
| 50 |
+
let type = dataView.getUint32(offset+4); //seemingly 1
|
| 51 |
+
let locale = dataView.getUint32(offset+8); //seemingly 0
|
| 52 |
+
let size = dataView.getUint32(offset-4) - 4*4;
|
| 53 |
+
const content = decoder.decode(videoData.slice(offset+12, offset+12+size));
|
| 54 |
+
const json = JSON.parse(content);
|
| 55 |
+
r(json);
|
| 56 |
+
return;
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
offset-=1;
|
| 61 |
+
}
|
| 62 |
+
} else {
|
| 63 |
+
console.error("Unknown magic: " + dataView.getUint32(0))
|
| 64 |
+
}
|
| 65 |
+
r();
|
| 66 |
+
return;
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
reader.readAsArrayBuffer(file);
|
| 70 |
+
});
|
| 71 |
+
}
|
| 72 |
+
function isVideoFile(file) {
|
| 73 |
+
if (file?.name?.endsWith(".webm")) {
|
| 74 |
+
return true;
|
| 75 |
+
}
|
| 76 |
+
if (file?.name?.endsWith(".mp4")) {
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
if (file?.name?.endsWith(".mkv")) {
|
| 80 |
+
return true;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
return false;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
let originalHandleFile = app.handleFile;
|
| 87 |
+
app.handleFile = handleFile;
|
| 88 |
+
let fileInput = document.getElementById("comfy-file-input")
|
| 89 |
+
//hijack comfy-file-input to allow webm/mp4/mkv
|
| 90 |
+
fileInput.accept += ",video/webm,video/mp4,video/x-matroska";
|
| 91 |
+
|
| 92 |
+
async function handleFile(file) {
|
| 93 |
+
if (file?.type?.startsWith("video/") || isVideoFile(file)) {
|
| 94 |
+
const videoInfo = await getVideoMetadata(file);
|
| 95 |
+
if (videoInfo?.workflow) {
|
| 96 |
+
await app.loadGraphData(videoInfo.workflow);
|
| 97 |
+
return
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
return await originalHandleFile.apply(this, arguments);
|
| 101 |
+
}
|