Skip to content

Read audio and video at the same time in video loader node.#13591

Merged
comfyanonymous merged 1 commit into
masterfrom
temp_pr
Apr 27, 2026
Merged

Read audio and video at the same time in video loader node.#13591
comfyanonymous merged 1 commit into
masterfrom
temp_pr

Conversation

@comfyanonymous

Copy link
Copy Markdown
Member

No description provided.

@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The changes consolidate video and audio processing into a single demux loop instead of separate decoding passes. Video frames are collected with one-time alpha-channel detection per file. Audio packets are decoded, resampled to fltp, and offset-skipped within the loop when present. Stop conditions are managed through video_done and audio_done flags. Container seeking is skipped when start_pts equals zero. An InvalidDataError during video decoding is caught and logged. Previous logic that re-sought and re-decoded audio in a separate block has been removed. Audio output is now built solely from frames captured during the demux process.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether one exists and relates to the changeset. Add a description explaining the motivation, implementation approach, and benefits of reading audio and video concurrently.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: refactoring video loading to read audio and video simultaneously rather than sequentially.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@comfy_api/latest/_input_impl/video_types.py`:
- Around line 299-300: The except block catching av.error.InvalidDataError
currently only logs ("pyav decode error") which lets the function (e.g., the
video decoding routine handling av.error.InvalidDataError) return partially
decoded frames; change it to stop silent continuation by re-raising the caught
exception (or raise a new, descriptive exception that includes the original
error) instead of just logging—replace the logging.info("pyav decode error") in
the except av.error.InvalidDataError handler with raising the exception
(including the original exception message) so corrupted/incomplete video data
cannot be returned as valid output.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 24e9663d-19fd-4d69-9306-c91a2965d631

📥 Commits

Reviewing files that changed from the base of the PR and between 64b8457 and c628e74.

📒 Files selected for processing (1)
  • comfy_api/latest/_input_impl/video_types.py
Comment on lines +299 to +300
except av.error.InvalidDataError:
logging.info("pyav decode error")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

��� Analysis chain

🏁 Script executed:

# First, let's see the full context around lines 299-300 in the file
cd comfy_api && git diff HEAD~1 HEAD -- latest/_input_impl/video_types.py | head -200

Repository: Comfy-Org/ComfyUI

Length of output: 90


🏁 Script executed:

# If git diff isn't available, let's examine the file structure and context
wc -l comfy_api/latest/_input_impl/video_types.py

Repository: Comfy-Org/ComfyUI

Length of output: 109


🏁 Script executed:

# Get the full context around lines 299-300 with surrounding code
sed -n '280,320p' comfy_api/latest/_input_impl/video_types.py

Repository: Comfy-Org/ComfyUI

Length of output: 1982


🏁 Script executed:

# Check if this file has recent changes and understand the context
git log --oneline -20 comfy_api/latest/_input_impl/video_types.py 2>/dev/null || echo "Git history not available"

Repository: Comfy-Org/ComfyUI

Length of output: 129


🏁 Script executed:

# Get broader context to see the function structure and what gets returned
sed -n '250,350p' comfy_api/latest/_input_impl/video_types.py

Repository: Comfy-Org/ComfyUI

Length of output: 4406


🏁 Script executed:

# Look for the function definition and return statement
grep -n "def get_components_internal\|return " comfy_api/latest/_input_impl/video_types.py | head -20

Repository: Comfy-Org/ComfyUI

Length of output: 1191


🏁 Script executed:

# Get the full function to understand the control flow
sed -n '200,400p' comfy_api/latest/_input_impl/video_types.py

Repository: Comfy-Org/ComfyUI

Length of output: 8766


Silently continuing after decode corruption can return partial video as valid output.

On lines 299–300, catching av.error.InvalidDataError and only logging allows the function to return whatever frames were decoded before the error occurred. This makes corrupted or incomplete data indistinguishable from valid output. Consider raising an error instead to prevent returning partial components:

Suggested fix
-                except av.error.InvalidDataError:
-                    logging.info("pyav decode error")
+                except av.error.InvalidDataError as e:
+                    logging.warning("pyav decode error: %s", e)
+                    raise ValueError("Video decode failed due to invalid/corrupt data") from e
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
except av.error.InvalidDataError:
logging.info("pyav decode error")
except av.error.InvalidDataError as e:
logging.warning("pyav decode error: %s", e)
raise ValueError("Video decode failed due to invalid/corrupt data") from e
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@comfy_api/latest/_input_impl/video_types.py` around lines 299 - 300, The
except block catching av.error.InvalidDataError currently only logs ("pyav
decode error") which lets the function (e.g., the video decoding routine
handling av.error.InvalidDataError) return partially decoded frames; change it
to stop silent continuation by re-raising the caught exception (or raise a new,
descriptive exception that includes the original error) instead of just
logging—replace the logging.info("pyav decode error") in the except
av.error.InvalidDataError handler with raising the exception (including the
original exception message) so corrupted/incomplete video data cannot be
returned as valid output.
@comfyanonymous comfyanonymous merged commit 3cbf015 into master Apr 27, 2026
16 checks passed
@comfyanonymous comfyanonymous deleted the temp_pr branch April 27, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant