mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-08 23:47:24 +08:00
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.
This commit is contained in:
parent
ab952395d7
commit
320fcfa29b
@ -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(
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user