Commit Graph
30 Commits
Author SHA1 Message Date
Austin Mroz 7c313fd9fb Merge ytdl_support, audio QOL 2024-07-30 02:36:13 -05:00
Jedrzej Kosinski 3b7492d023 Added Select Latents/Images/Masks nodes, renamed some nodes to remove Batch from names, renamed Duplicate nodes to Repeat 2024-07-11 21:34:53 -05:00
Austin Mroz d6cf89c501 Clean up get_audio try/catch
The prior implementation made a best effort to continue in the event of
an error, but immediately threw an error afterwards since there was no
output from the subprocess.

As get_audio isn't called until the audio connection from a Load Video
is used, it's safe to raise an exception here and properly expose the
error message from ffmpeg as is done elsewhere.

See #250
2024-07-11 11:03:32 -05:00
Austin Mroz 8c50452255 Skip download attempt when yt-dl unavailable 2024-07-09 17:07:00 -05:00
Austin Mroz 4838634372 Add support for downloading urls with yd-dl
Executable preference is
VHS_YTDL environment variable > yt-dlp > youtube-dl

Downloaded videos are cached in temp so they are not preserved between
reboots

Both Load Video (Path) and Load Audio (Path) are supported
2024-07-09 13:10:56 -05:00
Austin Mroz d37b823faa Parse channels and sample rate from source audio 2024-06-29 04:01:50 -05:00
Austin Mroz a19a4abe3a Migrate Audio from VHS_AUDIO to comfy's AUDIO
Known issues:
- need legacy node to convert from AUDIO to VHS_AUDIO
 - add js to automate adding said node to workflows?
- need to parse number of channels when loading audio
2024-06-29 03:07:48 -05:00
Austin Mroz b7359d5e67 Rework path stripping
All path stripping is now performed by a dedicated strip_path function.
First all whitespace is stripped, then a single double-quote is stripped
from the start and end of the path. Subsequent double quotes or white
space inside of the quotes is maintained.

Fixed a number of places paths received no stripping
- Load Video (Path) execution
- Path queries
- Advanced Previews
- Load Audio

See #224
2024-06-06 22:09:08 -05:00
Austin Mroz d85747121c Respect VHS_STRICT_PATHS for runtime paths 2024-05-28 01:08:49 -05:00
Austin Mroz b35068cebb Properly escape regex strings
Since updating to Python12, I've been graced with warnings about
improper escape sequences. This change should make no functional
difference, but resolves the warnings.
2024-05-21 16:11:46 -05:00
Austin Mroz d621c6b534 Always display ffmepg formats, raise error instead
While it made sense to quietly proceed when io nodes were rolled into
animate diff, the process of hiding unusable formats has caused frequent
confusion in addition to being a logic path that should not be formally
supported (imageio-ffmpeg is in requirements.txt so a lack of ffmpeg
is best considered an invalid install.)

While an angry warning was displayed on boot, this error message is
frequently missed by end users. Now, all format options are
displayed and, if an unusable format is selected, an error is raised
which provides a list of options for how to install ffmpeg

Additionally, an extra search path was added to run an ffmpeg executable
that is placed in the base ComfyUI directory. For those struggling with
virtual environments or the system path, this provides a third
installation option that works regardless of os, or venv and requires no
need for external configuration or environment variables.

See #188, among others.
2024-04-08 22:57:05 -05:00
Austin Mroz 5a60c935c7 Improved audio handling when no audio exists
Before, if an attempt is made to load audio from a media file that lacks
audio, an exception is raised which, inconveniently, is incorrectly
captured and handled by a higher level try-catch block.

Instead, exceptions in the ffmpeg call to extract audio from a file are
handled inside the get_audio function call and False is passed on
failure. False is used largely as a matter of convenience so that the
failed output is cached between runs and not re-executed

Since this output is cached, it's then easy to just check if audio
resolves to False and skip the code to embed audio (as if there was not
an audio input wired). This allows reuse of a single workflow that will
embed audio when it's available.

Resolves #153
2024-02-07 23:23:02 -06:00
Austin Mroz 03dbc9bc2a Improve import speed with single ffmpeg option
In order to eliminate the issues related to old system versions of
ffmpeg, a system was added for ranking the suitability of available
ffmpeg versions. This has a fairly high startup cost, so it's now
skipped when only one option exists.
2024-02-07 15:03:58 -06:00
Austin Mroz a2900c3273 Add support for Gifski ouput
Adds support for a gifski_pass in video_formats and a gifski format
which utilizes it. Resolves #79

Much consideration was put into how best to implement this. Gifski does
not support piped input, and implementing such functionality is
infeasible as the ffmpeg library used by Gifski requires inputs be
physical files. Consequentially, an intermediate file of some sort is
required. While an implementation that would not require a prior ffmpeg
pass was investigated, the only viable intermediary format
between Pillow and Gifski's ffmpeg decoder is an animated png and gifski
will never pass this png to it's ffmpeg decoder as it sees the png
header and instead interprets the file as a single frame image.
2024-02-07 12:03:26 -06:00
Austin Mroz ad9be8d398 Restrict BIG constants to js safe integer values
js uses doubles for all numbers, as a result, the maximum number that
could be entered by the ui and still allow for functioning of
increment/decrement.

Of consideration, ComfyUI uses a lower cap of 2**50 for seeds
2024-02-07 12:03:15 -06:00
Jedrzej Kosinski ffd061a709 Use BIGMIN and BIGMAX for inputs with no intended limits, use DIMMAX for setting size inputs to go up to ComfyUI limits, increased force_rate max up to 60 2024-02-06 02:17:45 -06:00
Jedrzej Kosinski f880012653 Fixed os.environ.get call 2024-02-06 01:58:05 -06:00
Austin Mroz 9cf39079b6 File hash and filename counter fixes.
The hash function used for IS_CHANGED had particularly poor performance
characteristics when combined with the new batch functionality. The
larger video files take a while to scan through and the scan occurs for
every sub-batch step. Consequentially, hash calculation has an
exponential performance cost when batching larger videos.

calculate_file_hash has been changed to instead use the modified
timestamp on the file. In profiling this brought the time cost for a
single call to IS_CHANGED from ~600 ms to <1 ms

The 16bit-png format was not being matched by the file counter regex and
resulted repeat counter values when combined with Prune Outputs.
The regex has been relaxed to prevent this discrepancy.
2024-01-31 12:32:39 -06:00
Austin Mroz af3f0c1be4 Migrate re-queues to occur on server side
Terminate batch when any input closes
2024-01-29 16:15:12 -06:00
Austin Mroz cf343e0a9d Add 16bit-png format. Support sequence file paths
Add a 16bit-png video_format which supports output transparency. Other
formats could be updated for similar capabilities, but are likely to
have issues with device support and unlikely to see widespread adoption.

Modifies the preview server code to properly parse and check for the
existence of sequence filenames.
2024-01-13 17:56:00 -06:00
Jedrzej Kosinski 6dda23d4f0 Added mask version of image/latent nodes 2024-01-06 07:55:50 -06:00
Austin Mroz 9234d91a2b Fix widget conversion
After substantial rewriting, paths are declared as strings in the python
code, and converted to path widgets in the webui if they include an
option for vhs_path_extensions. resolves #104

VALIDATE_INPUT and IS_CHANGED for path nodes were rewritten and largely
consolidated in utils to accommodate validation of inputs not known before
execution.
Known issue: VALIDATE_INPUT is never called for load_audio which results
in error messages that aren't very helpful if a bad path is provided

An error is no longer immediately raised if ffmpeg is not found

Internal paths are now absolute for load images advanced previews
2023-12-27 21:00:45 -06:00
Austin Mroz 75fc10e0ff Parse ffmpeg version information and choose best
While I have previously shied away from using imageio-ffmpeg as the
default version because the included version is 4 years old and
specifically does not work with the av1 format, there have been specific
issues from people with a system version of ffmpeg that is even older.

There has been a longstanding desire to create a system for determining
the best version of ffmpeg, but this has proved a reasonably involved
task. Some version information uses git commit hashes instead of a
potentially sortable semvar and there are a large number of compile time
flags that could result in a newer binary having less functionality.

Thus a sysstem has been added that parses compile flags for desired
encoders as well as the copyright year to determine which ffmpeg version
is more feature full.
2023-12-19 11:40:42 -06:00
Austin Mroz 3a34051eee Video loops, force imageio ffmpeg, metadata fix
Support loop_count with videos, fixes #83

Add support for forcing usage of ffmpeg bundled with imageio by setting
VHS_USE_IMAGEIO_FFMPEG to ease testing and as a temporary fix for #80

When saving with metadata, if an error occurred after initialization, an
empty output video would be produced which caused the without metadata
retry to fail with a less helpful error message. Now, if the pass with
metadata failed, but produced an output file, that error is raised and
the retry does not occur. This should not change the effectiveness of
the fallback for those who were experiencing the metadata issue.
2023-12-06 20:10:59 -06:00
Austin Mroz 31803f5308 URLs in Load Video (Path), more logging changes
Basic support for loading urls has been added to Load Video.
Most of the work is made trivial by both ffmpeg and opencv automatically
fetching a url if it's provided instead of a path.

A more sophisticated fix for error passing from ffmpeg during preview
generation. If a request is aborted, the ffmpeg process is immediately
killed instead of being allowed to respond to stdin being closed and
waited on at the end of the with block
2023-12-03 14:11:53 -06:00
Austin Mroz a1ee051238 Further cleanup
save_metadata is now a format flag
- This allows saving to different tag and hides for image formats

Implement high bit depth support
- Disabled by default, but works for images and has shown in testing to
  produce objectively higher quality output than base Save Image

Fix target_size from load video not applying when 2 dimensions are set
When an input video is scaled to a new aspect ratio, it is now cropped
Removed try wrapping of load video nodes. This creates more confusion
now a system of fallbacks isn't used

A fix for parsing format_widgets when applied outside a '_pass'

Fixed missing import of logger in utils

Animated images are now included in the animated preview code
- This improves performance and allows for pausing

Cleaned up injection of code to load metadata
2023-11-30 17:40:57 -06:00
Austin Mroz d0ddff7391 Numerous audio improvements
Audio settings are now stored in video_formats
Updated video_formats with reasonable defaults for audio
A Load Audio (Path) node has been added
Audio Loads are cached with load state and only occur once.
2023-11-26 22:30:33 -06:00
Austin Mroz 53d6d24b5f Partial implementation for audio wiring
Seemingly functional.
Loading audio from a file will be reimplemented as a future node
Format support is forthcoming
2023-11-26 20:30:19 -06:00
Jedrzej Kosinski 9fa5e37e20 added extension-checking code to get_sorted_dir_files_from_directory 2023-09-27 02:56:04 -05:00
Jedrzej Kosinski 99babcf489 added merge, split, select_every_nth, and Load Images nodes 2023-09-27 02:05:10 -05:00