{"record":{"id":"08cdb1fae8a9f778","repo":"Comfy-Org/ComfyUI","slug":"resize-produced-no-frames-start-time-start-time","errorCode":null,"errorMessage":"resize produced no frames (start_time={start_time}, duration={duration} selected nothing from the source)","messagePattern":"resize produced no frames \\(start_time=(.+?), duration=(.+?) selected nothing from the source\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/util/conversions.py","lineNumber":527,"sourceCode":"        encoded = 0\n        for frame in input_container.decode(video=0):\n            if trimming:\n                if frame.pts is None or frame.pts < start_pts:\n                    continue\n                if end_pts is not None and frame.pts >= end_pts:\n                    break\n            frame = frame.reformat(width=out_w, height=out_h, format=\"yuv420p\")\n            # Re-wrap as a fresh frame: dropping irregular source timestamps (VFR/AVI/GIF/...)\n            # lets the encoder assign clean ones and avoids mp4 muxer errors.\n            frame = av.VideoFrame.from_ndarray(frame.to_ndarray(format=\"yuv420p\"), format=\"yuv420p\")\n            for packet in video_stream.encode(frame):\n                output_container.mux(packet)\n            encoded += 1\n        for packet in video_stream.encode():\n            output_container.mux(packet)\n\n        if encoded == 0:\n            raise ValueError(\n                f\"resize produced no frames (start_time={start_time}, duration={duration} \"\n                \"selected nothing from the source)\"\n            )\n\n        if audio_stream is not None:\n            input_container.seek(0)\n            for audio_frame in input_container.decode(audio=0):\n                if trimming:\n                    if audio_frame.time is None or audio_frame.time < start_time:\n                        continue\n                    if duration and audio_frame.time > start_time + duration:\n                        break\n                # Carry odd audio time bases the mp4 muxer rejects; reset pts, encoder assigns clean ones (MP3-in-AVI)\n                audio_frame.pts = None\n                for packet in audio_stream.encode(audio_frame):\n                    output_container.mux(packet)\n            for packet in audio_stream.encode():\n                output_container.mux(packet)","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/util/conversions.py#L509-L545","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Log the clip's real duration (video.get_duration()) and clamp: 0 <= start_time < duration, and duration > 0.","Ensure start_time + duration <= clip duration.","For very short windows, allow at least a couple of frame intervals (2/fps seconds).","The message prints start_time and duration — compare them against the source length to confirm the window is empty."],"exampleFix":"// before\nresized = resize_video(video, width=w, height=h, start_time=10.0, duration=2.0)  # clip is 8s\n\n// after\nclip_dur = video.get_duration()\nstart_time = max(0.0, min(start_time, clip_dur - 0.1))\nduration = max(0.0, min(duration, clip_dur - start_time))\nresized = resize_video(video, width=w, height=h, start_time=start_time, duration=duration)","handlingStrategy":"validation","validationCode":"clip_duration = video.get_duration()\nassert 0 <= start_time < clip_duration, 'start_time outside clip'\nassert duration > 0, 'duration must be positive'\nassert start_time + duration <= clip_duration + 1e-6, 'window extends past clip end'\n# also require the window to span at least ~2 frames\nassert duration * float(fps) >= 2, 'window shorter than two frame intervals'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always clamp start_time and duration against get_duration() before calling resize/trim.","Treat time parameters as seconds everywhere; convert explicitly if your UI uses frames.","Beware VFR sources: keep windows at least several frames wide."],"tags":["video","pyav","trim","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}