Repository: huggingface/transformers
Pull request: Fix multi-video timestamp bug in Qwen-3-VL and GLM4V

# What does this PR do?

This PR fixes a timestamp placeholder error that occurs when multiple videos are included in a single text input.
In `Qwen3-VLProcessor,` frames are sampled from videos, and the relative timestamp placeholder `<{curr_time:.1f} seconds>` is constructed for each frame to indicate its corresponding time information. Previously, the code used the index `i` to retrieve the video metadata (`metadata= video_metadata[i]` ), which only worked correctly for a single video input. When multiple videos were provided, the metadata of the first video was incorrectly used to generate timestamp placeholders for all the other videos, resulting in errors.

This PR replaces the index `i` with the correct video index `index` when retrieving metadata, ensuring that each video use the appropriate timestamp placeholders.

Hi [@zach-huggingface](https://github.com/zach-huggingface) [@SunMarc](https://github.com/SunMarc) [@zucchini-nlp](https://github.com/zucchini-nlp), I am just following up on this bug and the proposed fix. It is a one-line change, and I would be happy to assist with any questions or further clarifications to help get it merged.

Thank you very much!


Changed files:
filename: src/transformers/models/glm4v/modular_glm4v.py
patch: @@ -1639,7 +1639,7 @@ def __call__(
                     num_frames = video_grid_thw[video_index][0]
                     video_structure = ""
 
-                    metadata = video_metadata[i]
+                    metadata = video_metadata[video_index]
                     if metadata.fps is None:
                         logger.warning_once(
                             "SmolVLM requires frame timestamps to construct prompts, but the `fps` of the input video could not be inferred. "

filename: src/transformers/models/glm4v/processing_glm4v.py
patch: @@ -178,7 +178,7 @@ def __call__(
                     num_frames = video_grid_thw[video_index][0]
                     video_structure = ""
 
-                    metadata = video_metadata[i]
+                    metadata = video_metadata[video_index]
                     if metadata.fps is None:
                         logger.warning_once(
                             "SmolVLM requires frame timestamps to construct prompts, but the `fps` of the input video could not be inferred. "

filename: src/transformers/models/qwen3_vl/modular_qwen3_vl.py
patch: @@ -1396,7 +1396,7 @@ def __call__(
             index = 0
             for i in range(len(text)):
                 while self.video_token in text[i]:
-                    metadata = video_metadata[i]
+                    metadata = video_metadata[index]
                     if metadata.fps is None:
                         logger.warning_once(
                             "Qwen3VL requires frame timestamps to construct prompts, but the `fps` of the input video could not be inferred. "

filename: src/transformers/models/qwen3_vl/processing_qwen3_vl.py
patch: @@ -196,7 +196,7 @@ def __call__(
             index = 0
             for i in range(len(text)):
                 while self.video_token in text[i]:
-                    metadata = video_metadata[i]
+                    metadata = video_metadata[index]
                     if metadata.fps is None:
                         logger.warning_once(
                             "Qwen3VL requires frame timestamps to construct prompts, but the `fps` of the input video could not be inferred. "