Skip to content

Commit 07a8ffb

Browse files
committed
fix: add validation before uploading Assets
Signed-off-by: bigcat88 <bigcat88@icloud.com>
1 parent e4afcc0 commit 07a8ffb

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

comfy_api_nodes/nodes_bytedance.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
validate_image_aspect_ratio,
5353
validate_image_dimensions,
5454
validate_string,
55+
validate_video_dimensions,
56+
validate_video_duration,
5557
)
5658
from server import PromptServer
5759

@@ -1904,6 +1906,8 @@ async def execute(
19041906
) -> IO.NodeOutput:
19051907
# if len(name) > 64:
19061908
# raise ValueError("Name of asset can not be greater then 64 symbols")
1909+
validate_image_dimensions(image, min_width=300, max_width=6000, min_height=300, max_height=6000)
1910+
validate_image_aspect_ratio(image, min_ratio=(0.4, 1), max_ratio=(2.5, 1))
19071911
resolved_group = await _resolve_group_id(cls, group_id)
19081912
asset_id = await _create_seedance_asset(
19091913
cls,
@@ -1965,6 +1969,24 @@ async def execute(
19651969
) -> IO.NodeOutput:
19661970
# if len(name) > 64:
19671971
# raise ValueError("Name of asset can not be greater then 64 symbols")
1972+
validate_video_duration(video, min_duration=2, max_duration=15)
1973+
validate_video_dimensions(video, min_width=300, max_width=6000, min_height=300, max_height=6000)
1974+
1975+
w, h = video.get_dimensions()
1976+
if h > 0:
1977+
ratio = w / h
1978+
if not (0.4 <= ratio <= 2.5):
1979+
raise ValueError(f"Asset video aspect ratio (W/H) must be in [0.4, 2.5], got {ratio:.3f} ({w}x{h}).")
1980+
pixels = w * h
1981+
if not (409_600 <= pixels <= 927_408):
1982+
raise ValueError(
1983+
f"Asset video total pixels (W×H) must be in [409600, 927408], " f"got {pixels:,} ({w}x{h})."
1984+
)
1985+
1986+
fps = float(video.get_frame_rate())
1987+
if not (24 <= fps <= 60):
1988+
raise ValueError(f"Asset video FPS must be in [24, 60], got {fps:.2f}.")
1989+
19681990
resolved_group = await _resolve_group_id(cls, group_id)
19691991
asset_id = await _create_seedance_asset(
19701992
cls,

0 commit comments

Comments
 (0)