From 320fcfa29b68a0421bd02ed9f5f2d4c196f65436 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Tue, 9 Jun 2026 17:47:29 +0000 Subject: [PATCH] fixup: address review feedback round 2 - Rename test to reflect that it only validates the in-memory BytesIO stream-copy path; documents that the .mp4 file-path case (SaveVideo's default) drops alpha. - Flush the libvpx-vp9 decoder with decode(None) in the helper. - Rework BriaTransparentVideoBackground description to make it explicit that this is currently the only way to persist the alpha channel to disk. --- comfy_api_nodes/nodes_bria.py | 7 ++++--- tests-unit/comfy_api_test/video_types_test.py | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/comfy_api_nodes/nodes_bria.py b/comfy_api_nodes/nodes_bria.py index 9b4a5b34e..4296a3a3d 100644 --- a/comfy_api_nodes/nodes_bria.py +++ b/comfy_api_nodes/nodes_bria.py @@ -519,9 +519,10 @@ class BriaTransparentVideoBackground(IO.ComfyNode): display_name="Bria Remove Video Background (Transparent)", category="partner/video/Bria", description="Remove the background from a video using Bria and return the cut-out frames " - "plus an alpha mask, ready for per-frame compositing or feeding into Save WEBM. Use this " - "when you need IMAGE + MASK sockets; if you only need to save a transparent video file, " - "use 'Bria Remove Video Background' with background_color='Transparent' instead.", + "plus an alpha mask, ready for per-frame compositing or feeding into Save WEBM to " + "persist a transparent video to disk. This is currently the only way to save the " + "alpha channel: Save Video on the consolidated 'Bria Remove Video Background' node's " + "Transparent output writes a .mp4 by default and drops the VP9 alpha plane on mux.", inputs=[ IO.Video.Input("video"), IO.Int.Input( diff --git a/tests-unit/comfy_api_test/video_types_test.py b/tests-unit/comfy_api_test/video_types_test.py index b2729bf50..84f963517 100644 --- a/tests-unit/comfy_api_test/video_types_test.py +++ b/tests-unit/comfy_api_test/video_types_test.py @@ -273,14 +273,21 @@ def _per_frame_alpha_means_libvpx(source) -> list: for frame in decoder.decode(packet): rgba = frame.to_ndarray(format="rgba") means.append(float(rgba[..., 3].mean())) + try: + for frame in decoder.decode(None): + rgba = frame.to_ndarray(format="rgba") + means.append(float(rgba[..., 3].mean())) + except EOFError: + pass return means -def test_save_to_auto_preserves_vp9_alpha_via_stream_copy(): - """Save Video with format=auto, codec=auto stream-copies a WebM/VP9+alpha file - without touching the alpha plane. This is the assumption that the consolidated - 'Bria Remove Video Background' node relies on when background_color='Transparent' - (which makes Bria return a webm_vp9 url with a real alpha channel).""" +def test_video_from_file_save_to_bytesio_stream_copies_vp9_alpha(): + """VideoFromFile.save_to(BytesIO, format=AUTO, codec=AUTO) stream-copies the source + container/codec without re-encoding, so a WebM/VP9 file with an alpha plane + round-trips unchanged. Note: this covers ONLY the in-memory BytesIO path. Saving + to a .mp4 file (SaveVideo's default extension) muxes VP9 into MP4 and drops the + alpha plane -- intentionally not covered here; see PR notes.""" raw = _make_webm_vp9_with_alpha() original_means = _per_frame_alpha_means_libvpx(io.BytesIO(raw)) assert len(original_means) > 0, "test fixture failed to produce frames"