{"record":{"id":"8f59c20cb38c4e58","repo":"sgl-project/sglang","slug":"no-frames-before-start-time-start-time-in-all-ti","errorCode":null,"errorMessage":"No frames before start_time {start_time} in all_timestamps {all_timestamps.tolist()}","messagePattern":"No frames before start_time (.+?) in all_timestamps (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/processors/mimo_v2.py","lineNumber":720,"sourceCode":"            )\n            max_pixels = max(min_pixels, min(max_pixels_per_frame, max_pixels))\n            return min_pixels, max_pixels\n\n        def segment_frame_selector(all_timestamps, start_time, end_time):\n            \"\"\"Select frame indices in [start_time, end_time). If none found, pick the nearest frame to the left.\"\"\"\n            if not isinstance(all_timestamps, torch.Tensor):\n                all_timestamps = torch.tensor(all_timestamps)\n\n            mask = (all_timestamps >= start_time) & (all_timestamps < end_time)\n            candidate_indices = torch.where(mask)[0]\n\n            if len(candidate_indices) == 0:\n                left_mask = all_timestamps <= start_time\n                left_indices = torch.where(left_mask)[0]\n                if len(left_indices) > 0:\n                    selected_frame_indices = left_indices[-1:].clone()\n                else:\n                    raise ValueError(\n                        f\"No frames before start_time {start_time} in all_timestamps {all_timestamps.tolist()}\"\n                    )\n            else:\n                selected_frame_indices = candidate_indices\n\n            assert (\n                len(selected_frame_indices) > 0\n            ), f\"No frames selected for segment {start_time} - {end_time} in all_timestamps {all_timestamps.tolist()}\"\n            return selected_frame_indices\n\n        kwargs = self.prepare_video_kwargs(video_input)\n        video = video_input.video\n\n        if not isinstance(video, tuple):\n            raise ValueError(\n                f\"video must be a tuple of (video_tensor, timestamps), but got {type(video)}. \"\n                \"Video download and decoding should be done by sglang load_video before calling process_video.\"\n            )","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/processors/mimo_v2.py#L702-L738","documentation":"Raised by segment_frame_selector when selecting frames in [start_time, end_time] yields no candidates AND there are also no frames at or before start_time to fall back to. This means the requested segment starts before the first timestamp in the decoded video (e.g. start_time earlier than frame 0, or timestamps all after the window).","triggerScenarios":"Calling process_video on a video whose sampled timestamps are all later than the requested start_time, and the start_time-relative candidate set within [start_time, end_time] is empty — e.g. segment start_time=0 with timestamps beginning at 0.5, plus a misaligned window where left_indices is also empty.","commonSituations":"Client sends video segment metadata with start_time earlier than the first decoded frame (pre-roll trimmed by decoder); mismatched time bases (milliseconds vs seconds); very short videos where fps sampling yields a single frame after the window.","solutions":["Validate that start_time <= min(timestamps) tolerance and end_time > start_time before calling","Normalize time units (seconds) for start_time/end_time on both client and server","For short videos, lower the sampling fps floor or extend end_time so at least one frame falls in the window"],"exampleFix":"# before\nselector = proc.segment_frame_selector(timestamps, start_time=100, end_time=200)  # ms vs s\n# after\nselector = proc.segment_frame_selector(timestamps, start_time=0.1, end_time=0.2)  # seconds","handlingStrategy":"validation","validationCode":"ts = timestamps.tolist()\nassert ts and min(ts) <= start_time + 1e-6 and end_time > max(start_time, min(ts)), \\\n    f'segment [{start_time},{end_time}] has no frames; timestamps span [{min(ts)},{max(ts)}]'","typeGuard":null,"tryCatchPattern":"try:\n    idx = proc.segment_frame_selector(timestamps, start_time, end_time)\nexcept ValueError as e:\n    if 'No frames before start_time' in str(e):\n        start_time = min(timestamps).item()  # clamp to first frame\n        idx = proc.segment_frame_selector(timestamps, start_time, end_time)\n    else:\n        raise","preventionTips":["Clamp start_time to the decoded timestamps' minimum","Use one time unit (seconds) end-to-end","Reject segments where end_time <= first timestamp at request validation"],"tags":["video","timestamps","segment","out-of-range"],"backgroundTag":"empty-timestamp-range","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}