Commit Graph
99 Commits
Author SHA1 Message Date
Austin Mroz 38618d4eae Fixes for batch_manager error handling
stdin is always flushed before yeilding. While this loses some potential
speedup by processing video output on cpu while the gpu is processing
the next batch of frames, it is likely incompatible with errors related
to metadata which could not be replicated. For now, stdin is flushed to
reduce the likelihood of regression.

Fixed a mistaken ordering in the batch_manager node causing the
unique_id to be overwritten.

Re-add the dummy count value to the batch manager node in js. Without
it, an error during the first batch step will result in teh batch
manager node not being marked as stale. Since the batch_manager node
exists only as an optional input, IS_CHANGED will never be called and
there must be some external change to ensure it is still marked stale
2024-01-29 20:50:31 -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 60cdc6c8bc Batch Manager supports multiple inputs and outputs
Also removes the use of a static batch_manager instance
2024-01-25 01:08:38 -06:00
Austin Mroz c5de20d0bf Initial proof of concept for Batch Management
Processing video can have prohibitively high memory requirements.
This commit introduces a system for dividing the processing of a video
input into multiple workflow executions.

To accomplish this, the reference to the cv2 video_capture instance, and
the ffmpeg subprocess are kept open and the workflow is automatically
re-executed for each partial step.
2024-01-23 23:47:36 -06:00
Austin Mroz aca4dfcdac Update preview on Upload
Previously, Load Video (Upload) and Load Images (Upload) would swap to
the new file or folder, but would not update the preview. They have both
been fixed.
2024-01-18 16:03:03 -06:00
Austin Mroz 97fbebd3af Restore preview display when zoomed out.
In switching to video previews to use DOMWidgets, the performance
optimization to hide elements when zoomed out was left enabled by
default. This hiding has been disabled to restore prior functionality.
2024-01-17 17:34:23 -06:00
Austin Mroz 48f7b5e2f4 Add hotkey to disable PathWidget extension filters
Load Video and Load Audio both function with inputs not officially
listed as supported. Load Video can be used to load image files as a
substitute for Load Image and Load Audio can be passed video files.

While users have always had the option to manually type the path to a
filetype not ostensibly supported, this can be inconvenient.

A hotkey (Ctrl+g) has been added to temporarily disable the extension
filtering.
2024-01-15 22:14:35 -06:00
Austin Mroz ff59a789c9 Initial DOMWidget migration
Migrates preview widgets to use the ComfyUI DOMWidgets implementation.
This resolves a number of issues with flickering, adds support for DOM
element clipping, and should have better compatibility with future
updates.

resolves #128

Fixes to logic for determining when the aspect ratio of a video preview
has changed.
2024-01-13 20:28:28 -06:00
Austin Mroz 6ec9bdf17f Only reload preview if aspect ratio would change
Previously, any change to force_size, custom_width, or custom_height
would cause the video preview to reload. This has been changed to only
reload the preview if a change of values has occurred that could change
the aspect ratio.
2024-01-09 22:19:27 -06:00
Austin Mroz 625d43e31d Pass custom_width and custom_height to python code
Before, custom_width and custom_height widgets were virtual widgets that
were used to generate an equivalent force_size value on serialization.

This logic has been moved to the python side, but is largely unchanged
for simplicity.

This allows for custom_width and custom_height to be converted to an
input and set by output from python code which is not known before
execution.

resolves #119
2024-01-08 16:12:45 -06:00
Austin Mroz 9f0526a766 Fix error on iteration of VHS node with no widgets
Resolves #107

Fix error message for failed late validation of load video path
2023-12-28 11:14:11 -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 3aeda1ffd5 Support converting VHSPATH widget to string input 2023-12-27 13:03:41 -06:00
Austin Mroz a4bd717116 Restore Video Combine previews persisting reloads 2023-12-26 19:58:45 -06:00
Jedrzej Kosinski 00b3d9593b made Advanced Preview setting name have the matching VHS emoji prefix to match format of other custom node settings 2023-12-26 15:57:39 -06:00
Austin Mroz 04a7000152 Switch to ComfyUI filename formatting
resolves #92
2023-12-24 02:16:01 -06:00
Austin Mroz 9bea17d2d2 Support previews on Load Image nodes 2023-12-22 21:37:35 -06:00
Austin Mroz 0661cbbaf0 Invert path safety, Fix preview without force_size
Instead of requiring VHS_UNSAFE_PATHS to disable checking paths on the
new endpoints, checking is disabled by default and VHS_STRICT_PATHS can
be used to re-enable it. This makes the added functionality opt out,
instead of opt in, as has been a primary goal, but the quality of life
has won me over, the difference in availability is minimal compared to
the functionality of the existent path nodes and I suspect setting would
cause unnecessary burden upon the average user.

Fix an improper check in the js code causing previews to break when
force_size is left on disabled.
2023-12-21 16:16:29 -06:00
Austin Mroz 69b865c368 Support advanced previews of changed aspect ratios
Previously, force_size information was discarded when requesting
an advanced preview as the video was instead scaled to the size of the
node. Fixing this was deemed particularly difficult since the python
code does not have access to the actual video resolution before starting
the ffmpeg process.

This is solved with a more complex ffmpeg command that passes the
cropping logic to the ffmpeg subprocess.
2023-12-19 11:52:38 -06:00
Austin Mroz 7565290d2b Fix old workflows, Custom Size on refresh
Further migrations to video parameters had broken display of output
videos when an old workflow is loaded. This is fixed.

When the refresh button was clicked in ui, the custom size options of
Load Video were overwritten and lost. When the refresh button is
clicked, the custom size options are now readded properly.
2023-12-06 15:05:30 -06:00
Austin Mroz 76c8971c94 Rename save_image to save_output on Video Combine
This includes migration code to preserve old workflows
2023-12-04 14:08:32 -06:00
Austin Mroz 8ce1682187 Several js fixes
Fix params being uninitialized on migrated workflows

Fix null filename when performing a right click -> save on a video

Fix edge case in paths of a specific length causing console spam
2023-12-04 00:45:29 -06:00
Austin Mroz 9193868907 Revert metadata toggle, logging, round ints
The toggle for saving metadata has been changed back to a boolean
instead of a combo. While I wished to provide for future compatibility,
the change broke existing workflows and there was no accommodating
implementation to load metadata saved under a different tag.

The log level for ffmpeg preview processes has been raised to fatal.
There's a good chance this will make debugging harder for users when
errors arise, but aborted requests were too common for the error
messages produced by them to be acceptable.

Format widgets for ints are now properly rounded.
2023-12-03 12:36:41 -06:00
Austin Mroz ad1baf1fa8 Load Image, custom size, extension passing fixes
Load Images had a typo prevent it's extension filter (of nothing) from
applying

Audio inputs and outputs now consistently use lowercase audio as a
description and have a format name of VHS_AUDIO. While other extensions
could share the audio type name, they would not pass functions.

Previously when using ffmpeg to load a video, care was needed to ensure
that the first frame was index 0, but the frame at 1s was the first to
appear after 1s. This should now be fixed.

The js code for load video nodes now passes the extension as part of the
format so that gifs and webps can be properly distinguished between when
deciding if an advanced preview should be loaded.

Fixed a mistake in serialization of custom height on load video nodes
2023-12-02 11:59:05 -06:00
Austin Mroz 19a84ddf72 Yet further fixes
Add "-b:v" flag to webm format, resolves #78

Fixes Video Combine to provide an output usable outside the ui,
a list of files produced, resolves #57

Fix error in file path safety checks across drives on windows

Fixes for preview generation when backing file has audio

Don't scale video previews above their base resolution

Implement select_every_nth for advanced previews

Fix regression with improper callback checking on Load Audio

Reorder Load Audio in node mappings to not be grouped with image nodes
2023-12-01 14:43:20 -06:00
Austin Mroz 70f010f7ea Support previews for Load Video (Path), cleanup
Video Combine now returns a list of output files:
Partial fix for #57

Move safety checks to single shared function, added opt out by
environment variable. Easier methods are being considered

Modifications to viewvideo endpoint to work with paths instead of
standard methodology

Return an empty list of options instead of an error status for path
suggestions in an attempt to further reduce console spam.

Substantial js refactoring to simplify preview logic and
compartmentalize code that is shared between upload and path nodes
2023-12-01 10:04:59 -06:00
Austin Mroz 0ee635d2b0 Improve Load Images masks, further cleanup
Enable path suggestions for Load Images

Add masks equal to image size if any image has masks
This causes images with masks to function as expected and those
without to remain fully opaque.
Special thanks to @miaoerduo

Fix counter regex to work with audio outputs

Fix extension not being set for animated image outputs

Reductions to extraneous preview loads

Prevent new preview code from applying to webp files
2023-11-30 21:54:25 -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 f63a0f789d Feature branch cleanup
Switch to new path widget code on remaining nodes

Performance tuning on video preview code
Surround preview code in try block in case request is closed
- May warrant a future pass, but ffmpeg errors will still log to console

Swap lack of common path in get_path to status=403
- This was mostly made to ease future changes to common path behaviour

Simplify the value field of preview widget.
- Reduces complexity and lessens duplicate requests on first loa

Introduce ui setting for advanced previews
- Reliability is shakey, so it's better kept as opt-in for now

Previews are properly integrated and apply to Video Combine nodes

More advanced formatting code when a path is too long to display

Reduced console spam from path suggestions
2023-11-30 14:29:03 -06:00
Austin Mroz e8e6971eaf Merge branch 'format_widgets' into develop 2023-11-29 20:43:25 -06:00
Austin Mroz 417332840c Merge audio, videopreview, path_completion branche 2023-11-29 20:39:52 -06:00
Austin Mroz 6218fe5342 Implement path completion
A number of nodes take a path as input.
This commit gives a search box with a list of valid files and folders
It also provides support for quickly selecting from valid options by
clicking or pressing tab.

Completion options are currently only suggested for subfolders of
comfyui, but this is easily changeable.
2023-11-29 16:31:32 -06:00
Austin Mroz 7773c61ef7 Functional previews in browser
Current js implementation is rough, but results are promising
2023-11-23 14:20:44 -06:00
Austin Mroz 9fd996ead3 Fix server-side prompt parsing, debugging.
While having the optional arguments passed is non-trivial, there's an
easy fix to get retrieve all params sent from the client.

Substantial changes to how formats are stored on the backend to ensure
that the extra data isn't displayed in the dropdown list or upon
clicking the "Refresh" button in the ui.

Update most existing existing formats to expose options as widgets
2023-11-22 00:04:58 -06:00
Austin Mroz cb6d1ae2c7 wip format_widgets implementation
Likely impossible to implement
Widgets which are not defined in original node function definition are
not passed
2023-11-09 13:39:34 -06:00
Austin Mroz c4b36a0555 State migration: combo and IOB
Combo widgets which use the first item instead of a default field are
now successfully reloaded if not defined.

Fixed a minor IOB from combo inputs having only a single element in
their definition
2023-11-02 17:07:02 -05:00
Austin Mroz 08ab4d371e Attempt to unclobber widget state during migration 2023-11-01 16:31:45 -05:00
Austin Mroz 7aa6d195e1 Improved node state migration code 2023-11-01 15:12:44 -05:00
Austin Mroz fd646a3594 Account for browser zoom in preview elements 2023-10-31 12:18:23 -05:00
Austin Mroz 3c27b297c7 Prevent display of null preview 2023-10-31 10:36:14 -05:00
Austin Mroz df8fae06dd Dedicated state migration code for Load Images 2023-10-30 16:30:49 -05:00
Austin Mroz d4eb68dd56 Discard legacy preview information
The old preview method stored the url instead of the params.
This makes it non trivial to parse whether it was to an image or video.
For safety, this information is instead discarded.
2023-10-30 15:36:14 -05:00
Austin Mroz 12f3471d0d Fxi no preview on old Video Combine node 2023-10-30 14:22:46 -05:00
Austin Mroz d87f1ab473 Show correct output preview on history load
Minor fix to not try and load a non-existent preview

Reduce obtrusiveness of likely resolved error path
2023-10-30 12:24:08 -05:00
Austin Mroz 5bcf3ee3b3 computeSize fix, improve pause/hide state.
computeSize now calculates directly from the nodes width instead of
saving the width from the last draw operation. This fixes a race
condition when a video loads before the draw frame occurs.

the paused and hidden state of a preview widget are now serialized as
part of the vlaue. This means they survive reload or restoring a
workflow. Addionally, videos are paused before being hidden to improve
performance on some browsers.
2023-10-29 23:17:48 -05:00
Austin Mroz 0447a5a9b0 Fix mouse stuck down on file upload
A frustrating amount of digging with an awfully simple solution.
The current selected widget for mouse events is held in
app.canvas.node_widget.and clearing it prevents the continued
propagation of move events to parent widgets.

Also provides a minor fix for canceled file uploads
2023-10-29 21:55:58 -05:00
Austin Mroz 553167e86b Ensure height is always a number greater than 0 2023-10-29 15:40:27 -05:00
Austin Mroz a99173e545 Fix attempts to serialize nodes with no widgets 2023-10-28 16:23:25 -05:00
Austin Mroz bc1e70d3b2 Store preview params in value
This allows for previews to be restored for Video Combine on reload
setPreviewsrc is left as a convenience function
2023-10-28 15:49:19 -05:00
Austin Mroz 2fb3787cc3 Fix migration when preview exists on Video Combine 2023-10-28 15:37:00 -05:00