mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-18 20:38:15 +08:00
Honor strict_duration in VideoFromComponents.as_trimmed
This commit is contained in:
parent
0aecac867d
commit
7cd78e02aa
@ -598,7 +598,7 @@ class VideoFromComponents(VideoInput):
|
||||
duration: float | None = None,
|
||||
strict_duration: bool = True,
|
||||
) -> VideoInput | None:
|
||||
if self.get_duration() < start_time + duration:
|
||||
if strict_duration and self.get_duration() < start_time + duration:
|
||||
return None
|
||||
#TODO Consider tracking duration and trimming at time of save?
|
||||
return VideoFromFile(self.get_stream_source(), start_time=start_time, duration=duration)
|
||||
|
||||
@ -116,6 +116,16 @@ def test_video_from_components_get_dimensions(video_components):
|
||||
assert height == 2
|
||||
|
||||
|
||||
def test_video_from_components_as_trimmed_respects_strict_duration(video_components):
|
||||
"""as_trimmed honors strict_duration, matching VideoFromFile.as_trimmed."""
|
||||
video = VideoFromComponents(video_components)
|
||||
over = video.get_duration() + 100
|
||||
# Non-strict: a window longer than the source yields a best-effort clip, not None.
|
||||
assert video.as_trimmed(start_time=0, duration=over, strict_duration=False) is not None
|
||||
# Strict: the same over-long window is rejected.
|
||||
assert video.as_trimmed(start_time=0, duration=over, strict_duration=True) is None
|
||||
|
||||
|
||||
def test_video_from_file_get_duration(simple_video_file):
|
||||
"""Duration extracted from file metadata"""
|
||||
video = VideoFromFile(simple_video_file)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user