feat(handler): add support for processing and uploading gif videos to S3#133
Open
peter064226 wants to merge 4 commits into
Open
feat(handler): add support for processing and uploading gif videos to S3#133peter064226 wants to merge 4 commits into
peter064226 wants to merge 4 commits into
Conversation
Add logic to handle gif video outputs from ComfyUI nodes, including uploading to S3 bucket and cleaning up local files. The implementation follows the same pattern as image handling but with video-specific content type handling.
Split the output_data list into separate lists for images and videos to improve data organization and clarity. This allows for better handling of different media types in the final result. Update the final result structure to include separate "images" and "videos" fields when present, and modify the completion log message to reflect both media types.
The error messages and status field were only referencing images when checking for empty output data. This change updates them to explicitly mention both images and videos to accurately reflect the possible output types and avoid confusion.
The handler function was not including an empty "videos" array in the final_result when no images or videos were processed, which could cause issues with clients expecting this field. This change ensures consistent response structure by initializing the field similar to how "images" is handled.
TimPietruskyRunPod
requested changes
Jun 2, 2026
Contributor
TimPietruskyRunPod
left a comment
There was a problem hiding this comment.
Good direction — handling gifs (which ComfyUI uses for video/gif outputs, e.g. from ComfyUI-VideoHelperSuite or AnimateDiff) alongside images is a real gap in the current handler. Approving the concept, but several things need to change before merge:
Blocking
- Rebase required — the branch is behind
mainand conflicts. Several things have moved since you opened this (e.g. PR #197 added a process-liveness check, the response structure was clarified in #157's investigation). - Variable rename is unnecessary and noisy — splitting
output_dataintooutput_data_imagesandoutput_data_videosadds churn for no functional benefit. The final response can just be:…without renaming the existingif output_data_images: final_result["images"] = output_data_images if output_data_videos: final_result["videos"] = output_data_videos
imagesaccumulator. Please keepoutput_dataas the images list and introduce a newoutput_data_videosonly. - Hardcoded
prefix=f"comfy/{job_id}"for video S3 uploads is inconsistent with how images are uploaded (which just usesrp_upload.upload_image(job_id, ...)). And it conflicts with #191 which is adding configurableBUCKET_PREFIX. Please align — either:- Use the same
BUCKET_PREFIXenv var (preferred), or - Use
rp_upload.upload_imagefor symmetry.
- Use the same
extra_args={"ContentType": f"video/{filename.split('.')[-1]}"}is dangerous: a.webpwill becomevideo/webp,.pngwill becomevideo/png, etc. Either map known extensions (mp4,webm,gif,mov) to their MIME types explicitly, or skip theContentTypearg and let boto3 detect.- No changeset — please add
.changeset/feat-handle-video-outputs.md:--- "worker-comfyui": minor --- feat: detect `gifs` output entries from video/animation nodes (AnimateDiff, VideoHelperSuite, etc.) and return them as base64 or upload to S3 alongside images.
Non-blocking
- The local cleanup of
os.remove(file_location)happens before checking that the S3 upload succeeded. If S3 upload throws, the original file is gone and we lose recoverability. Usetry/finallylike the image path does.
Happy to merge once the rebase and the items above are addressed. The feature itself is wanted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add logic to handle gif video outputs from ComfyUI nodes, including uploading to S3 bucket and cleaning up local files. The implementation follows the same pattern as image handling but with video-specific content type handling.
Motivation
User Demand: Support animated outputs (e.g., GIFs/MP4s) from video-generation nodes (e.g., AnimateDiff, GIF-compatible savers).
Scalability: Videos are larger than images and require dedicated S3 handling (e.g., multipart uploads for big files).
Maintenance: Unify media-handling logic (images + videos) to reduce tech debt.