Comfy-Org/ComfyUI · error · ValueError

resize produced no frames (start_time={start_time}, duration

Error message

resize produced no frames (start_time={start_time}, duration={duration} selected nothing from the source)

What it means

The resize_video helper counts encoded frames while copying the selected time window; if zero frames passed the start_time/duration filter it raises ValueError('resize produced no frames ...') with the exact window. This is a parameter problem: the chosen [start_time, start_time+duration] range (or a start_time past the clip end) selected nothing from the decoded stream.

Source

Thrown at comfy_api_nodes/util/conversions.py:527

        encoded = 0
        for frame in input_container.decode(video=0):
            if trimming:
                if frame.pts is None or frame.pts < start_pts:
                    continue
                if end_pts is not None and frame.pts >= end_pts:
                    break
            frame = frame.reformat(width=out_w, height=out_h, format="yuv420p")
            # Re-wrap as a fresh frame: dropping irregular source timestamps (VFR/AVI/GIF/...)
            # lets the encoder assign clean ones and avoids mp4 muxer errors.
            frame = av.VideoFrame.from_ndarray(frame.to_ndarray(format="yuv420p"), format="yuv420p")
            for packet in video_stream.encode(frame):
                output_container.mux(packet)
            encoded += 1
        for packet in video_stream.encode():
            output_container.mux(packet)

        if encoded == 0:
            raise ValueError(
                f"resize produced no frames (start_time={start_time}, duration={duration} "
                "selected nothing from the source)"
            )

        if audio_stream is not None:
            input_container.seek(0)
            for audio_frame in input_container.decode(audio=0):
                if trimming:
                    if audio_frame.time is None or audio_frame.time < start_time:
                        continue
                    if duration and audio_frame.time > start_time + duration:
                        break
                # Carry odd audio time bases the mp4 muxer rejects; reset pts, encoder assigns clean ones (MP3-in-AVI)
                audio_frame.pts = None
                for packet in audio_stream.encode(audio_frame):
                    output_container.mux(packet)
            for packet in audio_stream.encode():
                output_container.mux(packet)

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Log the clip's real duration (video.get_duration()) and clamp: 0 <= start_time < duration, and duration > 0.
  2. Ensure start_time + duration <= clip duration.
  3. For very short windows, allow at least a couple of frame intervals (2/fps seconds).
  4. The message prints start_time and duration — compare them against the source length to confirm the window is empty.

Example fix

// before
resized = resize_video(video, width=w, height=h, start_time=10.0, duration=2.0)  # clip is 8s

// after
clip_dur = video.get_duration()
start_time = max(0.0, min(start_time, clip_dur - 0.1))
duration = max(0.0, min(duration, clip_dur - start_time))
resized = resize_video(video, width=w, height=h, start_time=start_time, duration=duration)
Defensive patterns

Strategy: validation

Validate before calling

clip_duration = video.get_duration()
assert 0 <= start_time < clip_duration, 'start_time outside clip'
assert duration > 0, 'duration must be positive'
assert start_time + duration <= clip_duration + 1e-6, 'window extends past clip end'
# also require the window to span at least ~2 frames
assert duration * float(fps) >= 2, 'window shorter than two frame intervals'

Prevention

When it happens

Trigger: Calling resize_video with start_time >= clip duration; duration <= 0; a tiny duration that falls entirely between two frames; or start_time beyond the last keyframe the seek reached so the decode loop emits nothing before breaking.

Common situations: Trim sliders set past the end of the clip; duration computed as end - start where end < start (negative duration); VFR sources where frame.time jumps past the window immediately; unit confusion between seconds and frames.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/08cdb1fae8a9f778. Report an issue: GitHub.