-
Notifications
You must be signed in to change notification settings - Fork 30
feat: custom resolution support for comfyui live pipeline #586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
290eeee to
53c82eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds support for custom input/output resolution parameters in the comfyui live pipeline by propagating width and height values from the request to the encoder, decoder, and workflow configuration. Key changes include modifying the subscribe, publish, encoder, and decoder functions to accept and use dynamic resolution parameters, updating the default workflow JSON to reflect the new resolutions, and propagating resolution settings in the streamer.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| runner/app/live/trickle/media.py | Updated to pass output_width and output_height to decode_in and encode_in. |
| runner/app/live/trickle/encoder.py | Modified to dynamically set video resolution in the encoder. |
| runner/app/live/trickle/decoder.py | Adjusted decoding to enforce requested dimensions. |
| runner/app/live/streamer/streamer.py | Introduced resolution settings but with a potential bug in target_height assignment. |
| runner/app/live/streamer/protocol/trickle.py | Updated to pass resolution parameters when calling media.run_subscribe and media.run_publish. |
| runner/app/live/pipelines/comfyui_default_workflow.json | Updated workflow engine name and array formatting to reflect new resolution support. |
| runner/app/live/pipelines/comfyui.py | Modified initialization to update latent image dimensions and warmup pipeline with dynamic resolutions. |
Comments suppressed due to low confidence (1)
runner/app/live/pipelines/comfyui.py:110
- The variables 'width' and 'height' are not defined in this scope. It may be intended to use new_params.width and new_params.height instead, so please adjust the initialization logic accordingly.
if width is None or height is None:
34b499a to
03c8e7f
Compare
8bf3d8e to
bae6941
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces custom resolution support for the ComfyUI live pipeline by parsing the resolution from the workflow’s EmptyLatentImage node. Key changes include:
- Extracting latent image dimensions from the workflow JSON.
- Propagating custom output width and height through subscription, decoding, encoding, streaming, and pipeline initialization.
- Updating default resolution values and adjusting image resizing behavior to use the target resolution.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| runner/app/live/utils/comfy_utils.py | Introduces utility to extract latent image dimensions from workflows. |
| runner/app/live/trickle/media.py | Updates run_subscribe to accept output width and height parameters. |
| runner/app/live/trickle/encoder.py | Adapts video stream options using dynamic resolution values. |
| runner/app/live/trickle/decoder.py | Uses passed resolution values when reformatting video frames. |
| runner/app/live/streamer/streamer.py | Passes target dimensions to protocols and removes hardcoded cropping. |
| runner/app/live/streamer/protocol/trickle.py | Propagates resolution settings to the subscribe function. |
| runner/app/live/streamer/process_guardian.py | Checks for resolution changes and restarts the process if needed. |
| runner/app/live/pipelines/comfyui_default_workflow.json | Updates default workflow dimensions to match the new resolution setup. |
| runner/app/live/pipelines/comfyui.py | Warms up the pipeline using the workflow’s resolution values. |
Comments suppressed due to low confidence (2)
runner/app/live/utils/comfy_utils.py:5
- The default resolution values (384x704) differ from the PR description's fallback of 512x512; please confirm if this discrepancy is intentional or if the documentation should be updated.
DEFAULT_WIDTH = 384
runner/app/live/streamer/streamer.py:198
- The previous cropping logic for non-square images has been removed in favor of direct resizing, which may lead to image distortion if the aspect ratios differ. Please verify that this change in behavior is intended.
if (width, height) != (self.width, self.height):
65eeee6 to
84ded4a
Compare
280f87e to
83d6b52
Compare
runner/app/live/api/api.py
Outdated
| return web.json_response(status.model_dump()) | ||
|
|
||
|
|
||
| async def handle_restart_pipeline(request: web.Request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For testing only, can be removed
290dfaf to
e0c7aea
Compare
b84b6c0 to
084e11b
Compare
3d18216 to
bc5191f
Compare
| self.streamer = streamer or _NoopStreamerCallbacks() | ||
|
|
||
| self.process.reset_stream(request_id, manifest_id, stream_id) | ||
| self.process.update_params(params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likely not needed
| if not self.process: | ||
| raise RuntimeError("Process not running") | ||
|
|
||
| # Check if resolution has changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove, comfyui pipeline will stop itself
This change sets the ComfyUI pipeline to resize incoming video streams to match the expected resolution of the workflow by parsing the Empty Latent Image node from the workflow prompt, safely falling back to a default of
512x512Functional notes:
Related comfystream changes livepeer/comfystream#250