Commit Graph
29 Commits
Author SHA1 Message Date
Austin Mroz 8f8df32db1 Add additional format options for transparency
Updated ProRes to allow transparent output when set to Profile 4. As
part of this change, pix_fmt is no longer explicitly set for ProRes, but
the expected format is automatically applied from for each profile.

Added rgba as an output pix_fmt for the nvenc formats. These have not
been tested and may not function.

Fix incorrect escape in Advanced Preview code.
2024-07-31 02:19:27 -05:00
Austin Mroz b5d907bade WIP preview synchronization 2024-07-10 12:57:06 -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 e23ec8befd Unmute video on mouseover
Video previews unmute when moused over.

Advanced previews now have audio included when encoded.

Fixed yet another bug with custom_size on Load Video
2024-07-05 18:28:57 -05:00
Austin Mroz 659ba661de Fix size scaling, Load Images preview, add 8bitpng
On Load Video, Size scaling had a major rewrite to support different
downscale ratios, but logic was flawed. This has been fixed

Image Sequence previews were broken by adding a framerate arg since the
input is a sequence file and not the images themself. This could be
added later by adding the speed information to the sequence file, but
has been removed for now since there isn't any infrastructure to set the
frame rate on the Load Images node itself

Added an 8bit-png output format. Lots of people seem to prefer
outputting image sequences. When the extra quality isn't required,
having a separate 8bit format allows for a significant speedup and less
disk space used.
2024-06-24 12:13:26 -05:00
Austin Mroz 61e1d4c2c2 Image sequence preview: frame rate, context menu
Frame rate is now passed so image_sequqnces play back at proper rate.

Context menu options on an image sequence (open preview, save) now
operate on the first frame instead of throwing an error.
2024-06-18 16:18:48 -05:00
Austin Mroz b70a173d5e Reduce console spam, ffmpeg_gif split filter
There were still intermittent errors and console spam from a transcoded
advanced preview being interrupted before it could finish.Connection
errors are also caught now.

ffmpeg does not appear to handle transparency as expected for gif
creation. Transparent areas will show the previous frame, or a portion
of it. A deep dive into trying to find configuration options to fix this
did not result in solutions that functioned on my machine, but did
introduce me to the ffmpeg split filter.

Split allows for a single ffmpeg execution to generate a palette and
utilize the palette for creating the output gif without requiring a temp
file. However, the video data must be buffered in memory by ffmpeg.
Quick testing seems to show that ffmpeg uses 4 bytes per pixel
of buffered frame data.

The ramifications for memory usage are nuanced, but wind up preferable.
The increased memory per pixel of ffmpeg's buffering only results in
(approximated) 3% memory increase over the whole workflow, but remove
the need for a tempfile, a second subprocess call, and allow for
imperfect Meta Batch support which can only extend the total frame count
by 5-6x. It's a reduction in moving parts for underwhelming memory
characteristics in both the best and worst case. Additionally, it likely
actually addresses the issue the original requester saw in #160

The actual code for allowing pre-passes is left in for now and will
likely be re-evaluated for other uses or pruned at a later time.

Actually bump version.
2024-06-07 00:38:34 -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 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
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 839fb73e78 Use calculated ffmpeg_path for advanced previews 2023-12-27 13:22:30 -06:00
Jedrzej Kosinski 7118192b1c added missing time import in server.py 2023-12-26 15:47:09 -06:00
Austin Mroz 9178de560d Fix previews for Load Images Nodes
resolves #94
2023-12-26 15:33:42 -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 3805fa012e README, Path suggestion, video_format fixes
In an edge case, scan dir would throw an erro when encoutering a broken
symlink. It has been fixed to ignore these broken symlinks

Fix an edge case where the video_formats folder is overridden by
ComfyUI-AnimateDiff-Evolved if VideoHelperSuite loads first. See #87

Further README additions
2023-12-10 12:00:29 -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 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 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 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 1c9f3ab7d4 Initial proof of concept preview endpoint
Adds a new url endpoint for previewing videos
The intent, is that the video can be encoded on-the-fly with low quality
parameters to return a preview of the selected video time slice, it's
resolution, and frame rate, with lessened quality to reduce transmission
time.

Initial testing has a response time that is not great,
correspondingly, this may be non-viable
2023-11-23 12:24:13 -06:00