[Perf][Multimodal] Avoid building a full timestamps list in video frame sampling (#46543)

Signed-off-by: Lynn <lynnhe02@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Lynn committed Jun 24, 2026 at 04:38 UTC 52fbe12283f030c6bbfeb835bab634cbf2be045e
1 file changed +2 -4
vllm/multimodal/video.py
+2 -4
@@ -885,7 +885,6 @@ class GLM46VVideoBackend(VideoBackend):
885 extract_t = min(extract_t, cls._MAX_FRAME_COUNT_DYNAMIC)
886
887 duration_per_frame = 1 / original_fps if original_fps > 0 else 0
888 - timestamps = [i * duration_per_frame for i in range(total_frames_num)]
888 max_second = int(duration) if duration else 0
889
890 if total_frames_num < extract_t:
@@ -897,7 +896,7 @@ class GLM46VVideoBackend(VideoBackend):
896 current_second = 0.0
897 inv_fps = 1 / (temporal_patch_size * target_fps)
898 for frame_index in range(total_frames_num):
900 - if timestamps[frame_index] >= current_second:
899 + if frame_index * duration_per_frame >= current_second:
900 current_second += inv_fps
901 frame_indices.append(frame_index)
902 if current_second >= max_second:
@@ -991,7 +990,6 @@ class GLMGAVideoBackend(VideoBackend):
990 extract_t = min(extract_t, max_frames)
991
992 duration_per_frame = 1 / original_fps
994 - timestamps = [i * duration_per_frame for i in range(total_frames_num)]
993
994 if total_frames_num < extract_t:
995 frame_indices = [
@@ -1002,7 +1000,7 @@ class GLMGAVideoBackend(VideoBackend):
1000 current_second = 0.0
1001 inv_fps = 1 / target_fps
1002 for frame_index in range(total_frames_num):
1005 - if timestamps[frame_index] >= current_second:
1003 + if frame_index * duration_per_frame >= current_second:
1004 current_second += inv_fps
1005 frame_indices.append(frame_index)
1006 if current_second >= duration - inv_fps: