Skip to content

feat: add GetVideoLastFrame node (CORE-123)#13602

Closed
bigcat88 wants to merge 1 commit intomasterfrom
feat/video-last-frame-node
Closed

feat: add GetVideoLastFrame node (CORE-123)#13602
bigcat88 wants to merge 1 commit intomasterfrom
feat/video-last-frame-node

Conversation

@bigcat88
Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: bigcat88 <bigcat88@icloud.com>
@bigcat88 bigcat88 marked this pull request as ready for review April 28, 2026 16:17
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

This pull request adds a new GetVideoLastFrame node to the Comfy video extension. The node extracts and returns the last visible frame from a video file or video components as a normalized image tensor. The implementation includes a fast path for VideoFromFile inputs that performs seeking and direct frame decoding, with fallback to the existing get_components() path for trimmed or complex cases. Comprehensive unit tests validate frame extraction across various video formats, trimming behavior, tensor contract compliance, and error handling.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.74% 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 relevance to the changeset. Add a description explaining the purpose and use case for the GetVideoLastFrame node to provide context for reviewers.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a new GetVideoLastFrame node to the codebase.

✏️ 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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests-unit/comfy_extras_test/nodes_video_test.py (1)

298-301: Tighten the corrupt-input expectation.

pytest.raises(Exception) is very broad and can pass on unrelated regressions. Prefer asserting a narrower failure condition (specific error text or bounded exception set) so this test catches the right failure mode.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests-unit/comfy_extras_test/nodes_video_test.py` around lines 298 - 301,
Change the test to assert a narrower failure: replace pytest.raises(Exception)
in test_corrupt_bytes_raises with a specific exception type thrown by
GetVideoLastFrame.execute for invalid input (e.g., pytest.raises(ValueError))
and optionally add a match argument to assert the error message contains a
distinguishing substring like "corrupt" or "decode"; locate this in the test
function test_corrupt_bytes_raises which constructs the bad input via
InputImpl.VideoFromFile(io.BytesIO(...)) and calls
GetVideoLastFrame.execute(video).
🤖 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_extras/nodes_video.py`:
- Around line 200-203: The fixed 0.003s tolerance used when comparing
raw_duration_us/av.time_base to reported_duration_s can mis-detect trims for
high-FPS sources; replace the magic constant with a frame-rate-aware tolerance
by querying the stream frame rate (e.g., use av.average_rate or av.rate),
compute frame_duration_s = 1.0 / float(frame_rate) (fallback to a sensible
default if unavailable), then set threshold = min(0.003, 0.5 * frame_duration_s)
and use that threshold in the existing comparison using raw_duration_us,
av.time_base and reported_duration_s so tiny per-frame offsets at high FPS are
handled correctly.

---

Nitpick comments:
In `@tests-unit/comfy_extras_test/nodes_video_test.py`:
- Around line 298-301: Change the test to assert a narrower failure: replace
pytest.raises(Exception) in test_corrupt_bytes_raises with a specific exception
type thrown by GetVideoLastFrame.execute for invalid input (e.g.,
pytest.raises(ValueError)) and optionally add a match argument to assert the
error message contains a distinguishing substring like "corrupt" or "decode";
locate this in the test function test_corrupt_bytes_raises which constructs the
bad input via InputImpl.VideoFromFile(io.BytesIO(...)) and calls
GetVideoLastFrame.execute(video).
🪄 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: ece8b7bb-bfd0-46b1-85ce-ef74d8c60228

📥 Commits

Reviewing files that changed from the base of the PR and between 24de8dc and ddb52f4.

📒 Files selected for processing (2)
  • comfy_extras/nodes_video.py
  • tests-unit/comfy_extras_test/nodes_video_test.py

Comment thread comfy_extras/nodes_video.py
@alexisrolland alexisrolland changed the title feat: add GetVideoLastFrame node feat: add GetVideoLastFrame node (CORE-123) Apr 28, 2026
@alexisrolland
Copy link
Copy Markdown
Member

As discussed, this can be managed with a couple of nodes packaged as blueprints. We will add it to the next blueprints updates: #13611

Example:

image

Blueprint:

image

@bigcat88 bigcat88 deleted the feat/video-last-frame-node branch April 30, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants